Skip to content

Authentication timeout in a flow that uses max_age parameter has a 'send another authorisation code' button that doesn't allow login #455

@ineesalmeida

Description

@ineesalmeida

Describe the bug
The optional max_age parameter in the ConfidentialClientApplication. initiate_auth_code_flow is compared against the time the user entered their password instead of the full authentication with the MFA, which leads to odd behaviours for authentication timeout. A user that takes to long to enter the MFA sees a 'this has timed-out, send another authorization code' but entering the MFA again will not work because the time will be past the max_age, so an error will be raised instead.

To Reproduce
Steps to reproduce the behavior:

  1. Initiate a auth code flow with the max_age parameter set to 60 seconds (for example)
  2. I enter my password, but don't enter my MFA devices for a couple of minutes
  3. I see that too much time has passed and a button saying 'send another authorisation code'
  4. I press on that 'send another authorization code' button

Expected behavior
I would expect one of two behaviors:

  • I re-enter my MFA code and I can login
  • I am asked to re-enter my password and MFA and I can login

What you see instead
I re-enter my MFA code and a python error is raised:
RuntimeError( RuntimeError: 13. auth_time (1642085298) was requested, by using max_age (60) parameter, and now (1642085502) too much time has elasped since last end-user authentication.

The MSAL Python version you are using
1.16.0

Additional context
If a user takes too long to enter their password everything works fine since the max_age is evaluated since the password was entered. This is only an issue if the user takes to long to add their MFA code.
This flow is also fine if after I enter my password and take too long to enter my MFA code, I click on 'cancel' and then try again, and it will ask for my password + MFA again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions