Configure Keycloak login policies
What you’ll accomplish
Section titled “What you’ll accomplish”You’ll configure Keycloak login behavior for your UDS Core deployment: setting concurrent session limits, session idle timeouts, and logout confirmation behavior. All configuration in this guide is applied via bundle overrides — no image rebuild required.
Prerequisites
Section titled “Prerequisites”- UDS Core deployed
- UDS CLI installed
- Familiarity with UDS bundle overrides
Before you begin
Section titled “Before you begin”This guide configures Keycloak via Helm chart values — the fastest path to operational changes with no image rebuild required. If you’re unsure which approach fits your need, see Keycloak configuration layers. For custom themes or plugins, see Build a custom Keycloak configuration image.
-
Limit concurrent sessions per user
By default, Keycloak allows unlimited concurrent sessions per user. To restrict this — for example, to enforce single-session policies or limit login storms — set these values in your bundle:
uds-bundle.yaml packages:- name: corerepository: registry.defenseunicorns.com/public/coreref: x.x.x-upstreamoverrides:keycloak:keycloak:values:- path: realmInitEnvvalue:# Maximum concurrent active sessions per user (0 = unlimited)SSO_SESSION_MAX_PER_USER: "3"- path: realmConfigvalue:# Maximum in-flight (ongoing) login attempts per usermaxInFlightLoginsPerUser: 1Setting Default Description SSO_SESSION_MAX_PER_USER0(unlimited)Max concurrent active sessions per user maxInFlightLoginsPerUser300Max concurrent login attempts in progress -
Configure session idle timeouts
Keycloak has two session idle timeout layers that interact with each other:
- Realm session idle timeout: Controls the overall user session. When it expires, the user is logged out from all applications.
- Client session idle timeout: Controls the refresh token expiration for a specific application. Must be set equal to or shorter than the realm timeout.
Configure realm session timeouts via bundle override:
The realm-level SSO session idle timeout and max lifespan are set during initial realm import and can be configured in your
uds-bundle.yaml:uds-bundle.yaml packages:- name: corerepository: registry.defenseunicorns.com/public/coreref: x.x.x-upstreamoverrides:keycloak:keycloak:values:- path: realmInitEnvvalue:# Session idle timeout in seconds (default: 600 = 10 minutes)SSO_SESSION_IDLE_TIMEOUT: "1800"# Session max lifespan in seconds (default: 36000 = 10 hours)SSO_SESSION_MAX_LIFESPAN: "28800"Configure realm session timeouts in the Keycloak admin UI (for live instances):
- Log in to the Keycloak admin UI at
keycloak.<admin_domain> - Switch to the uds realm using the top-left dropdown
- Go to Realm Settings → Sessions tab
- Adjust SSO Session Idle and SSO Session Max as needed
Configure per-client session timeouts (admin UI only — not available as a bundle override):
- Go to Clients → select the client → Advanced tab → Advanced Settings
- Set Client Session Idle to a value ≤ the realm’s SSO Session Idle
-
Disable logout confirmation
By default, UDS Core shows a confirmation page when a user logs out. To skip this for specific applications, set the
logout.confirmation.enabledattribute in the Package CR:package.yaml apiVersion: uds.dev/v1alpha1kind: Packagemetadata:name: my-packagenamespace: my-namespacespec:sso:- name: My SSO ClientclientId: my-client-idredirectUris:- "https://my-app.uds.dev/login"attributes:logout.confirmation.enabled: "false" -
Create and deploy your bundle
Terminal window uds create <path-to-bundle-dir>uds deploy uds-bundle-<name>-<arch>-<version>.tar.zst
Verification
Section titled “Verification”Confirm your session policy changes are applied:
Check concurrent session limits:
- Log in to the same application from two different browser sessions
- If
SSO_SESSION_MAX_PER_USERis set to1, the second login should invalidate the first session
Check logout confirmation:
- Log out from an application where you set
logout.confirmation.enabled: "false" - The user should be logged out immediately without a confirmation page
Check session timeout configuration:
In the Keycloak admin UI, navigate to Realm Settings → Sessions and confirm the SSO Session Idle and SSO Session Max values match your intended configuration.
Troubleshooting
Section titled “Troubleshooting”Problem: Session expires unexpectedly early
Section titled “Problem: Session expires unexpectedly early”Symptoms: Users are logged out before the configured timeout elapses, or sessions expire after only 10 minutes on a fresh deployment.
Solution: The default SSO_SESSION_IDLE_TIMEOUT is 600 seconds (10 minutes). If this is too short for your environment, set a longer value in realmInitEnv before the first deploy, or update it in the Keycloak admin UI (Realm Settings → Sessions) on a live instance.
Also verify that the client session idle timeout is ≤ the realm session idle timeout. In Keycloak 26.5+ this is enforced; in earlier versions, a misconfigured client setting would be silently overridden by the realm setting.
Problem: Bundle deploy fails with a realmConfig error
Section titled “Problem: Bundle deploy fails with a realmConfig error”Symptoms: uds deploy fails with a validation error referencing realmConfig fields.
Solution: Verify the path and value types match the chart values schema. Common mistakes:
- Values expected as strings must be quoted:
"3"not3forSSO_SESSION_MAX_PER_USER - Check the Keycloak chart values for the correct path syntax
Problem: Logout confirmation change has no effect
Section titled “Problem: Logout confirmation change has no effect”Symptoms: Users still see a logout confirmation page after setting logout.confirmation.enabled: "false".
Solution: Confirm the Package CR is applied and the UDS Operator has reconciled it. Check the operator logs:
uds zarf tools kubectl logs -n pepr-system -l app=pepr-uds-core-watcher --tail=50 | grep logoutRelated Documentation
Section titled “Related Documentation”- Build a custom Keycloak configuration image — for theme and plugin customization beyond Helm values
- Manage FIPS 140-2 mode — verify FIPS status and understand constraints
- Keycloak: Session and Token Timeouts — upstream reference for session configuration options
- Package CR reference — full spec for SSO client configuration
Next steps
Section titled “Next steps”These guides and concepts may be useful to explore next: