Skip to content
Workforce IdentityMarkdown

Ask users to sign in again

Require a recent sign-in, or a fresh one, before an action, and make sure the right user is the one signing in.

APIOpenID Connect Core 1.0, RFC 9470

Some actions need proof the user is still at the keyboard, such as showing a recovery code or changing a password. The app asks for it in its sign-in request, with three parameters it can combine. The user signs in again through the chain they used before, and their session continues: the same session, freshly proved.

ParameterWhat it asks forWhat the user sees
max_age=300A sign-in no older than 300 secondsAsked to sign in again only if their sign-in is older than that
prompt=loginA fresh sign-in, whatever its ageAlways asked to sign in again
id_token_hint=<ID token>That the user signing in is this oneNothing extra; anyone else signing in is refused

Before you start:

  • Who can do it: the app’s developer. There’s nothing for a realm administrator to set.
  • Where: in the app’s own sign-in request.
  • First: register the app for the browser sign-in, as in Sign users in to a web app.
  1. Before the action, the app sends a sign-in request with max_age, prompt=login, or both, and the current user’s ID token as id_token_hint.

  2. The user signs in again if they need to, and the app receives a code as usual.

  3. The app checks the new ID token’s auth_time: it is the time of the fresh sign-in.

  • A fresh sign-in counts only if it happened after the request. Going back to an old page with an old session doesn’t count.
  • A session belonging to someone other than the hint’s user is answered login_required.
  • A hint the realm didn’t sign for this app is refused as invalid_request, never ignored. An expired hint is still accepted, because it only names a user.
  • With prompt=none, none of this can happen: the app is told login_required.
  • At an API behind the gateway, a policy can require a sign-in no older than a set age. The gateway then answers 401 with error="insufficient_user_authentication" and the max_age it needs.

Send prompt=login as a signed-in test user: you’re asked to sign in again, and the new ID token’s auth_time is the moment you did. The user’s trail holds a LOGIN record for the fresh sign-in, and a SESSION_UPGRADED record when it continued their session. Find them in Audit → Authentication in the dashboard.

SymptomCauseFix
The user isn’t asked to sign in againmax_age is longer than the time since their sign-inUse a shorter max_age, or prompt=login
login_requiredThe request also carried prompt=none, or the hint names another userDrop prompt=none; send the current user’s ID token
invalid_requestThe hint wasn’t signed by the realm for this appSend the app’s own ID token, unchanged
auth_time didn’t changeThe app read the old ID tokenRead the ID token from this sign-in’s code

Stop sending max_age and prompt=login. Nothing changes in the realm.