Skip to content
Workforce IdentityMarkdown

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). 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 the address it wants users to land on.
  1. 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 its postLogoutRedirectUris back 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.

  2. 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.

  3. 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 }'
The app sends…The user sees
their ID token as a hint, and a registered return addressSigned out at once, back at the app’s page
a hint that names another session, or no hintA page asking them to confirm, then signed out
a registered return address with only its client_idThe confirm page, then back at the app’s page
a hint the realm didn’t signA 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 outBack at the app’s page if it sent a registered return address, else the signed-out page; no error

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.

SymptomCauseFix
The user lands on the realm’s signed-out page, not the app’sThe return address isn’t registered exactly, port included, or the app sent neither a hint nor its client_idRegister the address as the app sends it, and send the hint
The user sees a confirm page every timeThe app sends no hint, or a hint from another sessionSend the ID token from the current sign-in as id_token_hint
An error page, and the user isn’t sent backThe hint wasn’t signed by the realm for this appSend the app’s own ID token, unchanged
Confirming does nothing, or is refusedThe user waited past logoutChallengeLifetimeSecsStart the sign-out again, or raise the setting
Another app still shows the user signed inThat app keeps its own sessionTell other apps about a sign-out

Send the client’s postLogoutRedirectUris back without the address. Sign-outs from the app then end on the realm’s signed-out page.