Beta

Create a tenant

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

Session age and reauthentication

A session can be busy and a token brand new while the sign-in behind them is a day old. Before a sensitive change, a relying party asks the provider for a recent sign-in with max_age, then checks auth_time itself, because the request passed through the browser on its way.

When a recent sign-in matters

All domains, identifiers and tokens in these examples are fictional.

At 15:00 UTC on 2 October, Ava decides her next poster order should go to her office instead of her home, and she opens the collage app's delivery address page. She has been signed in to the collage app since its silent check at 08:00, coming back to her collages every hour or so, often enough that its two-hour idle timeout never ran out. To the collage app, nothing about this visit looks unusual.

The delivery address decides where a parcel of Ava's photos goes. Someone who sat down at her unlocked computer, or who had copied her collage app session cookie, could send the order to themselves in a few clicks. Deleting her collage app account is similar, and it can't be undone. For actions like these, the collage app wants more than a valid session. It wants evidence that the person who can sign in to Ava's photo account did so recently, which Authentication policy and SSO called fresh authentication.

Ava's busy morning doesn't count as that evidence. Each time she opened a collage, the collage app moved its idle deadline forward without asking her for anything. The silent check at 08:00 produced a new ID token, but the photo service issued it from the session it already had. Staying active keeps a session alive, and a new token can describe an old sign-in. Neither one is a new authentication.

So the collage app sets a rule of its own: changing the delivery address needs a sign-in from the last five minutes. To apply it, it keeps the issuer, subject and authentication time from the validated ID token in Ava's session record. The rule sits beside the collage app's ordinary permission check rather than replacing it. A fresh sign-in shows that Ava is present; it doesn't let her account change an order that belongs to someone else.

Her session record shows how far away that is:

Ava's collage app session at 15:00 on 2 October
Session fieldValue
Account8812
Signed in withhttps://auth.photos.example, subject user-2048
Session created08:00:00 UTC on 2 October
auth_time1790845185, which is 08:59:45 UTC on 1 October

The session is seven hours old, but the sign-in behind it is more than thirty hours old. The silent check this morning created a new collage app session without a new authentication, and the collage app recorded the original auth_time, as it should. Nothing since then has moved that time forward, and nothing the collage app does on its own, such as refreshing its access to Ava's photos, ever could.

Requesting a fresh sign-in

The collage app keeps Ava's new office address on its server as a pending change, and starts a new sign-in attempt for it, with a fresh state, nonce and PKCE verifier, an expiry, and a note of the five-minute rule the result must meet. Then it sends her browser to the photo service with one parameter this course hasn't used yet, max_age=300:

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-signin-6
  &nonce=demo-nonce-6
  &code_challenge=zIg1QZV-I3GegEGQK73TUZpKR-4vRsAH1XMK4FTxM7Q
  &code_challenge_method=S256
  &max_age=300
  &id_token_hint=eyJhbGciOiJSUzI1NiIsImtpZCI6InBob3Rvcy1ycy0yMDI2LTA5IiwidHlwIjoiSldUIn0...

The ID token hint, Ava's earlier ID token from Login hints, is shortened here. It asks the photo service to answer only for the account this session belongs to. The scope is only openid, because the collage app needs a sign-in, not another copy of Ava's profile.

max_age is the oldest sign-in the collage app will accept, in seconds. If the photo service authenticated Ava within the last five minutes, it may answer without showing a page. Otherwise it asks her to authenticate again. Either way, a request with max_age requires auth_time in the returned ID token, so the collage app can see what actually happened.

The photo service sees that Ava's last sign-in was thirty hours ago and asks for her password. She enters it at 15:00:20, and the collage app receives a new ID token:

{
  "iss": "https://auth.photos.example",
  "sub": "user-2048",
  "aud": "photo-collage",
  "iat": 1790953225,
  "exp": 1790953525,
  "auth_time": 1790953220,
  "nonce": "demo-nonce-6"
}

Had Ava signed in to the photo service two minutes earlier for some other reason, the same request would have come back without a page, and auth_time would show those two minutes. That is what a maximum age offers over a demand for a new sign-in: it asks for exactly the freshness the collage app needs and no more.

The other way to ask is prompt=login, from Prompt and account selection, which asks the photo service to authenticate Ava again however recent her session is. The specification treats max_age=0 as equivalent. The difference lies in what comes back. Any request with max_age, including max_age=0, must receive auth_time. A request with only prompt=login isn't guaranteed to, and without it the collage app can't tell whether a new sign-in took place.

A client can also make sure auth_time arrives without asking for a new sign-in, by requesting it as an essential claim or by registering with require_auth_time so that every ID token carries it. Its registration can set default_max_age too, which applies whenever a request leaves max_age out, and which a request's own value overrides. None of these settings replaces the collage app's check of what comes back.

Checking auth_time

Asking isn't enough, because the request passed through Ava's browser. Somebody using it could remove max_age before the request reached the photo service and receive a perfectly valid token describing yesterday's sign-in. So when the response comes back, the collage app matches it to the pending attempt, uses that attempt only once, exchanges the code with the stored verifier, and validates the ID token as usual, including the nonce demo-nonce-6. Then it adds checks of its own:

claims = validate_id_token(response, pending)     # signature, issuer, audience, times, nonce
if (claims.iss, claims.sub) != (session.iss, session.sub):
    reject()                                      # someone else signed in
if claims.auth_time is None:
    reject()                                      # max_age was sent, so it must be present
if now() - claims.auth_time > pending.max_age + CLOCK_TOLERANCE:
    reject()                                      # not recent enough
if claims.auth_time > now() + CLOCK_TOLERANCE:
    reject()                                      # implausibly in the future
if not current_permission(session.user, pending.change):
    reject()                                      # fresh authentication cannot grant permission
session.auth_time = claims.auth_time
apply(pending.change)

A missing auth_time is a failure, not a pass, because the photo service was required to include it. The age check allows a small tolerance for differences between the two servers' clocks, measured in seconds, never enough to turn five minutes into an hour. Notice which claim it reads: iat only says when the token was issued, which is always moments ago, so it can't tell a new sign-in from an old one.

Ava entered her password

sub
user-2048
iat
15:00:25
auth_time
15:00:20
Signed in
5 seconds ago

Apply the change

Yesterday's sign-in reused

sub
user-2048
iat
15:00:25
auth_time
08:59:45, 1 October
Signed in
More than 30 hours ago

The address stays as it was

A different account signed in

sub
Another subject
iat
15:00:25
auth_time
15:00:18
Signed in
7 seconds ago

Discard the pending change

iat only says when the token was issued.

Three ID tokens the collage app could receive at 15:00:25, all issued seconds ago. Only auth_time and sub decide whether the address change goes ahead.

At 15:00:25 the new token's auth_time is five seconds old, well inside the limit. When every check passes, the collage app records the new auth_time in Ava's session and applies the pending change, once. The checks live in the server code that changes the address, not in the page that shows the form, so a request sent straight to that code meets the same rule.

Any failed check leaves the address as it was. If someone else signed in at the photo service, their sign-in says nothing about Ava, however valid it is. The collage app discards the pending change, and it may end her session too, since it can no longer be sure who is at the keyboard. If Ava cancels at the photo service, or can't sign in, the collage app receives an error instead of a code. Her session continues, and the collage app can explain that the change needs a recent sign-in and offer to try again.

Check your understanding

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

At 15:00 the collage app sends max_age=300 before changing Ava's delivery address. The returned ID token validates, but its auth_time is 08:59:45 the previous day. What should the collage app do? 1 of 3

Choose one answer.

Why does the collage app use max_age=300 rather than prompt=login before changing the delivery address? 2 of 3

Choose one answer.

Ava has used the collage app every hour since 08:00 without signing in again, and its silent check issued her a new ID token this morning. Does that count as a recent sign-in for the address change? 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