OAuth migration | Force user to sign in if Access token auth_time
older than 30 minutes
#1300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Context
After deploying #1294 and enabling Okta on PROD manage-frontend, we discovered an Okta behaviour which was undocumented in the sense that it was only documented in a modal in the UI, three layers down, after you clicked a specific radio button, and the actual documentation completely contradicted it:
One is reminded of a quote from The Hitchhiker's Guide To The Galaxy:
What this means in practice is that, when passing the
max_age
parameter when requesting OAuth tokens:max_age
FEDERATION
orSOCIAL
types (i.e. social login users who have never set a password) will never be forced to sign in again as long as their global Okta session is not expired. This is probably most of our social users.This behaviour means that we can't reliably enforce the MMA behaviour where a user must reauthenticate if they last authenticated more than 30 minutes ago using Okta settings alone.
For this reason, this PR adds the following check into
identityMiddleware
:auth_time
claim longer than 30 minutes in the past?/reauthenticate
route. This route always shows a signin form, irrespective of any session set in the browser. This essentially replicates the previous, IDAPI behaviour in MMA.signedInNotRecently
but allowed to proceed to the route. This again replicates the old IDAPI behaviour.The
auth_time
claimAccording to the OpenID spec, and confirmed by Okta, the
auth_time
claim is "Time when the End-User authentication occurred" in UNIX seconds, which in Okta land means the last time the user actively authenticated, i.e. created their Okta session. The OpenID spec states thatauth_time
is returned whenever themax_age
parameter is sent in the OAuth request, which in MMA is always. The Okta docs state thatauth_time
is a 'base claim', always returned. We've added logging in the check forauth_time
which will give us data on missingauth_time
claims, if any.Further reading for nerds here:
Other changes
auth_time
behaviour, which sets the Oktamax_age
to a very short value and attempts to refresh the page, expecting to be redirected.async
, the top-level middleware does this once and passes it down the chain. This also required a lot of refactoring in tests.identityMiddleware
error states to a new frontend error page,/sign-in-error
, which shows a more helpful message and a link to sign out, which is likely to resolve edge-case sign in issues:Testing