Beta

Create a tenant

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

Designing session and token lifetimes

One sign-in leaves several things behind, and each of them has its own lifetime: the application's session, the provider's session, an access token and a refresh token. This lesson follows Ava through a day with the printer to show how those lifetimes interact, what each one actually limits, and how the photo service chooses values for them on purpose.

Four clocks in one sign-in

At 09:00 Ava signs in to the printer with her photo service account, starts a photo book and leaves the tab open. At 09:10 the printer quietly gets a new access token. After lunch she comes back and the printer asks the photo service who she is, but she sees no sign-in page. At half past five it asks again, and this time she types her password. Nothing went wrong at any point. Ava met four separate clocks, each set by a different decision, and each ran out at a different time. All domains, accounts and tokens in these examples are fictional.

The first is the printer's own application session, the cookie that Establishing an application session described, which tells the printer's server that this browser belongs to Ava's account, user-2048. The second is the photo service's provider session, its own cookie on auth.photos.example, which lets it answer an authorization request without asking for her password. The third is the access token the printer sends to the photo API. The fourth is the refresh token the printer's server uses to get new access tokens without involving Ava's browser at all.

The four clocks in Ava's sign-in to the printer
ClockHeld byLets someoneWhen it runs out
Application sessionAva's browser, as a printer cookieUse the printer's pages as AvaThe printer sends her to the photo service
Provider sessionAva's browser, as a photo service cookieSign in to any connected application without a passwordThe photo service asks her to sign in
Access tokenThe printer's serverCall the photo APIThe printer refreshes it
Refresh tokenThe printer's serverGet new access tokens with nobody presentThe printer needs Ava to sign in again

Each product ships with defaults for its own clock, and nothing makes those defaults agree with each other. Lifetime design is the job of setting all four on purpose, knowing how they interact.

Idle and absolute timeouts

Staying signed in introduced the two limits a session can have. An idle timeout ends it after a stretch with no activity, and each use starts that stretch again. An absolute timeout ends it a fixed time after it began, however busy it is. The printer gives its application session an hour idle and twelve hours absolute, so Ava's lunch break ended it, while a day of steady work would have run into the twelve hours instead.

The two protect against different things. The idle timeout covers the laptop left open in a coffee shop: nobody is using the session, so it ends soon. The absolute timeout covers a session somebody is using, perhaps not Ava, by putting a ceiling on how long anything that started with one sign-in can last. A session with only an idle timeout can run forever if something keeps touching it, and that something can be a stolen copy of the cookie.

Refresh tokens have the same pair under other names. Refresh tokens and rotation called them the idle lifetime, which slides forward with each refresh, and the absolute lifetime of the token family, counted from the approval that started it. Rotation replaces the token at each use, which keeps moving the idle deadline but never the absolute one. Access tokens usually have only an expiry, the exp claim, because they are short enough that an idle limit would add nothing.

How the layers depend on each other

The clocks are independent in the sense that matters most: when one runs out, the others keep running. Ava's day showed each case.

Four lifetimes in one day. Each expiry sends the printer back one layer, and only the provider session's end reaches the person.

At 09:10 only the access token ran out, and the printer refreshed it from its server. At 13:05 the application session had gone idle, so the printer sent Ava's browser to the photo service, whose session was still alive, and she was back a moment later without seeing a page. At 17:30 the photo service's eight-hour session had passed its absolute limit, so the photo service asked for her password. The printer could only send her there. The decision to ask was the photo service's.

That dependence runs in one direction. A short application session leans on the provider session to bring people back quietly, so a printer with a ten-minute session and a photo service with an eight-hour session gives Ava eight hours of quiet returns, not ten minutes of security. If the printer wants a real password prompt after ten minutes, it has to ask for one, with the max_age parameter that the step-up section below returns to.

The reverse also holds: ending the provider session does not end the printer's session, or its refresh token. When Ava signs out at the photo service, the printer learns about it only if it listens for the logout token that Back-channel logout described, and the refresh token stops working only if the photo service revokes it too. The NIST digital identity guidelines, SP 800-63B-4, describe federation the same way: the provider's session and the application's session are managed separately, and the application decides whether its own reauthentication rules are met.

So the useful question is never just how long a session lasts, but which clock actually bounds each kind of access. For the printer's background work the answer is the refresh token's absolute lifetime, not anything Ava's browser holds.

The revocation gap

Suppose the photo service locks Ava's account at 11:00 because she reports that someone else has been using it. The provider session ends at once, and the refresh token is revoked, so the printer's next refresh fails with invalid_grant and no new access tokens are issued. The access token the printer received at 10:55 is another matter. The photo API validates JWT access tokens locally, checking the signature and expiry as Token formats and validation described, so it never asks the photo service about the account. It has no way to know about the lock, and it accepts that token until it expires at 11:05.

11:0011:00: the photo service locks Ava's account

Cookie on auth.photos.example

Ends at once

Held by the printer's server

Revoked

Next refresh fails with invalid_grant

Issued at 10:55

Signature
Valid
exp
11:05

Accepted by the photo API until 11:05

The revocation gap: five minutes in which the lock has not reached the photo API.

At 11:00 the lock reaches every clock the photo service holds. The access token issued at 10:55 still works at the photo API until 11:05.

The time between a decision to cut access and the moment access actually stops is the revocation gap. For a locally validated token it is the token's remaining lifetime. For a token the API checks with introspection, asking the photo service each time whether the token is still active, it is however long the API caches that answer. For an application session the gap is the session's own lifetime, unless a logout signal reaches the application sooner.

The gap is what an access token's lifetime really buys, so it is worth deciding per operation rather than per product. A useful way to do that is to sort operations into risk tiers:

Revocation gaps by risk tier at the photo service
TierExample operationsAcceptable gapHow the API gets there
LowViewing albums, listing print sizesUp to an hourLocal validation of tokens that last up to an hour
MediumOrdering prints, changing a delivery addressAbout ten minutesLocal validation of ten-minute tokens
HighSharing an album publicly, changing payout details, administrationSecondsIntrospection with little or no caching, or a fresh sign-in for the action

Shortening every access token to a minute would close the gap everywhere, at the cost of a refresh request every minute from every client. Tiers let the cheap path serve the operations where a few minutes do not matter, and spend the expensive checks where they do.

Step-up windows

A session that is still valid says that someone signed in, perhaps hours ago. Some actions need to know that Ava, specifically, proved herself recently. When she changes the printer's delivery address, the printer asks the photo service for a sign-in no more than five minutes old with max_age=300, then checks the auth_time claim in the ID token that comes back, the exchange Session age and reauthentication walked through. Asking for fresh proof before one sensitive action is often called step-up, and those five minutes are a step-up window: a lifetime for one kind of evidence, separate from every clock above.

Windows should be short and attached to the action, not to the session. Five minutes for a change of address, or zero for releasing a payment, makes sense. Extending the whole session because Ava stepped up once does not, because it turns a check for one action into a stronger session for everything that follows. A window can also ask for a particular method, as Requesting stronger authentication showed, so that a recent password does not satisfy an action that needs a recent passkey.

The assurance levels in Authenticator assurance levels put outer limits on these choices. At AAL2, SP 800-63B-4 says the overall reauthentication limit should be no more than 24 hours and the inactivity limit no more than an hour. At AAL3 the overall limit is at most 12 hours and inactivity should be no more than 15 minutes. At AAL1 the overall limit should be no more than 30 days. These are ceilings for the session that carries that level, not targets.

Binding the session to the device

Every limit so far assumes the session cookie is a bearer credential: whoever holds it is treated as Ava. That is why lifetimes matter so much. Malware that copies cookies out of a browser gets a session that lasts as long as its absolute limit, from any computer.

The alternative is to tie the session to a key that never leaves Ava's device, so that a copy of the cookie alone is not enough. Device Bound Session Credentials, or DBSC, does this for browser sessions. When a session starts, the browser creates a key pair, keeping the private key in secure hardware where the device has it, and registers the public key with the site. The site then issues cookies that last only a few minutes and renews them only when the browser signs a fresh challenge with that private key. A copied cookie stops working within minutes, because the key needed to renew it cannot be copied out. DBSC is being standardized at the World Wide Web Consortium (W3C), the body that also publishes WebAuthn, and in 2026 it is generally available only in Chrome on Windows. A site must also implement registration and renewal on its own servers.

Binding changes how lifetimes are chosen rather than removing the need for them. A bound session can afford a longer absolute limit, because its short-lived cookies limit what a copy is worth. An unbound session in the same application, in a browser without DBSC, still needs the stricter values, so a site that adopts DBSC usually runs two sets of numbers side by side. Limiting what stolen access can do, in Identity security, sets binding beside the other ways of shrinking what a stolen credential is worth.

Choosing values

The photo service set lifetimes for three of its applications in one sitting, working through the same questions for each: who uses it and how often, what the worst action in it is, what revocation gap that action tolerates, and how often people will accept being asked to sign in.

Lifetimes the photo service chose for three applications
ClockPhone app for customersPrinter integrationStaff administration console
Application sessionKept by the app while the refresh token lasts1 hour idle, 12 hours absolute (the printer's choice)15 minutes idle, 8 hours absolute
Provider session30 days, renewed by use on the phone8 hours absolute8 hours absolute, phishing-resistant sign-in
Access token15 minutes10 minutes5 minutes, checked by introspection
Refresh tokenRotated; 30 days idle, 180 days absoluteRotated; 30 days idle, 90 days absoluteNone: staff sign in again
Step-up window5 minutes for a new delivery address5 minutes for a new delivery addressFresh passkey sign-in for role changes

Each column follows from its answers. Customers open the phone app a few times a month and would abandon it if asked for a password each time, and the worst thing a stolen copy can do there is limited and visible to them, so the refresh token carries the long relationship and the access token stays short. The administration console can change other people's access, its users expect checks, and a stolen session there would cost far more, so it has no refresh token at all and checks every token with the photo service.

Two rules kept the table honest. Every value in a column had to be consistent with the others, which is why the console's 15-minute idle session is not undone by a long refresh token. And every number had to be one the photo service could explain to the person affected by it. A lifetime chosen because the product defaulted to it, or because a stricter number felt safer, tends to be the one people quietly work around.

Check your understanding

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

The printer ends its own session after 10 idle minutes, but the photo service keeps its sessions for 8 hours. Ava steps away for 20 minutes and comes back. What happens? 1 of 3

Choose one answer.

Ava signs out at the photo service. The printer does not listen for back-channel logout, and the photo service does not revoke the printer's refresh token. What happens to the printer's background work? 2 of 3

Choose one answer.

The photo API validates JWT access tokens locally, and they last 10 minutes. The photo service locks Ava's account at 11:00. How long can a token issued at 10:58 still be used at the API? 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