Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement response_mode #469

Merged
merged 6 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ def initiate_auth_code_flow(
domain_hint=None, # type: Optional[str]
claims_challenge=None,
max_age=None,
response_mode=None, # type: Optional[str]
):
"""Initiate an auth code flow.

Expand Down Expand Up @@ -677,6 +678,20 @@ def initiate_auth_code_flow(

New in version 1.15.

:param str response_mode:
OPTIONAL. Specifies the method with which response parameters should be returned.
The default value is equivalent to ``query``, which is still secure enough in MSAL Python
(because MSAL Python does not transfer tokens via query parameter in the first place).
For even better security, we recommend using the value ``form_post``.
In "form_post" mode, response parameters
will be encoded as HTML form values that are transmitted via the HTTP POST method and
encoded in the body using the application/x-www-form-urlencoded format.
Valid values can be either "form_post" for HTTP POST to callback URI or
"query" (the default) for HTTP GET with parameters encoded in query string.
More information on possible values
`here <https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes>`
and `here <https://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html#FormPostResponseMode>`

:return:
The auth code flow. It is a dict in this form::

Expand Down Expand Up @@ -707,6 +722,7 @@ def initiate_auth_code_flow(
claims=_merge_claims_challenge_and_capabilities(
self._client_capabilities, claims_challenge),
max_age=max_age,
response_mode=response_mode,
)
flow["claims_challenge"] = claims_challenge
return flow
Expand Down
1 change: 1 addition & 0 deletions msal/oauth2cli/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def initiate_auth_code_flow(
# Here we just automatically add it. If the caller do not want id_token,
# they should simply go with oauth2.Client.
_scope.append("openid")

eopeter marked this conversation as resolved.
Show resolved Hide resolved
nonce = "".join(random.sample(string.ascii_letters, 16))
flow = super(Client, self).initiate_auth_code_flow(
scope=_scope, nonce=_nonce_hash(nonce), **kwargs)
Expand Down