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).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 user’s ID: the
idthe realm gave them, read fromhttps://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.
End the sessions
Section titled “End the sessions”-
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. -
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, sendDELETE https://foobar.cvyuh.com/api/v0/am/sessions/v1/<id>instead.
Check it worked
Section titled “Check it worked”- 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
LOGOUTrecord for each session ended, with your ID asendedByin its context. Read it in Audit → Authentication in the dashboard, or with Read a user’s or agent’s trail.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
{ "ended": 0 } | The filter’s value isn’t the user’s ID (a username matches nothing), or they have no live session | Read the user’s id and list their sessions first |
404 when ending one session | That session already ended, or its name is wrong | List the sessions again; the id column is the name to send |
| The user is still using an app | The app holds offline access, which outlives sessions, or keeps its own session and has no back-channel address | Revoke the app’s grant (Cut a user off now), and see Tell other apps about a sign-out |
| Some sessions remain after a large search | One call ends at most 10,000 sessions | Call again |
| The user signs straight back in | Ending a session doesn’t stop them signing in | Deactivate the user, or reset the lost factor |
Good to know
Section titled “Good to know”- Offline access isn’t a session. An app the user allowed
offline_accesskeeps 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.
Undo it
Section titled “Undo it”A session can’t be brought back. The user signs in again and gets a new one.
Related
Section titled “Related”- Cut a user off now: sessions, apps, agents and the account, in one runbook.
- Session management: every way to find and end sessions.
- Tell other apps about a sign-out: what apps receive when a session ends.
- Sign-in methods: removing a lost passkey or app.