Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,49 @@ jobs:
run: |
node --test tests/isolated-http-access.test.js
SESSION_HTTP_MODE=refresh node --test tests/isolated-http-access.test.js

strapi-floor:
name: Real Strapi HTTP suites on the peer floor (Strapi 5.50.0)
runs-on: ubuntu-latest
timeout-minutes: 25

steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
cache: npm

- name: Install dependencies
run: npm ci --legacy-peer-deps

# package.json peers: @strapi/strapi and @strapi/plugin-users-permissions ^5.50.0.
# 5.50.0 added sessionManager listSessions/revokeSessionById and admin session
# metadata; the suites below fail on 5.49.0 and older.
- name: Install the Strapi 5.50.0 floor host
run: |
mkdir -p "$RUNNER_TEMP/strapi-floor"
cd "$RUNNER_TEMP/strapi-floor"
echo '{"name":"strapi-floor-host","version":"0.0.0","private":true}' > package.json
npm install --no-audit --no-fund --legacy-peer-deps @strapi/strapi@5.50.0 @strapi/plugin-users-permissions@5.50.0 better-sqlite3@13 jsonwebtoken
for pkg in strapi core admin plugin-users-permissions; do
version=$(node -p "require('./node_modules/@strapi/$pkg/package.json').version")
echo "@strapi/$pkg $version"
test "$version" = 5.50.0
done

- name: HTTP suites on Strapi 5.50.0
env:
SESSION_HTTP_REQUIRED: '1'
SESSION_HTTP_STRAPI_NODE_MODULES: ${{ runner.temp }}/strapi-floor/node_modules
run: |
node --test tests/isolated-http-access.test.js
SESSION_HTTP_MODE=refresh node --test tests/isolated-http-access.test.js
SESSION_HTTP_FALLBACK=1 node --test tests/isolated-http-access.test.js
node --test tests/isolated-admin-sessions-http.test.js
node --test tests/isolated-native-capture-http.test.js
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [Unreleased]

Release type: patch (`fix`). This corrects an untested compatibility claim; it is not a breaking change, because the plugin never worked fully on the Strapi versions now excluded.

### Fixed

* **Strapi peer floor corrected from `^5.0.0` to `^5.50.0`** (`@strapi/strapi` and `@strapi/plugin-users-permissions`). The old range was never tested. Strapi 5.50.0 added the session-manager methods the plugin calls (`listSessions`, `revokeSessionById`) and the `metadata` column of `admin::session` ([strapi/strapi#26628](https://github.com/strapi/strapi/pull/26628)). Measured with the real-HTTP suites on isolated hosts: on 5.24.0, 5.30.0, 5.40.0, 5.45.0 and 5.49.0, sign-in with `jwtManagement: 'refresh'` fails closed with 503, session list and revoke routes fail, and the Admin panel sessions routes return 500 in both JWT modes; 5.0.4 and 5.23.6 have no session manager or `admin::session` at all; 5.0.0 to 5.0.3 declare Node.js 20 or older, outside this plugin's `engines`. On 5.50.0 and 5.62.0 every suite passes.
* The plugin logs one clear error at start-up on Strapi older than 5.50.0 (`Strapi 5.x.y is not supported: Magic Session Manager requires Strapi 5.50.0 or later …`) instead of failing later on single requests.
* README badge, Compatibility table and project site now say Strapi 5.50+.

### Upgrade note

* Strapi 5.50.0 or later: nothing to do.
* Strapi older than 5.50.0: upgrade Strapi first (`npx @strapi/upgrade minor`), rebuild the admin and restart. npm 7+ refuses to install this release next to an older Strapi because of the peer range; until you upgrade Strapi, stay on your current plugin version.

### Tests

* New CI job `strapi-floor` installs Strapi 5.50.0 and Users & Permissions 5.50.0 into a separate directory and runs the HTTP access suite (legacy, refresh, fallback logout), the admin panel sessions suite and the native session capture suite against it.
* `tests/strapi-version-floor.test.js` checks the floor constant, the start-up error, that the peers and the CI job name the same floor.
* The native capture suite's provider-callback case now also sends the provider token in the query string, which Strapi 5.50 reads (5.62 reads the grant session), so it runs on both versions.

# [4.14.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.13.1...v4.14.0) (2026-11-18)


Expand Down
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Free and open source under the MIT license. Every feature works without an accou
[![npm downloads](https://img.shields.io/npm/dm/strapi-plugin-magic-sessionmanager.svg)](https://www.npmjs.com/package/strapi-plugin-magic-sessionmanager)
[![CI build status](https://img.shields.io/github/actions/workflow/status/Schero94/Magic-Sessionmanager/test.yml?branch=main&label=CI&logo=github)](https://github.com/Schero94/Magic-Sessionmanager/actions/workflows/test.yml?query=branch%3Amain)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Schero94/Magic-Sessionmanager/blob/main/LICENSE)
[![Strapi 5.0+](https://img.shields.io/badge/Strapi-5.0%2B-4945FF.svg)](https://github.com/Schero94/Magic-Sessionmanager#compatibility)
[![Strapi 5.50+](https://img.shields.io/badge/Strapi-5.50%2B-4945FF.svg)](https://github.com/Schero94/Magic-Sessionmanager#compatibility)
[![Documentation site](https://img.shields.io/badge/docs-project%20site-6d4aff.svg)](https://schero94.github.io/Magic-Sessionmanager/)

Live docs: [https://schero94.github.io/Magic-Sessionmanager/](https://schero94.github.io/Magic-Sessionmanager/) · [npm](https://www.npmjs.com/package/strapi-plugin-magic-sessionmanager) · [Changelog](https://github.com/Schero94/Magic-Sessionmanager/blob/main/CHANGELOG.md) · [Report a bug](https://github.com/Schero94/Magic-Sessionmanager/issues/new/choose) · [Discussions](https://github.com/Schero94/Magic-Sessionmanager/discussions)
Expand Down Expand Up @@ -224,7 +224,7 @@ Shown on the edit view of a Users & Permissions user only.

### Online users widget

Strapi 5.13 and later. Four tiles: **Online users** (of all registered users), **Active sessions**, **Idle sessions** and **Blocked users**, plus a link **Open Session Manager**. The widget refreshes every 30 seconds.
Part of every supported Strapi version (the widgets API exists since Strapi 5.13). Four tiles: **Online users** (of all registered users), **Active sessions**, **Idle sessions** and **Blocked users**, plus a link **Open Session Manager**. The widget refreshes every 30 seconds.

### Settings › Session Manager

Expand All @@ -248,17 +248,17 @@ Two links: **Configuration** and **Analytics**.

## Compatibility

| Item | Supported |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Strapi | 5 (`@strapi/strapi` peer range `^5.0.0`). Acceptance host: Strapi 5.62.0. |
| Node.js | `^22.22.2 \|\| >=24.15.0` (`engines.node`) |
| Users & Permissions | `jwtManagement: 'refresh'` and `'legacy-support'` |
| Homepage widget | Strapi 5.13 and later (older versions have no widgets API; the rest works) |
| Admin panel sessions | Strapi 5 with Strapi's session manager (`strapi.sessionManager`, admin origin); tested with 5.62.0. Without it the view says it is not available and the sign-out routes return 503. |
| Required peers | `@strapi/strapi` `^5.0.0`, `@strapi/plugin-users-permissions` `^5.0.0`, `react` / `react-dom` `^18.0.0`, `react-router-dom` `^6.0.0`, `styled-components` `^6.0.0`. A new Strapi 5 app already has all of them. |
| Optional peers | `@strapi/design-system` `^2.0.0`, `@strapi/icons` `^2.0.0`, `react-intl` `^6.0.0`. Strapi's admin brings them; they are marked optional so npm, Yarn and pnpm do not warn. |
| Package managers | npm, Yarn 1 and pnpm. Installing into a fresh Strapi 5.61 app prints no warning about this plugin. |
| Databases | PostgreSQL, MySQL, SQLite (several processes need PostgreSQL or MySQL, see [Running several instances](#running-several-instances-railway-replicas-pm2-cluster)). |
| Item | Supported |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Strapi | 5.50.0 and later 5.x (`@strapi/strapi` peer range `^5.50.0`). Tested in CI on 5.50.0 (floor) and 5.62.0 (acceptance host). Strapi 5.0 to 5.49 are not supported, see [Upgrading › Strapi older than 5.50](#strapi-older-than-550). |
| Node.js | `^22.22.2 \|\| >=24.15.0` (`engines.node`) |
| Users & Permissions | `jwtManagement: 'refresh'` and `'legacy-support'` |
| Homepage widget | Included (Strapi's widgets API exists since 5.13). |
| Admin panel sessions | Uses Strapi's session manager (`strapi.sessionManager('admin')`) and the device label in `admin::session` metadata, both available from Strapi 5.50.0; tested on 5.50.0 and 5.62.0. |
| Required peers | `@strapi/strapi` `^5.50.0`, `@strapi/plugin-users-permissions` `^5.50.0`, `react` / `react-dom` `^18.0.0`, `react-router-dom` `^6.0.0`, `styled-components` `^6.0.0`. A new Strapi 5 app already has all of them. |
| Optional peers | `@strapi/design-system` `^2.0.0`, `@strapi/icons` `^2.0.0`, `react-intl` `^6.0.0`. Strapi's admin brings them; they are marked optional so npm, Yarn and pnpm do not warn. |
| Package managers | npm, Yarn 1 and pnpm. Installing into a fresh Strapi 5.61 app prints no warning about this plugin. |
| Databases | PostgreSQL, MySQL, SQLite (several processes need PostgreSQL or MySQL, see [Running several instances](#running-several-instances-railway-replicas-pm2-cluster)). |

---

Expand Down Expand Up @@ -920,6 +920,18 @@ Session history lives in the content-type tables `magic_sessions` and `magic_ses

## Migration and upgrading

### Strapi older than 5.50

Earlier releases said "Strapi 5.0+" (`^5.0.0`) without testing older versions. The real floor is **Strapi 5.50.0**: the plugin calls `listSessions` and `revokeSessionById` on Strapi's session manager and reads the device label in `admin::session` metadata, which Strapi added in 5.50.0 ([strapi/strapi#26628](https://github.com/strapi/strapi/pull/26628)). Measured with this repository's real-HTTP suites:

| Strapi | Result |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 5.0.0 to 5.23.x | No session manager and no `admin::session` table (added in 5.24.0). 5.0.0 to 5.0.3 also declare Node.js 20 or older, outside this plugin's `engines`. |
| 5.24.0 to 5.49.x | With `jwtManagement: 'refresh'`, sign-in fails closed with 503 and session routes fail; the Admin panel view returns 500 in both modes. |
| 5.50.0, 5.62.0 | All suites pass (both JWT modes, the fallback logout, admin panel sessions, native session capture); the packed plugin installs without peer warnings and the admin panel builds on 5.50.0. |

On Strapi below 5.50.0 the plugin logs one error at start-up (`Strapi 5.x.y is not supported: Magic Session Manager requires Strapi 5.50.0 or later …`). Upgrade Strapi to 5.50.0 or later ([Strapi upgrade tool](https://docs.strapi.io/cms/upgrade-tool)), rebuild the admin and restart. If you cannot upgrade Strapi yet, stay on your current plugin version; it never worked fully on those versions either.

### To the next release (license removal, from 4.10.x)

Nothing to do for most apps.
Expand Down Expand Up @@ -963,6 +975,8 @@ SESSION_HTTP_REQUIRED=1 SESSION_HTTP_STRAPI_NODE_MODULES=$PWD/node_modules node
# PostgreSQL: add SESSION_HTTP_DB=postgres MSM_TEST_PG_URL=postgres://user:pass@127.0.0.1:5432/db
```

CI runs the same suites a second time against Strapi 5.50.0, the peer floor, installed into a separate directory (`SESSION_HTTP_STRAPI_NODE_MODULES=<dir>/node_modules`), so the floor stays tested.

The admin panel suite signs synthetic admins in through `POST /admin/login` and checks listing, signing out one browser and everywhere, self sign-out, the Super Admin guard, RBAC denials, the rate limit, that the next request and the refresh are rejected, and that admin sessions never reach the app-user numbers.

Quick manual check: sign in to your app as an end user (`POST /api/auth/local`), open Session Manager and find the session as **Active**, click **End session** and confirm, then call any Content API route with the same token: it returns 401 and the row shows **Ended · Ended manually**.
Expand Down
11 changes: 7 additions & 4 deletions docs/site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ <h1 id="page-title">See who is signed in. End access in one click.</h1>
/></a>
<a href="https://github.com/Schero94/Magic-Sessionmanager#compatibility"
><img
src="https://img.shields.io/badge/Strapi-5.0%2B-4945FF.svg"
alt="Strapi 5.0+"
src="https://img.shields.io/badge/Strapi-5.50%2B-4945FF.svg"
alt="Strapi 5.50+"
height="20"
/></a>
<a href="https://schero94.github.io/Magic-Sessionmanager/"
Expand Down Expand Up @@ -1113,7 +1113,10 @@ <h2 id="compatibility-title">Compatibility</h2>
<tbody>
<tr>
<th scope="row">Strapi</th>
<td>5 (<code>@strapi/strapi ^5.0.0</code>); acceptance host Strapi 5.62.0</td>
<td>
5.50.0 and later 5.x (<code>@strapi/strapi ^5.50.0</code>); tested on 5.50.0 and
5.62.0 (acceptance host)
</td>
</tr>
<tr>
<th scope="row">Node.js</th>
Expand All @@ -1125,7 +1128,7 @@ <h2 id="compatibility-title">Compatibility</h2>
</tr>
<tr>
<th scope="row">Homepage widget</th>
<td>Strapi 5.13 and later</td>
<td>Included</td>
</tr>
<tr>
<th scope="row">Admin languages</th>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"peerDependencies": {
"@strapi/design-system": "^2.0.0",
"@strapi/icons": "^2.0.0",
"@strapi/plugin-users-permissions": "^5.0.0",
"@strapi/strapi": "^5.0.0",
"@strapi/plugin-users-permissions": "^5.50.0",
"@strapi/strapi": "^5.50.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-intl": "^6.0.0",
Expand Down
4 changes: 4 additions & 0 deletions server/src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
const { createLogger } = require('./utils/logger');
const { createContentApiPermissionsLifecycle } = require('./utils/content-api-permissions');
const { isCallerRevocationScope } = require('./utils/block-revocation-scope');
const { checkStrapiVersion } = require('./utils/strapi-version');

const USER_UID = 'plugin::users-permissions.user';

/**
* Plugin register hook.
*
* - Logs one error when the running Strapi is older than the supported floor
* (`MIN_STRAPI_VERSION`, 5.50.0).
* - Registers the `access` RBAC action for admin access control and the
* `admin-sessions.read` / `admin-sessions.revoke` actions for the Strapi
* admin panel sessions view.
Expand All @@ -24,6 +27,7 @@ module.exports = async ({ strapi }) => {
const log = createLogger(strapi);

log.info('[START] Plugin registration starting...');
checkStrapiVersion(strapi, log);

strapi.admin.services.permission.actionProvider.registerMany([
{
Expand Down
Loading
Loading