Logout with SSO
Last updated: 2026-11-16T20:23:26-03:00 (UTC-3)
Two logout directions for those who sign in to the console through SSO:
| Feature | What it does | Flag |
|---|---|---|
| Backchannel logout | The IdP notifies the gateway when the session ends there (logout, employee offboarding), and the console session drops on the next request, on any replica | oidc_backchannel_logout |
| Sign out of the console and the IdP | When you click sign out, the console also ends the session at the IdP | oidc_rp_logout |
Both affect only federated sessions. Local login, the bootstrap token and inference keys are not touched.
Backchannel logout
Section titled “Backchannel logout”How to turn it on
Section titled “How to turn it on”features: oidc_login: true oidc_backchannel_logout: true # boot; requires PostgreSQLadmin: oidc: # other OIDC login fields session_epoch: oidc-bc-rollout-v1session_epoch is required: an identifier of 1 to 64 characters (A-Z, a-z, digits, _, -). It is not a secret; it marks the generation of federated sessions (see rollout).
In the IdP client, register the URL:
https://gateway.example.com/api/v1/admin/auth/oidc/backchannel-logoutIn Keycloak, configure the client’s backchannel logout URL and include sid in the tokens to log out a specific session. If the IdP sends only sub, all of that user’s sessions drop.
Tested with Keycloak 26.4: an administrative logout in Keycloak brought down the console session on the next request. Google sign-in does not imply backchannel support.
Named providers and the tested Keycloak profile
Section titled “Named providers and the tested Keycloak profile”For a named provider, register /api/v1/admin/auth/oidc/{id}/backchannel-logout instead of the legacy singleton URL. Its durable provider generation isolates this client/issuer from other profiles; local and legacy sessions are not implicitly revoked. Named forms are limited to 20 KiB (the legacy form limit is 64 KiB); both keep the 16 KiB token limit.
The validated Keycloak 26.4.0 profile supports two genuine notification shapes:
| Intended action | Keycloak client/operation | Gateway result |
|---|---|---|
| End one SSO session | Backchannel logout session required enabled; end that session through its Sessions view or a separate DELETE /admin/realms/{realm}/sessions/{sid} request |
The signed sub+sid event revokes that session on both replicas; the other SSO session stays valid |
| End every SSO session for this user/client | Backchannel logout session required disabled (backchannel.logout.session.required=false); administrative user logout |
Keycloak sends a signed sub-only event; all matching user sessions in that named provider are revoked, while other profiles remain valid |
Keep this distinction when configuring Keycloak 26.4.0. Its administrative user-logout loop can reuse one logout authentication context and deduplicate notifications by client: with session-required enabled and two SSOs, the observed run removed both IdP sessions but sent only one SID notification. The gateway correctly revoked only the notified session. The two configurations above were then tested with real signed notifications; no SID was discarded or replaced with a subject wildcard. See the pinned logout context and client deduplication.
A valid 200 acknowledges processing of a signed notification, including a notification whose session was already absent. It does not assert that the IdP notified every session. Preserve exact issuer/client/generation and every supplied sub/sid; never broaden a received SID event to work around missing IdP notifications. Named security changes also have the documented timestamp/skew fence; this does not promise provider retries.
How it works
Section titled “How it works”The IdP sends a POST with Content-Type: application/x-www-form-urlencoded and a logout_token in the body. The signed token is the authentication; there is no cookie or CSRF.
The gateway validates:
- an RS256, ES256 or PS256 signature against the login JWKS (never against keys indicated in the token itself), issuer, audience and
azp; iss,aud,iat,exp,jti,eventswith the backchannel logout event, andsuborsid;- the absence of
nonce, which distinguishes the logout token from an ID token; - dates:
iatat most 5 minutes in the past and at most 30 s in the future,expin the future and up to 5 minutes afteriat. Keep clocks synchronized.
| Result | Response |
|---|---|
| Valid, even for a session that no longer exists | 200 |
Invalid token or repeated jti |
400 |
| Flag off | 404 |
| Capacity, JWKS or database unavailable | 503; nothing is treated as done |
After the logout:
- the next request from that session is denied on any replica; requests already in progress may finish;
- a login that was in progress at the time of the logout does not recreate the session;
- the session cookie carries neither
sub,sidnor tokens; the database stores only hashes.
The federated session queries the primary PostgreSQL on every request. A lagging read replica does not work for this.
Limits
Section titled “Limits”| Resource | Limit |
|---|---|
| Concurrent logouts per replica | 4; the excess gets 503 |
| Form / token / token header | 64 KiB / 16 KiB / 2 KiB |
| Total logout time | 10 s |
| Sessions, replays and tombstones | up to 100,000 of each in the database |
| Session duration | up to 8 hours |
Cleanup of expired records happens alongside logins and logouts, without a dedicated process. When the ceiling is reached, new sessions fail closed instead of deleting valid protection.
Rollout and rollback
Section titled “Rollout and rollback”- Apply the migration (additive).
- Enable it with a new
session_epoch, the same on every replica. Federated users have to sign in again. - Register the URL in the IdP and test signature, audience, dates,
sid/suband retry. - To turn it off, preserve the epoch or advance to another new one. Never remove it or go back to an old value: that could re-enable old cookies still within their 8 hours.
- When re-enabling, advance the epoch again.
Never delete the revocation tables to work around an outage: revoked sessions could become valid again.
Make the epoch monotonic
Section titled “Make the epoch monotonic”oidc_epoch_guard (off by default; requires oidc_login and PostgreSQL; read at startup) turns step 4 from a procedure into a check:
features: oidc_login: true oidc_backchannel_logout: true oidc_epoch_guard: trueadmin: oidc: session_epoch: "2026-11-a" # advance to a never-used value; never go back- At startup the gateway checks the epoch first and records it only after every other startup step has passed, so a startup that fails later never advances the history and never blocks a rollback to the epoch before it. It records a SHA-256 digest of
admin.oidc.session_epoch(never the value) ingateway_oidc_session_epochs, in order, under a database lock, so replicas starting together agree on one order. - The latest epoch starts again. A never-used epoch becomes the latest and is logged as
oidc_session_epoch_advancedwith its sequence number. - An earlier epoch, or an empty one after any was recorded, stops startup with
oidc session epoch check failed, before the server listens. Advance to a new value instead. - It covers the legacy
admin.oidcprofile; named OIDC profiles already keep monotonic database generations. - Turning the flag off skips the check (and records nothing) until it is on again; the recorded history stays and still applies when it is.
- During a rolling update, replicas already running keep their epoch; a replica restarted with the old epoch after the new one was recorded is refused, which is the point. Roll forward, not back.
- Migration 169 adds the table; nothing is written until the flag is on.
Sign out of the console and the IdP
Section titled “Sign out of the console and the IdP”With oidc_rp_logout, signing out of a federated session returns an end_session_url and the console navigates to it. The URL comes from the IdP’s discovery (a trusted origin) and carries the client_id and, if configured, a post_logout_redirect_uri on the console’s origin.
The gateway does not store the ID token, so it does not send id_token_hint. Some providers ask for confirmation because of this (Keycloak asks “Do you want to log out?”), and those that require the hint keep their own session.
General limits
Section titled “General limits”- No front-channel logout. SAML has no Single Logout.
- The log records the request ID and the result, without IdP identifiers; it is not an immutable audit.
See also
Section titled “See also”- SSO and group-based login.
- Specification: OpenID Connect Back-Channel Logout 1.0.