Skip to content
Workforce IdentityMarkdown

Tell other apps about a sign-out

When a user's session ends, the realm tells every app they signed in to through it, so each app can end its own session for them.

APIOpenID Connect Back-Channel Logout 1.0

A user signs out in one app, or in the dashboard. Their tokens stop working at once, but an app that keeps its own session, such as a server-side web app with its own cookie, would still show them signed in. With back-channel logout, every other app they signed in to through the same session hears about it within seconds and ends its own session for them.

Before you start:

  • Who can do it: a realm administrator, in a group that holds RealmOwner (Delegated administration). RealmViewer can read the settings but not change them.
  • Where: today this is done through the API; Call the API shows how to get $CVYUH_SESSION.
  • First: have the app’s client ID, and an https address on a public host name where the app receives the notice.
  1. Register the app’s back-channel address:

    Terminal window
    curl -X PATCH 'https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/<client-id>' \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "backchannelLogoutUri": "https://wiki.example.com/backchannel-logout" }'

    localhost, single-word names and IP addresses are refused when you register it.

  2. Have the app handle the notice. It’s an HTTP POST carrying a logout token: a short-lived JWT signed by the realm, naming the realm, the app and the session (sid). The sid matches the one in the ID token the app received at sign-in, so the app finds its session by that sid and ends it.

  3. Optionally, change how long a logout token is valid:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "logoutTokenLifetimeSecs": 120 }'
  • Each app is told once per session, even if it signed in several times.
  • Only apps that received an ID token in that session are told.
  • Delivery is best effort: one retry after a timeout or a server error. The user’s tokens don’t wait for it; they end the moment the session ends.
  • A session that only times out isn’t announced.
  • The address must resolve to a public address when it is called, or the call isn’t made.

Sign in to two apps with one session, and sign out from the first. The second app’s back-channel address receives a POST with a logout token whose sid matches its session.

The sign-out itself is on the user’s trail as a LOGOUT record; the notices to each app are not, so look for them in the app’s own records.

SymptomCauseFix
Registering the address is refusedIt is localhost, a single-word name or an IP addressUse a public https host name
The app is never toldIt received no ID token in that session, or the session only timed outAsk for openid at sign-in; a timeout isn’t announced
The app is told, but the user stays signed in to itThe app looks the session up by something other than sidStore the ID token’s sid at sign-in and end that session
The app rejects the logout tokenIt checked it after logoutTokenLifetimeSecs, or against the wrong issuer or audienceCheck promptly; iss is the realm’s issuer and aud the app’s client ID

PATCH the client with { "backchannelLogoutUri": null }. The app is no longer told.