Skip to content

Commit 4397477

Browse files
eopeterEmmanuel Ocherayluo
authored
implement response_mode (#469)
* implement response_mode oidc supports passing the response_mode to allow redirects to send callback parameters as POST for increased security. * Fix error check logic and modify test_ccs to include response_mode * Add more comments * Apply suggestions from code review Co-authored-by: Ray Luo <[email protected]> * PR review comments addressed * remove extraneous line Co-authored-by: Emmanuel Oche <[email protected]> Co-authored-by: Ray Luo <[email protected]>
1 parent 14965f7 commit 4397477

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

msal/application.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ def initiate_auth_code_flow(
636636
domain_hint=None, # type: Optional[str]
637637
claims_challenge=None,
638638
max_age=None,
639+
response_mode=None, # type: Optional[str]
639640
):
640641
"""Initiate an auth code flow.
641642
@@ -677,6 +678,20 @@ def initiate_auth_code_flow(
677678
678679
New in version 1.15.
679680
681+
:param str response_mode:
682+
OPTIONAL. Specifies the method with which response parameters should be returned.
683+
The default value is equivalent to ``query``, which is still secure enough in MSAL Python
684+
(because MSAL Python does not transfer tokens via query parameter in the first place).
685+
For even better security, we recommend using the value ``form_post``.
686+
In "form_post" mode, response parameters
687+
will be encoded as HTML form values that are transmitted via the HTTP POST method and
688+
encoded in the body using the application/x-www-form-urlencoded format.
689+
Valid values can be either "form_post" for HTTP POST to callback URI or
690+
"query" (the default) for HTTP GET with parameters encoded in query string.
691+
More information on possible values
692+
`here <https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes>`
693+
and `here <https://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html#FormPostResponseMode>`
694+
680695
:return:
681696
The auth code flow. It is a dict in this form::
682697
@@ -707,6 +722,7 @@ def initiate_auth_code_flow(
707722
claims=_merge_claims_challenge_and_capabilities(
708723
self._client_capabilities, claims_challenge),
709724
max_age=max_age,
725+
response_mode=response_mode,
710726
)
711727
flow["claims_challenge"] = claims_challenge
712728
return flow

0 commit comments

Comments
 (0)