Magic Session Manager

See who is signed in. End access in one click.

Magic Session Manager is a free, MIT-licensed Strapi 5 plugin that records every Users & Permissions sign-in as a session, so admins can see who is online, end sessions and block accounts.

Your app gets logout routes, a "my devices" list, failed-login lockout and optional country rules. It works with Strapi's native refresh-token sessions and with several server processes on one database.

Used by

Using Magic Session Manager in production? Show your logo here

  • Strapi ^5.50.0
  • Node.js ^22.22.2 or >=24.15.0
  • 5 admin languages
  • MIT, no telemetry

npm version npm downloads CI build status License: MIT Strapi 5.50+ Documentation site

Sessions dashboard: four stat cards (Active, Idle, Ended, All), search, a status filter and a table of sessions with Active, Idle and Ended badges.

Is Magic Session Manager the right fit?

Use it when

  • Your app users sign in through Users & Permissions and you want to see and end their sessions.
  • Your frontend needs "log out", "log out everywhere" and a "my devices" list.
  • You want a lockout after failed sign-ins, rate limits or country rules.
  • You want to see who is signed in to the Strapi admin panel and sign admins out.

Skip it when

  • Your users do not sign in through Users & Permissions.
  • You need to create or edit admin accounts. That stays in Strapi's Settings › Users.
  • Your project runs Strapi older than 5.50.0.
  • You run several processes on SQLite. That setup needs PostgreSQL or MySQL.

Requirements

  • Strapi ^5.50.0 with @strapi/plugin-users-permissions
  • Node.js ^22.22.2 || >=24.15.0
  • PostgreSQL, MySQL or SQLite
  • SESSION_ENCRYPTION_KEY when NODE_ENV=production

Quick start (1 minute)

Install, enable, rebuild. Yarn and pnpm work the same way (yarn add, pnpm add).

  1. Install the package.

    Terminal
    npm install strapi-plugin-magic-sessionmanager
  2. Enable the plugin.

    config/plugins.ts
    export default () => ({
      'magic-sessionmanager': {
        enabled: true,
      },
    });
  3. Set the token encryption key. Production startup fails without it.

    Terminal
    node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
    # add the output to .env as SESSION_ENCRYPTION_KEY="..."
  4. Rebuild the admin and start Strapi.

    Terminal
    npm run build
    npm run develop

Open Session Manager in the main menu. Super Admins have access automatically. For other admin roles, grant Plugins › Session Manager › Access the Session Manager plugin under Settings › Administration Panel › Roles.

Both Users & Permissions modes work: with jwtManagement: 'refresh' Strapi issues and revokes native sessions and the plugin adds device, IP and location history; with 'legacy-support' the plugin keeps its own session records. The plugin never changes the host's authentication configuration.

Features

One vocabulary on every screen. A session is Active (open, used within the inactivity timeout), Idle (open, unused for longer) or Ended. An ended session shows its end reason: Logged out, Timed out, Expired, Ended manually, User blocked or Reason not recorded.

End

The session stops working. The record stays in the history.

Delete record

The record leaves history, statistics and exports. An open session also ends, and its token stays revoked.

Block

The user cannot sign in, and all open sessions end. Unblock allows sign-in again.

A user is Online when at least one of their sessions is Active. The dashboard, the widget and the user panel use this one rule.

Sessions dashboard

Main menu › Session Manager. Header links Analytics and Settings, and an Export menu (CSV or JSON, with an End reason column and no tokens). Four stat cards that filter the list, search by user, email, IP or device, Status and End reason filters, and the row actions View details, End session and More actions › Delete record. Filters and search live in the URL. Below 768 px the table becomes a card list.

Session details

A sentence that says why the session is in its state, then user, session times, device, location and security score. Look up location runs only when you click it. Technical details hold the record ID and the raw user agent. End session asks for confirmation.

Sessions panel on a user

In the Content Manager edit view of a Users & Permissions user: Online or Not online, the number of open sessions and the last activity, End all sessions and Block user with confirmation, the open sessions, and Show all sessions, which opens the dashboard filtered by the user's email.

Online users widget

On the Strapi homepage (Strapi 5.13 and later): Online users out of all registered users, Active sessions, Idle sessions and Blocked users, refreshed every 30 seconds.

Admin panel sessions

Who can use the Strapi admin panel and who is signed in, on which browser and since when. Sign an admin out of one browser or everywhere; it takes effect on their next click. Separate from your app's users, Super Admin only by default.

Admin sign-in history and activity

Every admin sign-in, failed attempt, lockout and sign-out with IP address, browser and location, and who signed out whom. Optionally, which entries each admin opened, created, edited, published or deleted in the Content Manager. Filters, CSV export, IP anonymisation and retention; activity recording is off by default.

Configuration

Settings › Session Manager › Configuration with five tabs: Sessions, Login protection, Location data, Alerts, and Data and retention, plus Admin activity for roles with "View admin activity". Each tab is a deep link (?tab=). Save and Discard changes sit in the header, and leaving with unsaved changes asks first.

Analytics

All and active sessions, sign-ins in the last 24 hours and 7 days, sessions by device and browser, and the average session length.

Routes for your app

My sessions, current session, log out, log out everywhere and log out other devices. Each user only ever sees and ends their own sessions.

Login protection

Temporary IP lockout after failed sign-ins, Content API rate limits, optional rejection of VPN, proxy or low-score sign-ins, and country allow or block lists.

Alerts

Security emails to the user through Strapi's Email plugin, and sign-in notifications to Discord or Slack.

Screenshots

All screenshots show synthetic data on an isolated Strapi 5.61 host: users at example.test, IP addresses from the documentation range 203.0.113.0/24. Select an image to open it at full size.

Mobile, 390 px

Configuration

Static defaults go in config/plugins.ts with time values in milliseconds. Values saved on the Configuration page are stored in the database in minutes, seconds or days and override the static config. Other server processes apply saved changes within 30 seconds.

config/plugins.ts
export default () => ({
  'magic-sessionmanager': {
    enabled: true,
    config: {
      inactivityTimeout: 15 * 60 * 1000, // ms
      lastSeenRateLimit: 30 * 1000,      // ms
      cleanupInterval: 30 * 60 * 1000,   // ms
      maxSessionAgeDays: 30,
      retentionDays: 90,                 // -1 keeps ended sessions forever
      geoIpProvider: 'auto',             // auto | local-mmdb | ipapi | disabled
      geoLookupFailureMode: 'auto',      // auto | allow | block
    },
  },
});
Settings by Configuration tab, with defaults and the ranges accepted on Save
Tab Setting (key) Default Range
Sessions Inactivity timeout (inactivityTimeout) 15 min 1 to 1440 min
Maximum session age (maxSessionAgeDays) 30 days 1 to 365 days
Update "Last active" at most every (lastSeenRateLimit) 30 s 5 to 300 s
Run idle check every (cleanupInterval) 30 min 5 to 1440 min
Token check (strictSessionEnforcement) Relaxed Strict or Relaxed
Grace period after sign-in (sessionCreationGraceMs) 5 s 0 to 30 s
Login protection Temporary IP lockout after (maxFailedLogins) 5 0 to 100, 0 = off
Trust proxy headers (trustedProxies) Off On or off
Reject suspicious sign-ins (blockSuspiciousSessions) Off On or off
Country rules (enableGeofencing, allowedCountries, blockedCountries) Off ISO 3166-1 alpha-2 codes
Location data IP location lookup (enableGeolocation) On On or off
Security scoring (enableSecurityScoring) On On or off
Provider (geoIpProvider) Automatic auto, local-mmdb, ipapi, disabled
Alerts Security emails to users (enableEmailAlerts) Off Needs IP location lookup and Strapi's Email plugin
Team notifications (enableWebhooks, discordWebhookUrl, slackWebhookUrl) Off Discord or Slack URLs only
Data and retention Keep ended sessions for (retentionDays) 90 days 1 to 365 days or Forever (-1)

Retention is checked once a day across all instances, the first time about 5 minutes after the server starts. It deletes records of ended sessions only; open sessions are never deleted by retention. Delete ended sessions on the same tab removes the records of all ended sessions of all users at once. The idle check ends idle sessions as Timed out and deletes nothing.

Environment variables: SESSION_ENCRYPTION_KEY, MAGIC_SESSIONMANAGER_GEOIP_DATABASE (local MaxMind database), MAXMIND_ACCOUNT_ID and MAXMIND_LICENSE_KEY (database updates; they take precedence over stored credentials). The full reference, including Advanced settings and email templates, is in the README.

API and permissions

Content API routes live under /api/magic-sessionmanager, require a Users & Permissions JWT, act on the caller's own sessions only and are rate-limited (10 writes and 120 reads per minute by default, then 429 with Retry-After).

Content API
Method Path Purpose
GET /my-sessions Own sessions, current one first (up to 200)
GET /current-session The session of the current token
GET /user/:userId/sessions Own sessions by user ID; 403 for another user
POST /logout End the current session (Logged out)
POST /logout-all End all own sessions
POST /logout-others End all own sessions except the current one
DELETE /my-sessions/:sessionId End one other own session (Ended manually)

Admin routes live under /magic-sessionmanager in the Strapi admin API. Each one requires an authenticated admin and the permission plugin::magic-sessionmanager.access, which also controls the menu link, settings links, widget and user panel. The admin panel session routes also need plugin::magic-sessionmanager.admin-sessions.read ("Read admin panel sessions"), and signing out plugin::magic-sessionmanager.admin-sessions.revoke ("Sign out admins"). The sign-in history and activity routes also need plugin::magic-sessionmanager.admin-activity.read ("View admin activity"). Only Super Admin has these by default.

Admin API
Method Path Admin action
GET /sessions, /sessions/active Dashboard list: paged on the server (page, pageSize, status, reason, search, sort) with exact totals
GET /sessions/stats, /sessions/analytics Dashboard cards, widget and Analytics: counts over every session
GET /sessions/export Export batches of up to 1,000 rows with a cursor
GET /user/:userId/sessions Sessions panel
POST /sessions/:sessionId/terminate End session
DELETE /sessions/:sessionId Delete record
POST /sessions/clean-inactive Delete ended sessions
POST /user/:userId/terminate-all End all sessions
POST /user/:userId/toggle-block Block user / Unblock user; send { "blocked": true | false }
GET /users/stats Widget totals
GET /geolocation/:ipAddress Look up location
GET, PUT, POST /geoip/status, /geoip/credentials, /geoip/update GeoIP database status, MaxMind credentials, database update
GET, PUT /settings Configuration
GET /admin-sessions/admins, /admin-sessions/admins/:adminId/sessions Admin panel view and View sessions (admin-sessions.read)
POST /admin-sessions/admins/:adminId/sessions/:sessionId/sign-out, /admin-sessions/admins/:adminId/sign-out-everywhere Sign out, Sign out everywhere (admin-sessions.revoke; signed-in admins only; 10 per minute; a delegated role cannot sign out a Super Admin)
GET /admin-activity/sign-ins, /admin-activity/content, and /export under each Sign-in history, Activity and their CSV exports (admin-activity.read; filters for admin, event or action, content type and date range)

Requests with an ended session receive 401 and the header X-Session-Terminated-Reason (logout, manual, idle, expired or blocked). The optional route policy plugin::magic-sessionmanager.session-required adds an explicit check to your own routes. Response shapes and error codes are in the README.

Examples

Synthetic host api.example.test; replace <JWT> with a Users & Permissions token.

"Your devices" list
const res = await fetch('https://api.example.test/api/magic-sessionmanager/my-sessions', {
  headers: { Authorization: `Bearer ${jwt}` },
});
const { data, meta } = await res.json();
// data[0].isCurrentSession === true
Sign out all other devices
curl -X POST https://api.example.test/api/magic-sessionmanager/logout-others \
  -H "Authorization: Bearer <JWT>"
# {"message":"2 other session(s) terminated","terminatedCount":2,"currentSessionPreserved":true}
config/middlewares.js: let browsers read the reason
{ name: 'strapi::cors', config: { expose: ['X-Session-Terminated-Reason'] } }

A request with an ended session gets 401 with X-Session-Terminated-Reason. Cross-origin JavaScript can read that header only when CORS exposes it, as above. More examples are in the README.

Security and privacy

Production requirement: set SESSION_ENCRYPTION_KEY before starting Strapi with NODE_ENV=production; startup fails without it. Keep the key stable, because changing it makes stored tokens unreadable.

Session security

Stored tokens are encrypted with AES-256-GCM and never returned by any route or export. Ended, expired and revoked sessions and blocked users are rejected on every Content API request. A password reset ends all older sessions of the user.

Ownership

Content API routes only return or end the caller's own sessions. A foreign session ID answers exactly like a missing one, so IDs cannot be probed.

Login protection

Applies to new sign-ins only: a temporary 15-minute IP lockout after failed sign-ins (429), rejection of VPN, proxy, threat or low-score sign-ins (403), and country rules (403). Refused sign-ins are not recorded, and user accounts are never blocked by the lockout.

Location data and privacy

IP location lookup is on by default with the Automatic provider, which can send IP addresses to ipapi.co. Choose the local MaxMind database or turn the lookup off to keep IP addresses on your server. The details dialog looks up a location only when you click the button.

Admin sign-in history

The security log stores admin sign-ins with IP address and user agent. The address is Strapi's client IP: behind a proxy set server.proxy.koa and maxIpsCount. Anonymise the last part of IP addresses, set the retention (90 days by default) and keep Content Manager activity off until employees, and in Germany the works council, are informed. Typed emails and passwords are never stored.

Retention

Session records hold IP addresses, user agents and location. Set Keep ended sessions for to match your retention policy; Delete record and Delete ended sessions remove history on demand.

What leaves your server

Only what you turn on: ipapi.co lookups, Discord or Slack webhooks, emails through your own Email provider and the MaxMind download. No telemetry, no install ping and no license check.

Secrets

The MaxMind license key is stored in the plugin store and never sent back to the browser. Webhook URLs accept Discord and Slack hosts only; treat them as secrets.

Signing out an admin deletes Strapi's own session records of that browser (or of every browser). Strapi 5.62 checks the admin session on every admin request, so the admin is signed out on their next click, without waiting for the access token to expire. Admin API tokens are not affected. The plugin stores nothing about admins, and Strapi records no IP address for admin sessions. Every sign-out is logged with admin ids and counts only. To report a vulnerability, do not post exploit details publicly: open a GitHub issue that asks for a private contact, without credentials or personal data.

Running several instances (Railway replicas, pm2 cluster)

Several Strapi processes can share one PostgreSQL or MySQL database, for example two Railway replicas with four pm2 workers each. No sticky sessions and no Redis are needed; the database is the single source of truth.

Shared state across processes
State How it stays consistent
Session validity Read from the database on every request; state changes are conditional updates, so a stale process cannot revive an ended session.
Failed-login lockout, rate limits Atomic shared counters (magic_sm_counters), IP stored as a hash.
Idle cleanup, retention A job lease (magic_sm_leases): one process runs each job.
Settings A shared revision; every process reloads within about 2 seconds.
ipapi.co cache and back-off Shared through magic_sm_cache.
  1. Point every instance at one PostgreSQL or MySQL database.

  2. Use identical secrets everywhere, including SESSION_ENCRYPTION_KEY; the plugin logs an error when instances use different keys.

  3. Behind a proxy, turn on Koa's proxy mode (proxy: { koa: true } in config/server.js) so lockout and rate limits see the client IP.

  4. Start a single process first on an empty database or after a content-type change (Strapi core races on its own tables otherwise), then scale out.

  5. With a local GeoIP database, download it on every instance before start, for example with npx strapi-magic-sessionmanager-geoip.

Measured on Strapi 5.61 with PostgreSQL 16, 4 processes and pm2 cluster mode: 48 parallel wrong passwords from one IP let exactly 5 reach the password check. Full setup, a pm2 ecosystem file and an optional Redis counter store are in the README.

Performance

Per request

One session lookup by token hash, backed by indexes the plugin creates at startup. "Last active" is written at most every 30 seconds per session by default.

Caches

Settings are cached for 30 seconds with a 2-second revision check. ipapi.co results are cached for 24 hours and shared; a local MaxMind database needs no network call.

Bounded work

The dashboard loads only the page on screen and counts every session in SQL, the widget loads counts only, /my-sessions returns at most 200, and retention deletes ended sessions after 90 days by default.

Compatibility

Supported versions
Strapi 5.50.0 and later 5.x (@strapi/strapi ^5.50.0); tested on 5.50.0 and 5.63.0 (acceptance host)
Node.js ^22.22.2 || >=24.15.0
Users & Permissions jwtManagement: 'refresh' and 'legacy-support'
Homepage widget Included
Admin languages English, German, French, Spanish, Portuguese
Required peers @strapi/strapi, @strapi/plugin-users-permissions, react, react-dom, react-router-dom, styled-components: all present in a new Strapi 5 app
Package managers npm, Yarn 1 and pnpm, with no install warning about this plugin
Database PostgreSQL, MySQL or SQLite. Tables magic_sessions, magic_session_revocations and three magic_sm_* coordination tables

FAQ

Does it manage Strapi admin accounts?

It shows who is signed in to the Strapi admin panel and signs admins out (the Admin panel view). Creating, editing and deactivating admins stays in Strapi's Settings › Users. Everything else is about end users of Users & Permissions.

When does signing out an admin take effect?

On the admin's next request, usually their next click: Strapi 5.62 checks the session on every admin request. They can sign in again with their password unless you deactivate the account in Settings › Users.

Do I need a license key, account or activation?

No. Everything is free under MIT and the plugin contacts no license or telemetry server. The only key you may add is your own MaxMind key for the GeoLite2 database.

Do I have to add the session-required policy?

No. Revocation works on every Content API route without configuration. The policy is an optional, explicit per-route check.

Does it work with jwtManagement: 'refresh'?

Yes. Strapi issues, rotates and revokes its own sessions; the plugin adds device, IP address, location and history, and ends the native session when you end it.

What are "untracked Strapi sign-ins" on the dashboard?

Refresh tokens that Strapi still accepts but that have no session details from this plugin, for example sign-ins from before it started tracking, or tokens that custom code created without returning them. They are not in the list and are not active or online sessions. Why? shows a count-only summary (before or after tracking, how Strapi created them, expiry); End these sessions ends them. The README lists which sign-in paths are linked.

Does it send my users' IP addresses anywhere?

Only when location lookup uses ipapi.co (provider ipapi, or auto without a local database). Choose local-mmdb or disabled to keep IP addresses on your server.

Why do sign-ins get 429?

The temporary IP lockout counts failed sign-ins per IP address. Behind a proxy, turn on Koa's proxy mode or Trust proxy headers, otherwise all users share the proxy's address.

Migration and upgrading

To the release with the security log (from 4.14.x)

  • Nothing to do: Strapi creates the table magic_sessions_security_events on first start. Admin sign-ins are recorded from then on; Content Manager activity stays off until you turn it on.
  • Behind a reverse proxy, set server.proxy.koa: true and maxIpsCount, otherwise the proxy's address is stored.
  • The new permission "View admin activity" is held by Super Admin only; grant it to other roles in Settings › Roles.

To the next release (from 4.10.x)

  • The License page and the admin routes under /magic-sessionmanager/license are removed; Settings shows Configuration and Analytics.
  • Stored licenseKey, lastValidated and deviceId values are deleted on first start. MaxMind credentials and settings stay.
  • MAGIC_LICENSE_SERVER_URL and MAGIC_LICENSE_TIMEOUT_MS are no longer read.
  • No change to your package.json or config is needed.

From 3.x (Strapi 4)

Version 4 requires Strapi 5. Upgrade Strapi first with the official upgrade guide, then install the latest 4.x, rebuild the admin and restart. Sessions are addressed by documentId. Details for every 4.x step are in the README.

Releases and maintenance

Actively maintained for Strapi 5. Releases are cut by semantic-release from main and published to npm with npm Trusted Publishing. Use 4.9.0 or later: 4.8.0 was published before its acceptance gates closed and has defects that 4.9.0 fixed.

Quality gates on every release

  • ESLint, Prettier, both type checks and the full unit and HTTP test suite.
  • strapi-plugin verify, a runtime check of the server bundle and npm pack review.
  • An 8-process concurrency suite on SQLite and PostgreSQL 16 in CI.

Known issues outside the plugin

  • The recorded high-severity advisory comes through the Strapi 5 core dependency chain: picomatch (GHSA-fc5q-39xc-vjpf) via @strapi/utils 5.62.0, checked 2026-11-17.
  • No compatible fix exists; the forced npm fix downgrades to Strapi 4, so none was applied.
Local checks
npm ci --legacy-peer-deps
npm test
npm run test:ts:front && npm run test:ts:back
npm run build && npm run verify && npm run verify:runtime