<s> from rest_framework import authentication , exceptions <EOL> class DoacAuthentication ( authentication . BaseAuthentication ) : <EOL> def authenticate ( self , request ) : <EOL> """<STR_LIT>""" <EOL> from doac . middleware import AuthenticationMiddleware <EOL> try : <EOL> response = AuthenticationMiddleware ( ) . process_request ( request ) <EOL> except : <EOL> raise exceptions . AuthenticationFailed ( "<STR_LIT>" ) <EOL> if not hasattr ( request , "<STR_LIT:user>" ) or not request . user . is_authenticated ( ) : <EOL> return None <EOL> if not hasattr ( request , "<STR_LIT>" ) : <EOL> raise exceptions . AuthenticationFailed ( "<STR_LIT>" ) <EOL> return request . user , request . access_token <EOL> def authenticate_header ( self , request ) : <EOL> """<STR_LIT>""" <EOL> from doac . conf import options <EOL> return '<STR_LIT>' % options . realm </s>
