T4 Token lifetime and refresh¶
Description¶
How long tokens live, whether an exchange can give a token for work that outlasts the request, and what happens at expiry. Uses the tokens of T1, in the same session, except for the expired token, which has its own.
Runs against: LS Login. On the mock, lifetimes come from mock/oidc.json, and an exchange never returns a refresh token.
From the LS Login team, 2026-11-03: the lifetime is "currently 1 hour" (A7), and refresh tokens come with offline_access and last 31 days for now (A6).
Expectations¶
- Exchanged tokens live 1 hour. A login token of Krini's lived 4 hours on 2026-10-20 (our own observation), so login tokens may differ.
- Refreshing gives a new access token for the same
sub. - If
expof the refresh token moves by the time elapsed, the limit is idle. If it stays, absolute. If introspection shows noexpand the token is opaque, only the LS Login team can tell. - Whether an exchange returns a refresh token is unknown. If it does, its access token has
aud= gateway, the call gives 200, and the last refresh is refused after revocation. - An expired token gets 401 with the reason
expired, an exchange of it is refused by LS Login, and the refresh still works. - Another client can't redeem the client's refresh token (RFC 6749, section 6). Whether a rotated refresh token can be reused, and whether that ends the whole grant, is unknown.
Steps¶
Refresh at the client¶
Rotation shows in refresh_token_rotated.
tb> show user
tb> introspect user --as client --refresh
tb> refresh r1 --as client --from user
tb> introspect r1 --as client --refresh
tb> show r1
Lifetimes¶
Compare the login, exchanged and refreshed tokens. Then exchange from the login token, which is old by now: does the new token get a full lifetime, or only what the subject token has left? If the subject has expired, the exchange should be refused. If it's refused with seconds_left above zero, the refresh may have ended the old access token, which is a result of its own.
31 days: idle or absolute?¶
We can't wait 31 days, but we can compare. At least 10 minutes after the previous step:
Refresh token from an exchange¶
The Conquest case, which decides how long-running work gets tokens. It starts from a new token, as the one from T1 may have expired, which would look like a refusal of the refresh token.
tb> exchange to-orch2 --as client --from r2 --audience @orchestrator
tb> exchange ro --as orchestrator --from to-orch2 --audience @gateway --scope "openid offline_access"
tb> exchange ro2 --as orchestrator --from to-orch2 --audience @gateway --scope "openid offline_access" --requested-type refresh
Only if that returned one¶
Use the token that holds it in place of ro. A token issued as a refresh token can only be redeemed, not called with.
tb> refresh ro-a --as orchestrator --from ro
tb> show ro-a
tb> call gateway --token ro-a
tb> refresh ro-b --as orchestrator --from ro-a --audience @gateway
tb> revoke ro-b --as orchestrator --refresh
tb> refresh ro-c --as orchestrator --from ro-b
Expired token¶
Start this at least an hour before you need the result, in a second session, as it takes as long as the tokens live:
Only one session can log in at a time, as they share the callback port. Log in with account A again, so that sub can be compared with the first login.
tb> login exp --as client
tb> exchange exp-gw --as client --from exp --audience @gateway
tb> lifetimes
tb> wait-expiry exp-gw
tb> call gateway --token exp-gw
tb> exchange exp-bad --as gateway --from exp-gw --audience @node
tb> refresh exp-new --as client --from exp
Ctrl-C ends a wait without losing the tokens.
Binding and reuse¶
In the same second session, as reuse detection may end every refresh token of a login, and later tests need those of the first. The client refreshes twice and reuses the older refresh token. Then another client tries the newest one:
tb> refresh exp-new2 --as client --from exp-new
tb> refresh exp-reuse --as client --from exp-new
tb> refresh exp-after --as client --from exp-new2
tb> refresh exp-other --as orchestrator --from exp-after
Only if exp-new2 shows refresh_token_rotated: true does the reuse mean anything. Then a refused exp-reuse shows that rotation is enforced, and a refused exp-after that reuse ended the grant. The other client is the orchestrator, as its registration has the refresh token flow, so a refusal is about the token, not about the flow. If it worked, the refresh token isn't bound to the client, which is a result of its own. If exp-after was refused, exp-other has no token to try: log in again with login exp2 --as client, then use --from exp2. See Delegated access for why this matters.
Questions it answers¶
What does "1 hour" cover, and is it capped by the subject token?¶
Does it cover only exchanged tokens?
- Sets the margin of FOCA's cache per user and audience, until shortly before expiry.
- If it's capped: an old login token shortens each hop, so clients have to refresh before exchanging. That goes into the docs for the clients of proTES #391.
Lifetimes stay configurable in FOCA either way, as the new stack will change them (C10).
Can an exchange return a refresh token, limited to the next hop?¶
- Yes: the orchestrator holds it per run. FOCA adds encrypted storage and revocation helpers.
- No: Conquest can't mint tokens days later. Options to weigh: Krini's backend holds the user's refresh token and exchanges on demand, or service tokens for that hop only. #391's "Long-running work" changes.
Is the 31 days idle or absolute, and do refresh tokens rotate?¶
- Absolute: it's the maximum length of a run, which goes into Conquest's docs.
- Idle: runs can go on as long as they refresh in time, unless the grant has a cap of its own, which only the LS Login team can confirm.
- Rotation: FOCA's helper has to store the new token atomically, as a lost one ends the run.
Are refresh tokens bound to the client, and is reuse detected?¶
- Bound: a refresh token that leaks from the workflow system is of no use to another client without that client's secret, too. If not, a refresh token has to be treated like a password of the user's.
- Reuse detected: a leaked refresh token that is used ends the run, too, so leaks show. FOCA's helper then reports that the grant has ended, rather than retrying.
- Neither: the 31 days are all that limits a leaked refresh token, unless it's revoked.
What to record¶
| Step | Record | Result |
|---|---|---|
| Lifetimes | Login, exchanged, second hop, refreshed, exchanged from an old subject | |
| Refresh at the client | Format of the refresh token, refresh_token_rotated, exp before and after |
|
| Idle or absolute | exp of r1 and r2, and the verdict: idle, absolute or unknown |
|
| Refresh token from an exchange | Whether either holds a refresh token, and issued_token_type |
|
| Only if that returned one | aud, status of the call, the refresh after revoking |
|
| Expired token | sub compared with the first login, status and reason, the exchange's error, the refresh |
|
| Binding and reuse | Whether exp-other was refused, refresh_token_rotated of exp-new2, and whether exp-reuse and exp-after were refused, with errors |