Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Requesting stronger authentication

Some actions need a stronger or more recent sign-in than the session already holds. This lesson follows the collage app as it sends Ava back to the photo service for a passkey before a sensitive download, checks what comes back against its own rule, and handles a provider that cannot comply.

A download that needs more

Ava and two friends are building a poster in the collage app from photos of their autumn trip. The board for it holds the full-resolution originals, straight from the photo service, and anyone who downloads them gets every photo at full size. At 10:15 UTC on 3 October, Ava opens the board and selects Download originals. She has been signed in since 08:30, when she used her password and an authenticator app code at the photo service. All domains, identifiers and tokens in these examples are fictional.

Before the collage app looks at how Ava signed in, it checks whether she may have the originals at all. She is a member of the autumn board, and members may download. Had she not been, the collage app would refuse the download there and then. Sending someone off for a stronger sign-in can't add them to a board.

With permission settled, the collage app turns to the sign-in behind the session. Its rule for downloading originals has two parts. The sign-in must meet the photo service's class urn:photos:acr:passkey, which the photo service defines as a passkey or security key unlocked with a PIN or fingerprint, and it must be no more than fifteen minutes old. A password and an app code can both be typed into a convincing fake page and relayed to the real one, while a passkey's response is tied to the site that asked for it, as What makes authentication multi-factor explained. The classes and the acr claim that reports them come from Authentication context and methods. Ava's session falls short on both parts:

Ava's session against the rule for originals
Session fieldRecordedRequired for originals
acrurn:photos:acr:two-factorurn:photos:acr:passkey
auth_time1791016200, which is 08:30:00 UTCNo more than 900 seconds old

This is step-up authentication: asking for stronger or fresher authentication at the moment an action needs it, rather than demanding the strongest sign-in for everything. Authentication policy and SSO introduced the idea. Here the collage app makes the decision, because the download happens in the collage app, and the photo service performs the stronger sign-in.

So the collage app sets the download aside rather than refusing it. It saves the pending download on its server, with the board, the photos and the rule they need, and starts a new sign-in attempt with its own state, nonce, PKCE verifier and expiry, as it would for any sign-in. Keeping the download on the server matters later. When Ava comes back, the collage app resumes the download it saved, instead of following a destination carried in the response, which anyone could have edited on the way.

Sending the person back

The request the collage app builds carries both parts of the rule:

https://auth.photos.example/authorize
  ?response_type=code
  &client_id=photo-collage
  &redirect_uri=https%3A%2F%2Fcollage.example%2Fsignin%2Fcallback
  &scope=openid
  &state=demo-collage-2
  &nonce=demo-collage-nonce-2
  &code_challenge=T0sO5nn95rTe6T6C4-oxfW6yhwJ-cQcpMGwYz4x9IWI
  &code_challenge_method=S256
  &max_age=900
  &claims=%7B%22id_token%22%3A%7B%22acr%22%3A%7B%22essential%22%3Atrue%2C%22values%22%3A%5B%22urn%3Aphotos%3Aacr%3Apasskey%22%5D%7D%7D%7D
  &id_token_hint=eyJhbGciOiJSUzI1NiIsImtpZCI6InBob3Rvcy0yMDI2IiwidHlwIjoiSldUIn0...

Each part has one job. The claims parameter asks for an essential acr claim with the accepted class, which names the required context. max_age=900 asks for a sign-in no more than fifteen minutes old, as in Session age and reauthentication. The earlier validated ID token goes in id_token_hint, which tells the photo service whose sign-in this must be, as in Login hints.

How to meet the request is up to the photo service. Had Ava signed in five minutes ago, it could have asked only for what was missing, the passkey. The 08:30 sign-in is far older than fifteen minutes, so it needs a fresh authentication, and Ava's passkey unlocked with her fingerprint supplies one that meets the class as well. Whatever the photo service asks for, the collage app gets one of two answers back: a code for a sign-in that meets the requirement, or an error saying it could not be met. Ava uses her passkey, and this ID token comes back:

{
  "iss": "https://auth.photos.example",
  "sub": "user-2048",
  "aud": "photo-collage",
  "iat": 1791022520,
  "exp": 1791022820,
  "auth_time": 1791022515,
  "nonce": "demo-collage-nonce-2",
  "acr": "urn:photos:acr:passkey",
  "amr": ["pop", "mfa"]
}

Before it reads any of that, the collage app checks the callback like any other: the state must belong to the pending step-up, and the issuer must be the photo service. It exchanges the code with the stored verifier and validates the ID token completely, nonce included. Only then does it compare the token with the download's rule:

  1. The issuer and subject match the session. A passkey belonging to someone else must not unlock Ava's download.
  2. The acr is on the download's list, which holds only urn:photos:acr:passkey.
  3. auth_time is present, no more than 900 seconds old, and not in the future, allowing only a small clock tolerance either way.

None of these checks merely repeats the request. The request crossed the browser, where someone could have removed the claims parameter or max_age and still received a valid token for a weaker or older sign-in. Asking for an essential claim is not the same as receiving one. The amr list goes into Ava's sign-in history, but the decision rests on the agreed class and on her current permission.

The collage app decides that the download needs more, the photo service performs the stronger sign-in, and the collage app checks the result against its own rule before releasing the originals.

All three checks pass. The collage app records the new acr, auth_time and amr in the session and gives the browser a new session identifier, because the session now carries more authority than before. Staying signed in explained the same step at sign-in. Then it resumes the pending download, checking Ava's membership of the board once more. If a friend had removed her from the board in the minute it took to find her phone, a successful step-up would not bring that access back.

A second download at 10:25 needs no new trip: the session's class is on the list, and the sign-in is ten minutes old. After 10:30:15 the fifteen minutes are up, and the next download sends Ava back again. Ordinary pages carry on throughout, because they accept either class and set no age limit.

When the provider cannot comply

Suppose Ava had never added a passkey, and has no other phishing-resistant method enrolled. The photo service can't meet an essential acr request, so it treats the attempt as a failed authentication and redirects back with an error:

https://collage.example/signin/callback
  ?error=unmet_authentication_requirements
  &state=demo-collage-2
  &iss=https%3A%2F%2Fauth.photos.example

unmet_authentication_requirements comes from a short companion specification to OpenID Connect. A provider uses it when it cannot authenticate the person in the way the relying party required, and it is the expected answer when an essential acr request can't be met. Not every provider supports it. Some report the same situation with a more general error, and a provider that doesn't honor essential claims may return a sign-in at a weaker class, which the collage app's own check then rejects. If Ava simply cancels at the passkey prompt, the answer is typically access_denied.

The collage app handles the error with the same care as a success:

  • It validates the response as it would a success, matching state to the pending step-up and checking the issuer. There is no code, so there is nothing to exchange.
  • It discards the pending download and leaves the originals where they are.
  • It keeps Ava's existing session. The 08:30 sign-in still meets the rules for ordinary pages, and a missing passkey says nothing against it.
  • It explains what the download needs: "Downloading originals needs a passkey or security key. Add one in your photo account's security settings, then try again."
  • It records the outcome: the action, the requirement, the error code, and a correlation ID for the attempt, without tokens or the request URL.

One tempting fix is to try again at once with acr_values instead. That only turns the requirement into a preference. The photo service may then complete the sign-in at the two-factor class, and the token that comes back will be valid in every other respect. The collage app's check must still refuse it for originals, so the retry gains nothing except a second trip for Ava.

A sign-in by someone else is handled at two points. Because the request carried Ava's ID token as a hint, a careful provider refuses to return anyone else's sign-in for it, and answers with an error such as login_required. If a provider ignored the hint, or the hint was stripped from the request, an ID token for another subject would come back, and the first of the collage app's checks would refuse it. Either way the collage app discards the pending download. When a token for someone else does arrive, it also ends the session: someone else's passkey was used in Ava's session, and the collage app can no longer be sure who is at the keyboard.

Here the collage app decided that the download needed more, because the download happens in the collage app. The Step-up authentication challenges lessons in Advanced OAuth, starting with When an API needs stronger authentication, follow the other case, where an API makes that decision: the requirement reaches the client in the API's error response and travels on to the authorization server in the same acr_values and max_age parameters. Wherever the requirement starts, the provider performs the stronger sign-in, and the party that set the requirement checks acr and auth_time in what comes back.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

After a step-up, the collage app receives a valid ID token with the passkey acr and a fresh auth_time, but its sub is someone other than Ava, whose session asked. What should the collage app do? 1 of 3

Choose one answer.

The photo service answers the collage app's step-up request with error=unmet_authentication_requirements. What should the collage app do? 2 of 3

Choose one answer.

Ava completes the passkey step-up, but a friend removed her from the board a moment before the collage app resumes the download. What should happen? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity