2828from .defaults import DEFAULT_RP_KEY_DEFS
2929from .exception import OidcServiceError
3030from .oauth2 import Client
31+ from .oauth2 import dynamic_provider_info_discovery
3132from .oauth2 .utils import pick_redirect_uri
3233from .util import add_path
33- from .util import dynamic_provider_info_discovery
3434from .util import load_registration_response
3535from .util import rndstr
3636
@@ -185,11 +185,15 @@ def init_client(self, issuer):
185185 _context .jwks_uri = self .jwks_uri
186186 return client
187187
188- def do_provider_info (self , client = None , state = '' , behaviour_args = None ):
188+ def do_provider_info (self ,
189+ client : Optional [Client ]= None ,
190+ state : Optional [str ]= '' ,
191+ behaviour_args : Optional [dict ]= None ) -> str :
189192 """
190193 Either get the provider info from configuration or through dynamic
191194 discovery.
192195
196+ :param behaviour_args:
193197 :param client: A Client instance
194198 :param state: A key by which the state of the session can be
195199 retrieved
@@ -205,7 +209,7 @@ def do_provider_info(self, client=None, state='', behaviour_args=None):
205209
206210 _context = client .client_get ("service_context" )
207211 if not _context .get ('provider_info' ):
208- dynamic_provider_info_discovery (client )
212+ dynamic_provider_info_discovery (client , behaviour_args = behaviour_args )
209213 return _context .get ('provider_info' )['issuer' ]
210214 else :
211215 _pi = _context .get ('provider_info' )
@@ -280,16 +284,9 @@ def do_client_registration(self, client=None,
280284 _params = RegistrationRequest ().parameters ()
281285 request_args .update ({k : v for k , v in behaviour_args .items () if k in _params })
282286
283- # _ignore = [k for k in list(request_args.keys()) if k in CALLBACK_URIS]
284- # if _context.get('redirect_uris'):
285- # if 'redirect_uris' not in _ignore:
286- # _ignore.append('redirect_uris')
287- #
288- # add_callbacks(_context, _ignore)
289-
290287 load_registration_response (client , request_args = request_args )
291288
292- def do_webfinger (self , user ) :
289+ def do_webfinger (self , user : str ) -> Client :
293290 """
294291 Does OpenID Provider Issuer discovery using webfinger.
295292
@@ -304,7 +301,10 @@ def do_webfinger(self, user):
304301 temporary_client .do_request ('webfinger' , resource = user )
305302 return temporary_client
306303
307- def client_setup (self , iss_id = '' , user = '' , behaviour_args = None ):
304+ def client_setup (self ,
305+ iss_id : Optional [str ] = '' ,
306+ user : Optional [str ] = '' ,
307+ behaviour_args : Optional [dict ] = None ) -> Client :
308308 """
309309 First if no issuer ID is given then the identifier for the user is
310310 used by the webfinger service to try to find the issuer ID.
@@ -358,11 +358,17 @@ def _get_response_type(self, context, req_args: Optional[dict] = None):
358358 else :
359359 return context .get ('behaviour' )['response_types' ][0 ]
360360
361- def init_authorization (self , client = None , state = '' , req_args = None , behaviour_args = None ):
361+ def init_authorization (self ,
362+ client : Optional [Client ] = None ,
363+ state : Optional [str ] = '' ,
364+ req_args : Optional [dict ] = None ,
365+ behaviour_args : Optional [dict ] = None ) -> dict :
362366 """
363367 Constructs the URL that will redirect the user to the authorization
364368 endpoint of the OP/AS.
365369
370+ :param behaviour_args:
371+ :param state:
366372 :param client: A Client instance
367373 :param req_args: Non-default Request arguments
368374 :return: A dictionary with 2 keys: **url** The authorization redirect
@@ -607,8 +613,7 @@ def userinfo_in_id_token(id_token):
607613 :param id_token: An :py:class:`oidcmsg.oidc.IDToken` instance
608614 :return: A dictionary with user information
609615 """
610- res = dict ([(k , id_token [k ]) for k in OpenIDSchema .c_param .keys () if
611- k in id_token ])
616+ res = dict ([(k , id_token [k ]) for k in OpenIDSchema .c_param .keys () if k in id_token ])
612617 res .update (id_token .extra ())
613618 return res
614619
@@ -629,7 +634,8 @@ def finalize_auth(self, client, issuer: str, response: dict,
629634
630635 _srv = client .get_service ('authorization' )
631636 try :
632- authorization_response = _srv .parse_response (response , sformat = 'dict' )
637+ authorization_response = _srv .parse_response (response , sformat = 'dict' ,
638+ behaviour_args = behaviour_args )
633639 except Exception as err :
634640 logger .error ('Parsing authorization_response: {}' .format (err ))
635641 message = traceback .format_exception (* sys .exc_info ())
0 commit comments