Token lifetime, renewal, and revocation¶
Xratu issues two kinds of token, and they differ in exactly one operationally important way: one can be revoked and one cannot.
| Exchanged token | Service-account token | |
|---|---|---|
| Obtained by | Exchanging a provider token | Issuing against a service account |
| Default lifetime | 3600 seconds | 86400 seconds |
| Minimum lifetime | 300 seconds | 300 seconds |
| Tracked individually | No | Yes, by token id |
| Revocable | No | Yes |
| Renewed by | Exchanging again | Issuing another |
Lifetime¶
Both kinds take a requested lifetime and both apply the same floor. A request below 300 seconds is raised to 300, so the shortest token you can hold is five minutes.
xratu auth exchange --provider gcp --external-token "${TOKEN}" --ttl-seconds 3600 --set-token
xratu auth issue-token --for service-account:ci-publisher --ttl-seconds 86400
Any lifetime is accepted at issue, so a long-lived service-account token is possible, and revocation is what makes that acceptable.
Expiry is carried in the token and checked on every request. An expired token verifies as nothing, so the request falls back to the system actor and fails on authorisation rather than reporting an expiry.
How a token is renewed¶
Renewal is reissue: every fresh token comes from the path that issued the first one.
An exchanged token is renewed by exchanging again, which means obtaining a fresh provider token first. This is why an automation that authenticates through a human's provider session eventually stops working: the session, not the Xratu token, is the thing that lapses.
A service-account token is renewed by issuing another. The old one remains valid until it expires or is revoked, so issue the replacement first, switch, then revoke the old one.
Revocation¶
Only service-account tokens can be revoked, because only they are recorded individually when issued. Each carries a token id, and every request using one checks that the id is still active.
xratu auth revoke-token \
--for service-account:ci-publisher \
--token-id <token-id> \
--reason "rotating credentials"
The reason defaults to manual_revocation when omitted. Revocation is audited,
recording the actor, the token id and the reason.
After revocation, a request carrying that token resolves to no actor with a
context of token_revoked_or_expired.
Exchanged tokens cannot be revoked. They are not tracked individually, so there is nothing to mark inactive. A leaked exchanged token stays valid until it expires, which is the argument for short lifetimes on them and for using service accounts wherever a credential will be stored rather than held in a session.
Rotating a service-account credential¶
The safe order avoids a gap where nothing works:
# 1. issue the replacement
xratu auth issue-token --for service-account:ci-publisher --ttl-seconds 86400 --reason "rotation"
# 2. deploy it wherever the old one is used, and confirm the consumer works
# 3. revoke the old token by its id
xratu auth revoke-token --for service-account:ci-publisher --token-id <old-token-id> --reason "rotation"
Keep the token id from the issue response. It is how you revoke later, and it is not recoverable from the token as an operator.
Disabling an account¶
Disabling a service account stops new tokens being issued for it: an issue
request against a disabled account is refused with 409. It does not
retrospectively invalidate tokens already issued, so revoke those explicitly.
What a token carries¶
Identity and claims. What the resulting actor may do is evaluated per request from role bindings, so a binding change takes effect immediately on tokens already issued.
The service account as a whole. A service-account token carries the account's identity within its workspace, so what it can do is adjusted through that account's bindings.
Related¶
- The authentication model for how each kind is verified.
- Create and manage a service account for the full lifecycle.