Skip to content
Workforce IdentityMarkdown

Logout

Signing out from one app ends the user's session, revokes the tokens it gave, and tells your other apps.

AvailableAPIOpenID Connect RP-Initiated Logout 1.0, OpenID Connect Back-Channel Logout 1.0

When a user signs out of one of your apps, the realm ends their session, and every access token given in that session without offline access stops working at once. Your other apps that signed the user in through the same session are told, so each can end its own session for that user too.

Use it in every app that signs users in with OpenID Connect. The app starts the sign-out by sending the browser to the realm; apps that registered a back-channel address hear about it without the browser.

  • Who can do it: a realm administrator (a group holding RealmOwner) registers the client’s sign-out addresses; RealmViewer can read them. The app starts each sign-out itself.
  • Where: today this is done through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: the app signs users in with OpenID Connect, so it holds an ID token to send as the hint.

1. The app sends the browser to the realm, with the ID token it holds as id_token_hint, where to return, and a state of its own:

GET /oauth2/logout?id_token_hint=eyJhbGciOiJSUzI1NiIs…
&post_logout_redirect_uri=https%3A%2F%2Fwiki.example.com%2Fsigned-out&state=x7f3k
Host: foobar.cvyuh.com

2. The realm ends the session when the hint names the browser’s current session, and returns the browser:

HTTP/1.1 303 See Other
Location: https://wiki.example.com/signed-out?state=x7f3k

If the hint names another session, or there is no hint, the user is first asked on the realm’s sign-out page. Without a hint, the app sends its client_id beside post_logout_redirect_uri, and the browser returns there once the user confirms. If the user chooses to stay signed in, nothing ends, and the browser goes to the realm’s home page.

3. Other apps are told. Every app that received an ID token in that session and registered a backchannelLogoutUri receives a POST with a form field logout_token, and answers 200 or 204. Each app is told once per session. The token is a JWT of type logout+jwt, with these claims:

{
"iss": "https://foobar.cvyuh.com/oauth2",
"aud": ["team-wiki"],
"iat": <unix time>,
"exp": <iat + 120>,
"jti": "0c9a2f4e-71d3-4b8e-a5f6-3e2d1c0b9a87",
"sid": "6f1e2d3c-4b5a-4968-8776-a5b4c3d2e1f0",
"events": { "http://schemas.openid.net/event/backchannel-logout": {} }
}

It names the session by sid, the same sid as in the app’s ID tokens. It carries no sub and no nonce, so it can never pass for an ID token. It’s signed with the same algorithm as the app’s ID tokens.

AccessAfter sign-out
Tokens given without offline_accessEnd with the session, everywhere at once
Tokens given with offline_accessKeep working: the user allowed access while away
A session that simply times outEnds its tokens the same way, but no app is told

A token given without offline_access never outlives the session’s own end, even if the session isn’t signed out: its lifetime is cut to fit. Signing out of the realm’s own pages has the same effect as an app-initiated sign-out.

Set these on the client (https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client; see Call the API) and the realm (PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings):

WhereSettingWhat it does
ClientpostLogoutRedirectUrisWhere the browser may return after logout
ClientbackchannelLogoutUriWhere the realm posts the logout token
ClientidTokenSignedResponseAlgThe algorithm its ID tokens and logout tokens are signed with (OpenID Connect)
RealmlogoutChallengeLifetimeSecsHow long the confirm page stays answerable (default 600)
RealmlogoutTokenLifetimeSecsHow long a logout token is valid (default 120)

The app sends the browser to https://foobar.cvyuh.com/oauth2/logout. Discovery publishes it as end_session_endpoint.

With a hint naming their current session, nothing: the browser goes straight back to the app’s signed-out address. Otherwise the realm’s sign-out page asks the user to confirm. If they choose to stay signed in, nothing ends and the browser goes to the realm’s home page. A bad hint shows the realm’s signed-out page with the error, and never returns to the app.

Setting or limitDefaultRange
logoutChallengeLifetimeSecs: how long the confirm page stays answerable60010 to 3,600
logoutTokenLifetimeSecs: how long a logout token is valid1201 to 300
Back-channel deliveryone try and one retryfixed
backchannelLogoutUrinonehttps, at a public host name
SymptomCauseFix
The user lands on the realm’s signed-out page, not the app’spost_logout_redirect_uri isn’t exactly one of postLogoutRedirectUrisRegister the exact address
The user is asked to confirm every timeThe app sends no id_token_hint, or one for another sessionSend the ID token from the current sign-in
Another app stays signed inIt registered no backchannelLogoutUri, didn’t answer 200/204, or keeps its own session without checking sidRegister the address, answer quickly, and end the local session whose sid matches

A sign-out writes a LOGOUT record for the session, on the user’s trail. Whether each app was told isn’t recorded on the trail today; check the app’s own records for the logout_token it received. See the sign-out in Audit → Authentication.

  • The browser returns only to a registered address, matched exactly against postLogoutRedirectUris. Any other is ignored, and the browser goes to the realm’s own signed-out page. state, when sent, is returned on that address.
  • An expired ID token is still a good hint: a session can outlive its token.
  • A bad hint ends nothing. A hint the realm didn’t issue, or a client_id that isn’t the hint’s audience, is an error. The browser is shown the realm’s signed-out page with the error, never sent back to the app.
  • A browser with no session isn’t an error: it’s simply returned.
  • Only the session being ended can answer its confirm page.
  • Back-channel addresses must be https, at a public host name. Addresses such as localhost or an IP address are refused.
  • Delivery is best effort, with one retry. The session’s tokens never wait on it: they end the moment the session ends.