Repository navigation
Request for Documentation on SSO Best Practices (OIDC/SAML) #41410
Unanswered
Diogo-Rego
asked this question in
Q&A
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm currently working on securing a Keycloak deployment and was wondering:
Is there an official or community-recommended guide on best practices for Single Sign-On (SSO) configuration, specifically related to:
Access Token Lifespan and refresh strategies (short-lived vs long-lived)
Session idle/max timeout recommendations
SSO logout behavior (front-channel/back-channel logout, global logout etc.)
Password policies (recommended settings per security level)
Best practices around OIDC vs SAML setup choices
Other relevant hardening steps (e.g. PKCE, CORS, client scopes)
I’ve gone through the official documentation and some blog posts, but I haven’t found a centralized or opinionated reference that ties all this together for real-world secure SSO deployments.
Would appreciate it if anyone could point me to such a guide or if the team is considering publishing one!
All reactions
Replies: 2 comments · 2 replies
Uh oh!
There was an error while loading. Please reload this page.
Those questions are more related to the open standards OpenID Connect, OAuth, and SAML, not specific to Keycloak.
Review the RFCs, IETF drafts, and BCPs for those standards. Here are some examples:
[1] Best Current Practice for OAuth 2.0 Security --> https://datatracker.ietf.org/doc/rfc9700/
[2] OAuth 2.0 Threat Model and Security Considerations --> https://datatracker.ietf.org/doc/rfc6819/
[3] OAuth 2.0 for Browser-Based Applications --> https://datatracker.ietf.org/doc/draft-ietf-oauth-browser-based-apps/
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Thanks for sharing those links. However, the documents you provided — such as the OAuth 2.0 Security BCP (RFC 9700), the OAuth 2.0 Threat Model (RFC 6819), and the draft for Browser-Based Applications — focus more on general security considerations, threat mitigation strategies, and best practices for implementing OAuth and OpenID Connect securely.
They do not specifically mention implementation-level parameters like Access Token Lifespan, Client Session Idle, or Client Session Max. Those are typically configuration options provided by identity providers (like Keycloak) to manage session behavior and token expiration, rather than being standardized or dictated directly by the RFCs or drafts.
That said, the principles discussed in those documents can help inform decisions about setting those parameters securely, even if they don’t prescribe exact values or mechanisms.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
But parameters like Access Token Lifespan, Client Session Idle, or Client Session settings are all based on your business and security requirements. It’s not something strictly defined by Keycloak - it depends on how much time you want for your tokens and client sessions.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
You're right — parameters like Access Token Lifespan, Client Session Idle, and other session settings in Keycloak aren't strictly defined by the platform itself. They should be configured based on your organization's business and security requirements.
That said, are there any well-established recommendations or best practices regarding how long sessions (both access tokens and client sessions) should remain active in typical scenarios?
For instance, in applications like Nextcloud (and similar tools), once a user logs in via Keycloak, there are usually two active sessions:
Keycloak session: the central authentication session, managed by the realm or client settings in Keycloak.
Nextcloud session: the local application session, with its independent timeout and behavior.
This leads to a few implications:
A user may remain authenticated in Nextcloud even if their Keycloak session expires, as long as the local session is still active.
Federated logout doesn’t always terminate the local session unless the application properly supports mechanisms like backchannel logout.
Because of this, it's not ideal to keep both sessions active for extended periods. Instead, it's important to align session timeouts between the identity provider (Keycloak) and the application (Nextcloud), based on a clear and consistent security policy.
Are there any official or community-backed guidelines regarding session duration or token lifetime in federated login scenarios like this?
All reactions