tut: Keycloak session and token timeouts, explained - #376
Merged
Merged
Conversation
Deploying phasetwo-docs with
|
| Latest commit: |
22700f7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dd1917fb.phasetwo-docs.pages.dev |
| Branch Preview URL: | https://content-t67-session-token-ti.phasetwo-docs.pages.dev |
xgp
marked this pull request as ready for review
September 7, 2026 10:29
9 tasks
pnzrr
approved these changes
Sep 7, 2026
Both sides added a new sidebar category in the same position: this branch's "Sessions and tokens", and "Securing applications" which landed on main in #372 and #373 while this sat open. Kept both. "Sessions and tokens" goes after "JSON Web Tokens (JWT)" rather than where either side had it. That is where tutorials/index.md already puts it -- the timeouts tutorial is step 5 of the "Working with tokens" learning path, after the three JWT ones -- and it leaves main's existing category order untouched. tutorials/index.md merged cleanly and reads correctly: the new "Securing an application" path sits above the token path, and its "More framework-by-framework guides are next" line is still true.
Every URL on this site is served and canonicalised with a trailing slash, and this was the only /docs/authentication/sso without one anywhere in the repo. Not broken -- it redirects -- but a redirect hop on a page about to publish, and inconsistent with the four other internal links in the same file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keycloak Session and Token Timeouts, Explained
Queue item: T67 · Type: tutorial · Track: Sessions and tokens (new)
Publish target: week of 2026-09-14
Path:
tutorials/sessions/timeouts.mdx→/tutorials/sessions/timeouts/Primary keyword: keycloak session timeout
Secondary: keycloak token lifespan, keycloak sso session idle, keycloak access token lifespan, keycloak refresh token expiration
What this helps a reader do
Configure Keycloak's twelve interacting session and token timeouts deliberately instead of
by trial and error, and know which setting actually bounds each risk.
The official Session and token timeouts
reference is a good definition list and this page links to it rather than restating it. What
it does not give you is which setting wins when two disagree, what the defaults are, what the
REST field behind each console label is called, or what breaks. This page adds:
Tokens tabs, plus the five client-level override attribute keys and the four per-action
realm attributes. These are needed for
kcadm.sh, Terraform and realm JSON, and themapping is not published anywhere. Read out of the admin console shipped in 26.7.3.
own
expires_in/refresh_expires_infor each — and five precedence rules derived from it.The three findings that make this worth publishing
Token Lifespan at 300s, at t+91s the refresh grant returns
invalid_grant,/userinforeturns 401 and introspection says
active: false— but the JWT still verifies againstthe realm JWKS with 200+ seconds left. Any resource server doing local signature
validation (the recommended default) accepts it. So session idle bounds
re-authentication; only Access Token Lifespan bounds the token. Stated plainly, including
the cost of the default.
The docs qualify it with "only if persistent user sessions are not active", and persistent
user sessions have been on by default since Keycloak 26. Measured both ways on 26.7.3 —
five independent sessions per run, one probe each, since a successful refresh resets the
idle clock — and the results are identical: expiry is exact at the configured idle in both
modes. A lot of third-party advice still says to budget the extra two minutes.
refresh_expires_inshrinks as a session ages (measured 150 → 139 → 79 as theremaining max lifespan falls below the idle timeout). Clients that cache the first value
schedule their last refresh after the session has already ended.
Verified against
quay.io/keycloak/keycloak:26.7.3,start-dev). Every default,number and error string in the page is copied from an actual run; nothing is from memory.
--features-disabled=persistent-user-sessionsfor the A/Bin finding 2.
admin console bundle in that release rather than inferred.
Configuring distributed caches, and the 26.0 release notes for the persistent-user-sessions
default.
Could not confirm
refresh grant and may still use the two-minute window. Only the refresh grant was measured;
the page says so explicitly and does not claim the window is gone everywhere.
way in the text.
Editorial notes
authors:frontmatter — no tutorial in this section carries one and the tutorialsplugin does not render a byline. Flagging rather than introducing an unused field.
<ProductionNote />is the only Phase Two mention, which is also where the canonicalcommercial link lives. Nothing in the tutorial requires our product.
sidebars.tutorials.js(first tutorial in thetrack) and one line to the tutorials index learning path.
Internal links
/tutorials/getting-started/your-first-token//tutorials/getting-started/run-keycloak-locally//tutorials/jwts/jwt-security-best-practices//tutorials/jwts/jwt-benefits-drawbacks//docs/authentication/sso/hosting/dedicated-clusters/(via<ProductionNote />)Follow-ups, once their pages are on
main: this page wants links to the offline-access,session-limits and OIDC-logout tutorials in the same track. They are in separate PRs and do
not exist on this branch, so the link checker would reject them — deliberately left out.
Checklist
pnpm install --frozen-lockfile && pnpm buildpasseskeycloak_versionfrontmatter set<ProductionNote />present and is the only Phase Two mentionimage:key)Rationale for the item and its place in the plan is in the private
content-marketingrepo.