Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit d334f73

Browse files
committed
Make repsonse_type actually matter.
1 parent bbdab14 commit d334f73

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/oidcrp/rp_handler.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,21 @@ def create_callbacks(self, issuer, request_uri=False):
380380

381381
return res
382382

383+
def _get_response_type(self, context, req_args: Optional[dict] =None):
384+
if req_args:
385+
return req_args.get("response_type", context.get('behaviour')['response_types'][0])
386+
else:
387+
return context.get('behaviour')['response_types'][0]
388+
389+
def _pick_redirect_uri(self, context, response_type: str):
390+
_callbacks = context.get("callbacks")
391+
if response_type == ["code"]:
392+
return _callbacks["code"]
393+
elif response_type == ["form_post"]:
394+
return _callbacks["formpost"]
395+
else:
396+
return _callbacks["implicit"]
397+
383398
def init_authorization(self, client=None, state='', req_args=None, behaviour_args=None):
384399
"""
385400
Constructs the URL that will redirect the user to the authorization
@@ -400,10 +415,11 @@ def init_authorization(self, client=None, state='', req_args=None, behaviour_arg
400415
_context = client.client_get("service_context")
401416

402417
_nonce = rndstr(24)
418+
_response_type = self._get_response_type(_context, req_args)
403419
request_args = {
404-
'redirect_uri': _context.get('redirect_uris')[0],
420+
'redirect_uri': self._pick_redirect_uri(_context, _response_type),
405421
'scope': _context.get('behaviour')['scope'],
406-
'response_type': _context.get('behaviour')['response_types'][0],
422+
'response_type': _response_type,
407423
'nonce': _nonce
408424
}
409425

0 commit comments

Comments
 (0)