def authentication_method_generator(request, auth):
 if (auth is None):
  raise exception.ValidationError(attribute='auth', target='request body')
 if request.environ.get('REMOTE_USER'):
  method = ExternalAuthenticationMethod()
 elif ('token' in auth):
  method = TokenAuthenticationMethod()
 elif ('passwordCredentials' in auth):
  method = LocalAuthenticationMethod()
 else:
  raise exception.ValidationError(attribute='auth', target='request body')
 return method

def authentication_method_generator ( request , auth ) : if ( auth is None ) : raise exception . ValidationError ( attribute = 'auth' , target = 'request body' ) if request . environ . get ( 'REMOTE_USER' ) : method = ExternalAuthenticationMethod ( ) elif ( 'token' in auth ) : method = TokenAuthenticationMethod ( ) elif ( 'passwordCredentials' in auth ) : method = LocalAuthenticationMethod ( ) else : raise exception . ValidationError ( attribute = 'auth' , target = 'request body' ) return method
given an request return a suitable authentication method .