Skip to content

feat: see and sign out Strapi admin panel sessions - #22

Merged
Schero94 merged 8 commits into
mainfrom
feat/admin-sessions
Nov 18, 2026
Merged

Schero94 merged 8 commits into
mainfrom
feat/admin-sessions

Conversation

@Schero94

Copy link
Copy Markdown
Owner

What

New Admin panel view next to the app-user dashboard (/admin/plugins/magic-sessionmanager/admin-panel): who can use the Strapi admin panel, who is signed in (per browser: device label, signed in, last active, latest end, "This browser", "Remember me"), and Sign out / Sign out everywhere, each confirmed. Minor release (4.14.0), no breaking change; existing routes, numbers, widget and settings are unchanged.

Design note: docs/plans/2026-11-17-admin-panel-sessions-design.md. Gate with evidence: gates/admin-sessions.md.

How a sign-out takes effect (Strapi 5.62.0)

  • @strapi/admin strategies/admin.js calls sessionManager('admin').isSessionActive(sessionId) on every admin request. Deleting the session rows makes the admin's next request 401 and the panel's renewal (POST /admin/access-token) 401, so they land on the login page. No wait for the 30-minute access token.
  • isSessionActive ignores status, so revokeSessionById (deletes only the active row) leaves an access token of a rotated row valid until it expires. The plugin deletes every row of the browser via invalidateRefreshToken(userId, deviceId) (what Strapi's own logout does). Both behaviours are proven in the HTTP suite.

Server

  • Routes (admin type): GET /admin-sessions/admins, GET /admin-sessions/admins/:adminId/sessions, POST /admin-sessions/admins/:adminId/sessions/:sessionId/sign-out, POST /admin-sessions/admins/:adminId/sign-out-everywhere.
  • RBAC: admin-sessions.read, admin-sessions.revoke (Super Admin only by default), plus the existing access.
  • Strict zod input, 404 for foreign or unknown sessions, no tokens/device ids/password fields in responses, browser session required for sign-out (admin API tokens 403), 10 sign-outs/min, audit log line with admin ids and counts only, plus event magic-sessionmanager.admin-sessions.signed-out.
  • A role without Super Admin cannot sign out a Super Admin, so the last active Super Admin can't be signed out by someone else.
  • Admin rows never reach app-user numbers (regression covered over HTTP).

Tests

  • npm test 849/849; lint, format, both type checks, build, verify, verify:runtime clean.
  • New tests/isolated-admin-sessions-http.test.js (admins sign in via POST /admin/login): SQLite 14/14, PostgreSQL 16 14/14. Existing HTTP access suite on 5.62.0: legacy 37/37, refresh 39/39.
  • New CI job runs these against the repo's own Strapi 5.62 devDependencies (@strapi/plugin-users-permissions 5.62.0 added as devDependency).

Browser acceptance

Isolated Strapi 5.62.0 host (packed tarball, SQLite, random secrets, egress blocked). 100 matrix stops (5 screens x 10 widths x light/dark) with measure.js all empty; 24/24 click-path/RBAC/state checks; a second browser shows what a signed-out admin sees; keyboard walk; de/fr/es/pt at 1440 and 320; 0 plugin console messages (apart from the deliberate warning for a mocked 500). Details in the gate.

Task Steps from the plugin page
See who is signed in 1
Find an admin 2
Sign an admin out everywhere 2 + confirm
Sign one browser out 3 + confirm
Sign yourself out (warning) 3 + confirm
Deactivate (Strapi Settings > Users) 3

Docs read: docs.strapi.io/cms/configurations/admin-panel (Session management), Context7 /strapi/documentation, installed @strapi/core 5.62.0 services/session-manager.js, @strapi/admin 5.62.0 strategies/controllers/routes/ConfirmDialog/useRBAC/PageHelpers, @strapi/design-system 2.3.1 Dialog/Box/Badge.

Not run: MySQL.

🤖 Generated with Claude Code

Schero94 and others added 8 commits November 18, 2026 07:04
Research of Strapi 5.62.0 admin session storage and revocation, IA, API
contract, guards, click paths and test plan for the 4.14.0 feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds four admin routes under /magic-sessionmanager/admin-sessions that read
Strapi's own admin::session rows (origin admin) and sign admins out with
strapi.sessionManager('admin').invalidateRefreshToken, per browser or
everywhere. New RBAC actions admin-sessions.read and admin-sessions.revoke
(Super Admin only by default). Sign-out needs a browser session (no admin
API tokens), is limited to 10 per minute, writes an audit log line with
admin ids and counts only, and a delegated role cannot sign out a Super
Admin. Admin rows stay out of every app-user number.

Strapi 5.62 checks isSessionActive on every admin request, so a sign-out
takes effect on the next request. Deleting per device also ends access
tokens bound to rotated rows, which revokeSessionById alone leaves valid.

Real-HTTP suite on SQLite and PostgreSQL with admins signed in through
POST /admin/login; new CI job; @strapi/plugin-users-permissions 5.62.0 as a
devDependency so the suites boot without a separate host app.

Docs read: docs.strapi.io/cms/configurations/admin-panel (Session
management), Context7 /strapi/documentation; installed @strapi/core 5.62.0
services/session-manager.js, @strapi/admin 5.62.0 strategies/admin.js,
controllers/authentication.js, controllers/authenticated-session.js.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New "Admin panel" view next to the app-user dashboard
(plugins/magic-sessionmanager/admin-panel), switched with a two-link
navigation that only admins with admin-sessions.read see. Stat cards
(signed in, not signed in, all admins) filter the list; search, filter and
pagination run on the server and live in the URL. Table from the DS medium
breakpoint, cards below. A sessions dialog lists every signed-in browser
(Strapi's device label, signed in, last active, latest end, "This browser",
"Remember me") with Sign out, Sign out everywhere and a link to Strapi's
Settings > Users. Every sign-out is confirmed with ConfirmDialog, states
that it takes effect on the admin's next click and warns before a self
sign-out. Super Admins protected from delegated roles are explained, not
shown as disabled buttons. Five locales.

Docs read: installed @strapi/admin 5.62.0 useRBAC.d.ts and PageHelpers
(Page.Protect matches any permission), router addMenuLink (mounts
plugins/<id>/*), @strapi/design-system 2.3.1 Box/Typography types,
@strapi/icons 2.3.1 (SignOut, Eye).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The DS primary badge measured 2.43:1 in the dark theme; "You" and "This
browser" now use the primary surface with neutral800 text. The sign-out
confirmation body is a node, so it carries its own Dialog.Description
(Radix warned that the AlertDialog had no description).

Docs read: installed @strapi/design-system 2.3.1 Dialog (Body wraps only
string children in Description), @strapi/admin 5.62.0 ConfirmDialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README, Pages and CHANGELOG [Unreleased]: the Admin panel view, the four
routes and their response and error contracts, the two RBAC actions, how a
sign-out takes effect in Strapi 5.62 (next request, no access-token wait),
the Super Admin guard, privacy, troubleshooting, FAQ and how to run the
real-HTTP suite. New README screenshots use absolute URLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follows the 4.13.1 README rules (absolute Pages image URLs, at most eight
screenshots): the Admin panel view replaces the Analytics shot in the
README; the sessions dialog, confirmation, signed-out view, dark mode and
phone layout are in the Pages gallery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synthetic screenshots from the isolated Strapi 5.62.0 host (packed
tarball, egress blocked) and the gate with test, browser matrix, click-path,
keyboard, locale and console evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Schero94
Schero94 merged commit a088b03 into main Nov 18, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 18, 2026
# [4.14.0](v4.13.1...v4.14.0) (2026-11-18)

### Features

* see and sign out Strapi admin panel sessions ([#22](#22)) ([a088b03](a088b03))

Release type: minor (`feat`), no breaking change. Existing routes, responses, numbers, widgets, settings and Content API features are unchanged. No migration needed.

### Added

* **Admin panel sessions.** A new **Admin panel** view on the Session Manager page (`/admin/plugins/magic-sessionmanager/admin-panel`), next to the app-user dashboard, shows who can use the Strapi admin panel and who is signed in: every admin with roles, status (Signed in, Not signed in, Deactivated, Invited), last activity and the signed-in browsers (Strapi's device label, signed in, last active, latest end, "This browser", "Remember me"). Search, a sign-in status filter and pagination run on the server. All five languages.
* **Sign admins out.** **Sign out** (one browser) and **Sign out everywhere**, each confirmed. Strapi 5.62 checks the admin session on every admin request, so the admin is signed out on their next click and lands on the login page; there is no waiting for the access token to expire. The plugin deletes every Strapi session record of the browser, so older access tokens of rotated records stop working too. Signing yourself out of the current browser shows a warning. **Manage in Settings** links to Strapi's Settings › Users to deactivate an account.
* Admin routes `GET /magic-sessionmanager/admin-sessions/admins`, `GET /magic-sessionmanager/admin-sessions/admins/:adminId/sessions`, `POST /magic-sessionmanager/admin-sessions/admins/:adminId/sessions/:sessionId/sign-out` and `POST /magic-sessionmanager/admin-sessions/admins/:adminId/sign-out-everywhere` (contracts in the README).
* RBAC actions `plugin::magic-sessionmanager.admin-sessions.read` ("Read admin panel sessions") and `plugin::magic-sessionmanager.admin-sessions.revoke` ("Sign out admins"), granted to Super Admin only by default.

### Security

* Sign-outs need a signed-in administrator (admin API tokens get 403), are limited to 10 per minute per admin, and write one info log line with admin ids and counts only (`[magic-sessionmanager] Admin sign-out: actor=… target=… scope=one|all ended=…`), plus the Strapi event `magic-sessionmanager.admin-sessions.signed-out`.
* An admin without the Super Admin role cannot sign out a Super Admin (403 `super-admin-protected`), so the last active Super Admin can never be signed out by someone else.
* A session id that is not a live session of the given admin answers 404, like an unknown id. Responses never contain tokens, device ids or password fields. The plugin stores nothing about admins; Strapi records no IP address for admin sessions.

### Changed

* Admin session rows (`origin = 'admin'`) stay out of every app-user number; regression tests now cover the dashboard statistics, the untracked-session count and the widget totals with admin sessions present.

### Tests

* Real-HTTP suite `tests/isolated-admin-sessions-http.test.js` on SQLite and PostgreSQL: admins sign in through `POST /admin/login`; listing, sign-out of one browser and everywhere, self sign-out, Super Admin guard, RBAC denials, rate limit, rejected next request and refresh. New CI job runs it, plus the existing HTTP access suite in both JWT modes, against the Strapi 5.62 devDependencies (`@strapi/plugin-users-permissions` is now a devDependency).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant