Skip to content
Workforce IdentityMarkdown

End a user's sessions

Sign a user out of the realm everywhere at once, when a device is lost or an account looks wrong, and see what it ends.

API

A user reports a stolen laptop, or their account is signing in from somewhere it shouldn’t. Ending their sessions signs them out of the realm everywhere at once: every app they signed in to through those sessions is told, and the tokens issued under them stop working. The user signs in again as normal, so pair this with a password change or removing a lost factor when the account itself is at risk.

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 user’s ID: the id the realm gave them, read from https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya.

This guide ends sessions only. To cut a user off entirely, with their offline app access and their agents, follow Cut a user off now.

  1. List the user’s live sessions, to see where they’re signed in:

    Terminal window
    curl 'https://foobar.cvyuh.com/api/v0/am/sessions/v1?filter=<filter>' \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

    where <filter> is this, URL-encoded:

    {"filter":{"field":"user","op":"=","value":"<user id>"}}

    Each session shows its id, when it began and was last used, and the address it signed in from.

  2. End all of them:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/sessions/v1/end \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "qbe": { "filter": { "field": "user", "op": "=", "value": "<user id>" } } }'

    The realm answers with how many it ended, such as { "ended": 2 }. To end only one, send DELETE https://foobar.cvyuh.com/api/v0/am/sessions/v1/<id> instead.

  • List the user’s sessions again with the same GET: none is listed.
  • Any app they were signed in to has received a back-channel logout, and its tokens from those sessions read inactive at introspection.
  • The user’s trail holds one LOGOUT record for each session ended, with your ID as endedBy in its context. Read it in Audit → Authentication in the dashboard, or with Read a user’s or agent’s trail.
SymptomCauseFix
{ "ended": 0 }The filter’s value isn’t the user’s ID (a username matches nothing), or they have no live sessionRead the user’s id and list their sessions first
404 when ending one sessionThat session already ended, or its name is wrongList the sessions again; the id column is the name to send
The user is still using an appThe app holds offline access, which outlives sessions, or keeps its own session and has no back-channel addressRevoke the app’s grant (Cut a user off now), and see Tell other apps about a sign-out
Some sessions remain after a large searchOne call ends at most 10,000 sessionsCall again
The user signs straight back inEnding a session doesn’t stop them signing inDeactivate the user, or reset the lost factor
  • Offline access isn’t a session. An app the user allowed offline_access keeps refreshing after their sessions end. See Choose online or offline access.
  • The user isn’t told. Their next click in an app sends them to sign in.

A session can’t be brought back. The user signs in again and gets a new one.