Skip to main content

List and end sessions

Show the active sessions of a person, and end one of them or all of them.

RecipeReadyView source
Packages
lumo
Works with
lumo CLIPlain HTTP

What it shows​

  1. An administrator lists the active sessions of a person. Each session is one browser in which the person is signed in.
  2. The administrator ends the oldest session. The person is signed out in that browser only.
  3. The administrator signs the person out everywhere. LumoAuth ends every session of the person.
  4. The second action also revokes the access tokens and the refresh tokens of the person. The first one does not.

Before you start​

  • An API key with the scopes admin:sessions:read and admin:sessions:write. The person who created the key must hold the permissions users.view and users.edit.
  • A test user who is signed in in two browsers, for example in a normal window and in a private window. Do not use your own account: the program signs the person out.
  • jq, and for the CLI tab the lumo CLI.
VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYAn API key with the scopes admin:sessions:read and admin:sessions:write.
USER_IDThe ID of the person (a UUID). lumo users list --search maya -o json prints it.

Code​

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization.

accounts/sessions/cli/sessions.sh
#!/bin/sh
# List the sessions of a person, end the oldest one, then sign the person out
# everywhere, with the lumo CLI.
#
# sh accounts/sessions/cli/sessions.sh
#
# The script needs the lumo CLI and jq.
set -eu

# The CLI reads its own three variables. With them it needs no `lumo login`.
export LUMO_BASE_URL="$LUMOAUTH_URL" LUMO_ORG="$LUMOAUTH_ORG_ID" LUMO_API_KEY="$LUMOAUTH_API_KEY"

# 1. The active sessions of the person, the newest first.
show() {
lumo sessions list --user "$USER_ID" -o json |
jq -r '"sessions: \(.data | length)", (.data[] | " \(.id) \(.createdAt) \(.ipAddress)")'
}
show

# 2. End one session: here the oldest one. The person is signed out in that
# browser. The tokens of the applications stay valid.
SESSION_ID=$(lumo sessions list --user "$USER_ID" -o json | jq -r '.data[-1].id // empty')
if [ -n "$SESSION_ID" ]; then
lumo sessions revoke "$SESSION_ID" --quiet > /dev/null
echo "ended session $SESSION_ID"
show
fi

# 3. Sign the person out everywhere. This ends every session, and it also
# revokes the access tokens and the refresh tokens of the person.
lumo sessions revoke-all --user "$USER_ID" --quiet > /dev/null
echo "signed out everywhere"
show
sh accounts/sessions/cli/sessions.sh

Check the result​

Output
sessions: 2
1033 2026-11-28T01:21:16+00:00 203.0.113.45
1032 2026-11-28T01:21:15+00:00 203.0.113.45
ended session 1032
sessions: 1
1033 2026-11-28T01:21:16+00:00 203.0.113.45
signed out everywhere
sessions: 0
  • After the second step, reload a LumoAuth page in the browser of the ended session, for example the account page. The browser shows the sign-in page.
  • After the last step, an application of the person cannot use its refresh token: the token endpoint answers invalid_grant. After the second step alone, the refresh token still works.
  • The audit log of the portal has one entry session.revoked and one entry session.revoked_all.
  • An application with a back-channel logout address receives a logout token in both cases. See Sign out of every application.

Limits​

  • The list holds active sessions only. It has no filter for ended sessions.
  • A session ID is a number, not a UUID.
  • An API that verifies an access token only by its signature accepts the token until it expires. Use token introspection where the revocation must count at once.
  • People end their own sessions on the hosted page Your devices. See Link to the account pages.