@@ -131,9 +131,7 @@ def is_usable(self, request=None, authorization_token=None):
131131
132132 def verify (self , request , ** kwargs ):
133133 if (
134- self .server_get ("endpoint_context" ).cdb [request ["client_id" ]][
135- "client_secret"
136- ]
134+ self .server_get ("endpoint_context" ).cdb [request ["client_id" ]]["client_secret" ]
137135 == request ["client_secret" ]
138136 ):
139137 return {"client_id" : request ["client_id" ]}
@@ -148,9 +146,7 @@ class BearerHeader(ClientSecretBasic):
148146 tag = "bearer_header"
149147
150148 def is_usable (self , request = None , authorization_token = None ):
151- if authorization_token is not None and authorization_token .startswith (
152- "Bearer "
153- ):
149+ if authorization_token is not None and authorization_token .startswith ("Bearer " ):
154150 return True
155151 return False
156152
@@ -203,9 +199,7 @@ def verify(self, request, key_type, **kwargs):
203199 if _sign_alg and _sign_alg .startswith ("HS" ):
204200 if key_type == "private_key" :
205201 raise AttributeError ("Wrong key type" )
206- keys = _context .keyjar .get (
207- "sig" , "oct" , ca_jwt ["iss" ], ca_jwt .jws_header .get ("kid" )
208- )
202+ keys = _context .keyjar .get ("sig" , "oct" , ca_jwt ["iss" ], ca_jwt .jws_header .get ("kid" ))
209203 _secret = _context .cdb [ca_jwt ["iss" ]].get ("client_secret" )
210204 if _secret and keys [0 ].key != as_bytes (_secret ):
211205 raise AttributeError ("Oct key used for signing not client_secret" )
@@ -361,14 +355,10 @@ def verify_client(
361355 if _method .is_usable (request , authorization_token ):
362356 try :
363357 auth_info = _method .verify (
364- request = request ,
365- authorization_token = authorization_token ,
366- endpoint = endpoint ,
358+ request = request , authorization_token = authorization_token , endpoint = endpoint ,
367359 )
368360 except Exception as err :
369- logger .warning (
370- "Verifying auth using {} failed: {}" .format (_method .tag , err )
371- )
361+ logger .warning ("Verifying auth using {} failed: {}" .format (_method .tag , err ))
372362 else :
373363 if "method" not in auth_info :
374364 auth_info ["method" ] = _method .tag
@@ -398,19 +388,15 @@ def verify_client(
398388 raise UnknownClient ("Unknown Client ID" )
399389
400390 if not valid_client_info (_cinfo ):
401- logger .warning (
402- "Client registration has timed out or " "client secret is expired."
403- )
391+ logger .warning ("Client registration has timed out or " "client secret is expired." )
404392 raise InvalidClient ("Not valid client" )
405393
406394 # store what authn method was used
407395 if auth_info .get ("method" ):
408396 _request_type = request .__class__ .__name__
409397 _used_authn_method = endpoint_context .cdb [client_id ].get ("auth_method" )
410398 if _used_authn_method :
411- endpoint_context .cdb [client_id ]["auth_method" ][
412- _request_type
413- ] = auth_info ["method" ]
399+ endpoint_context .cdb [client_id ]["auth_method" ][_request_type ] = auth_info ["method" ]
414400 else :
415401 endpoint_context .cdb [client_id ]["auth_method" ] = {
416402 _request_type : auth_info ["method" ]
@@ -422,9 +408,7 @@ def verify_client(
422408
423409 try :
424410 # get_client_id_from_token is a callback... Do not abuse for code readability.
425- auth_info ["client_id" ] = get_client_id_from_token (
426- endpoint_context , _token , request
427- )
411+ auth_info ["client_id" ] = get_client_id_from_token (endpoint_context , _token , request )
428412 except KeyError :
429413 raise ValueError ("Unknown token" )
430414
0 commit comments