Sign users out from an app
Let an app sign the user out of the realm and bring them back to the app, and what happens when the request can't prove whose session it is.
APIOpenID Connect RP-Initiated Logout 1.0
Sign out in an app should end the user’s session with the realm, not only the app’s own. Every online grant ends with it, in every app, and the user lands back at a page of the app’s choosing. This is for any app that signs users in through the realm.
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 the address it wants users to land on.
Set it up
Section titled “Set it up”-
Register where the browser may return after sign-out. Read the client first with
GET https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/<client-id>, then send itspostLogoutRedirectUrisback with the address added: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 '{ "postLogoutRedirectUris": ["…existing addresses","https://wiki.example.com/"] }'The list you send replaces the client’s whole list. The return address must match one registered here exactly, port included.
-
Have the app’s Sign out send the browser to:
https://foobar.cvyuh.com/oauth2/logout?id_token_hint=<the ID token>&post_logout_redirect_uri=https://wiki.example.com/&state=<anything the app wants back>An expired ID token is still a good hint: sessions often outlive their ID tokens.
-
Optionally, change how long the confirm page stays answerable, from 10 to 3600 seconds (600 by default):
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 '{ "logoutChallengeLifetimeSecs": 600 }'
What the user sees
Section titled “What the user sees”| The app sends… | The user sees |
|---|---|
| their ID token as a hint, and a registered return address | Signed out at once, back at the app’s page |
| a hint that names another session, or no hint | A page asking them to confirm, then signed out |
a registered return address with only its client_id | The confirm page, then back at the app’s page |
| a hint the realm didn’t sign | A signed-out page with an error; never sent back to the app |
| anything but a hint the realm didn’t sign, when they’re already signed out | Back at the app’s page if it sent a registered return address, else the signed-out page; no error |
Check it worked
Section titled “Check it worked”Sign in to the app, click Sign out, and you land on the registered page. Opening another app that shared the session now asks you to sign in. The realm’s own sign-out, in the dashboard, has the same effect.
The sign-out is on the user’s trail as a LOGOUT record naming the session. Find it in Audit → Authentication in
the dashboard.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| The user lands on the realm’s signed-out page, not the app’s | The return address isn’t registered exactly, port included, or the app sent neither a hint nor its client_id | Register the address as the app sends it, and send the hint |
| The user sees a confirm page every time | The app sends no hint, or a hint from another session | Send the ID token from the current sign-in as id_token_hint |
| An error page, and the user isn’t sent back | The hint wasn’t signed by the realm for this app | Send the app’s own ID token, unchanged |
| Confirming does nothing, or is refused | The user waited past logoutChallengeLifetimeSecs | Start the sign-out again, or raise the setting |
| Another app still shows the user signed in | That app keeps its own session | Tell other apps about a sign-out |
Undo it
Section titled “Undo it”Send the client’s postLogoutRedirectUris back without the address. Sign-outs from the app then end on the realm’s
signed-out page.
Related
Section titled “Related”- Logout: every sign-out path and what it revokes.
- Tell other apps about a sign-out: so apps end their own sessions too.
- Choose online or offline access: which access survives a sign-out.