Skip to content

Commit dac99e0

Browse files
committed
WIP: Relax exp check with reasonable skew. And add auth_time check. Previous commit incorrectly always enables max_age
1 parent 9f78b6b commit dac99e0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

msal/application.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ def initiate_auth_code_flow(
558558
login_hint=None, # type: Optional[str]
559559
domain_hint=None, # type: Optional[str]
560560
claims_challenge=None,
561+
max_age=None,
561562
):
562563
"""Initiate an auth code flow.
563564
@@ -588,6 +589,17 @@ def initiate_auth_code_flow(
588589
`here <https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code>`_ and
589590
`here <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oapx/86fb452d-e34a-494e-ac61-e526e263b6d8>`_.
590591
592+
:param int max_age:
593+
OPTIONAL. Maximum Authentication Age.
594+
Specifies the allowable elapsed time in seconds
595+
since the last time the End-User was actively authenticated.
596+
If the elapsed time is greater than this value,
597+
Microsoft identity platform will actively re-authenticate the End-User.
598+
599+
MSAL Python will also automatically validate the auth_time in ID token.
600+
601+
New in version 1.15.
602+
591603
:return:
592604
The auth code flow. It is a dict in this form::
593605
@@ -617,6 +629,7 @@ def initiate_auth_code_flow(
617629
domain_hint=domain_hint,
618630
claims=_merge_claims_challenge_and_capabilities(
619631
self._client_capabilities, claims_challenge),
632+
max_age=max_age,
620633
)
621634
flow["claims_challenge"] = claims_challenge
622635
return flow
@@ -1403,6 +1416,7 @@ def acquire_token_interactive(
14031416
timeout=None,
14041417
port=None,
14051418
extra_scopes_to_consent=None,
1419+
max_age=None,
14061420
**kwargs):
14071421
"""Acquire token interactively i.e. via a local browser.
14081422
@@ -1448,6 +1462,17 @@ def acquire_token_interactive(
14481462
in the same interaction, but for which you won't get back a
14491463
token for in this particular operation.
14501464
1465+
:param int max_age:
1466+
OPTIONAL. Maximum Authentication Age.
1467+
Specifies the allowable elapsed time in seconds
1468+
since the last time the End-User was actively authenticated.
1469+
If the elapsed time is greater than this value,
1470+
Microsoft identity platform will actively re-authenticate the End-User.
1471+
1472+
MSAL Python will also automatically validate the auth_time in ID token.
1473+
1474+
New in version 1.15.
1475+
14511476
:return:
14521477
- A dict containing no "error" key,
14531478
and typically contains an "access_token" key.
@@ -1466,6 +1491,7 @@ def acquire_token_interactive(
14661491
port=port or 0),
14671492
prompt=prompt,
14681493
login_hint=login_hint,
1494+
max_age=max_age,
14691495
timeout=timeout,
14701496
auth_params={
14711497
"claims": claims,

0 commit comments

Comments
 (0)