1818from oidcmsg .oidc import AuthorizationResponse
1919from oidcmsg .oidc import Claims
2020from oidcmsg .oidc import OpenIDSchema
21+ from oidcmsg .oidc import RegistrationRequest
2122from oidcmsg .oidc .session import BackChannelLogoutRequest
2223from oidcmsg .time_util import time_sans_frac
2324
@@ -180,7 +181,7 @@ def init_client(self, issuer):
180181 _context .jwks_uri = self .jwks_uri
181182 return client
182183
183- def do_provider_info (self , client = None , state = '' ):
184+ def do_provider_info (self , client = None , state = '' , behaviour_args = None ):
184185 """
185186 Either get the provider info from configuration or through dynamic
186187 discovery.
@@ -235,10 +236,14 @@ def do_provider_info(self, client=None, state=''):
235236 except KeyError :
236237 return _context .get ('issuer' )
237238
238- def do_client_registration (self , client = None , iss_id = '' , state = '' ):
239+ def do_client_registration (self , client = None ,
240+ iss_id : Optional [str ] = '' ,
241+ state : Optional [str ] = '' ,
242+ behaviour_args : Optional [dict ] = None ):
239243 """
240244 Prepare for and do client registration if configured to do so
241245
246+ :param behaviour_args: To fine tune behaviour
242247 :param client: A Client instance
243248 :param state: A key by which the state of the session can be
244249 retrieved
@@ -271,7 +276,9 @@ def do_client_registration(self, client=None, iss_id='', state=''):
271276 v for k , v in callbacks .items () if not k .startswith ('__' )])
272277 _context .set ('callbacks' , callbacks )
273278
274- load_registration_response (client )
279+ _params = RegistrationRequest ().parameters ()
280+ request_args = {k :v for k , v in behaviour_args .items () if k in _params }
281+ load_registration_response (client , request_args = request_args )
275282
276283 def add_callbacks (self , service_context ):
277284 _iss = service_context .get ('issuer' )
@@ -298,7 +305,7 @@ def do_webfinger(self, user):
298305 temporary_client .do_request ('webfinger' , resource = user )
299306 return temporary_client
300307
301- def client_setup (self , iss_id = '' , user = '' ):
308+ def client_setup (self , iss_id = '' , user = '' , behaviour_args = None ):
302309 """
303310 First if no issuer ID is given then the identifier for the user is
304311 used by the webfinger service to try to find the issuer ID.
@@ -307,6 +314,7 @@ def client_setup(self, iss_id='', user=''):
307314 the necessary information for the client to be able to communicate
308315 with the OP/AS that has the provided issuer ID.
309316
317+ :param behaviour_args: To fine tune behaviour
310318 :param iss_id: The issuer ID
311319 :param user: A user identifier
312320 :return: A :py:class:`oidcrp.oidc.Client` instance
@@ -335,10 +343,10 @@ def client_setup(self, iss_id='', user=''):
335343 return client
336344
337345 logger .debug ("Get provider info" )
338- issuer = self .do_provider_info (client )
346+ issuer = self .do_provider_info (client , behaviour_args = behaviour_args )
339347
340348 logger .debug ("Do client registration" )
341- self .do_client_registration (client , iss_id )
349+ self .do_client_registration (client , iss_id , behaviour_args = behaviour_args )
342350
343351 self .issuer2rp [issuer ] = client
344352 return client
@@ -439,7 +447,7 @@ def begin(self, issuer_id='', user_id='', req_args=None, behaviour_args=None):
439447 """
440448
441449 # Get the client instance that has been assigned to this issuer
442- client = self .client_setup (issuer_id , user_id )
450+ client = self .client_setup (issuer_id , user_id , behaviour_args = behaviour_args )
443451
444452 try :
445453 res = self .init_authorization (client , req_args = req_args , behaviour_args = behaviour_args )
0 commit comments