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).RealmViewercan 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
httpsaddress on a public host name where the app receives the notice.
Set it up
Section titled “Set it up”-
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. -
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). Thesidmatches the one in the ID token the app received at sign-in, so the app finds its session by thatsidand ends it. -
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 }'
Good to know
Section titled “Good to know”- 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.
Check it worked
Section titled “Check it worked”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.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| Registering the address is refused | It is localhost, a single-word name or an IP address | Use a public https host name |
| The app is never told | It received no ID token in that session, or the session only timed out | Ask for openid at sign-in; a timeout isn’t announced |
| The app is told, but the user stays signed in to it | The app looks the session up by something other than sid | Store the ID token’s sid at sign-in and end that session |
| The app rejects the logout token | It checked it after logoutTokenLifetimeSecs, or against the wrong issuer or audience | Check promptly; iss is the realm’s issuer and aud the app’s client ID |
Undo it
Section titled “Undo it”PATCH the client with { "backchannelLogoutUri": null }. The app is no longer told.
Related
Section titled “Related”- Logout: back-channel logout and every sign-out path.
- Sign users out from an app: starting the sign-out.