strapi-plugin-magic-sessionmanager 4.12.0 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -2
- package/README.md +53 -11
- package/dist/admin/{Analytics-lP0-RsVd.js → Analytics-BikQQx_J.js} +1 -1
- package/dist/admin/{Analytics-C_c24Uzq.mjs → Analytics-DIY51RI_.mjs} +1 -1
- package/dist/admin/{App-DCyNPn1k.mjs → App-B3vaybSO.mjs} +433 -13
- package/dist/admin/{App-miWDdmdX.js → App-BV1LM9Bp.js} +433 -13
- package/dist/admin/{OnlineUsersWidget-C6wlwENC.mjs → OnlineUsersWidget-T-2upsDd.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-C6b7e4jb.js → OnlineUsersWidget-fJogM1xl.js} +1 -1
- package/dist/admin/{Settings-D9zyn5xn.js → Settings-AyYka8wn.js} +1 -1
- package/dist/admin/{Settings-DssYw2W4.mjs → Settings-BpBlXyMY.mjs} +1 -1
- package/dist/admin/{de--yNl7MPl.mjs → de-BSCDuq1i.mjs} +38 -1
- package/dist/admin/{de-DjPEATFf.js → de-z0aHRwdw.js} +38 -1
- package/dist/admin/{en-5U7g51cH.mjs → en-B4Cuq9JN.mjs} +38 -1
- package/dist/admin/{en-BoO12UQw.js → en-BWPOiiMt.js} +38 -1
- package/dist/admin/{es-BLpEuycJ.js → es-CMskkUh-.js} +38 -1
- package/dist/admin/{es-BJR-zCXL.mjs → es-DBAmysKi.mjs} +38 -1
- package/dist/admin/{fr-CeeCYQCs.mjs → fr-BNGdtjEl.mjs} +38 -1
- package/dist/admin/{fr-BE828R9Q.js → fr-ClJ2BkrE.js} +38 -1
- package/dist/admin/{index-CfQOMZVX.js → index-DyE1rLW0.js} +22 -19
- package/dist/admin/{index-rbxJZcLv.mjs → index-mCVi1j7e.mjs} +22 -19
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-BWEFiuvo.js → pt-CRh_J7JS.js} +38 -1
- package/dist/admin/{pt-CorrU3yG.mjs → pt-Cl7TWsOV.mjs} +38 -1
- package/dist/server/index.js +721 -30
- package/dist/server/index.mjs +721 -30
- package/package.json +10 -2
- package/pics/untracked-confirm-dialog.webp +0 -0
- package/pics/untracked-disclosure-warning-dark.webp +0 -0
- package/pics/untracked-disclosure-warning.webp +0 -0
- package/pics/untracked-mobile-notice-warning.webp +0 -0
- package/pics/untracked-notice-neutral.webp +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
# [4.13.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.12.0...v4.13.0) (2026-11-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* explain and diagnose untracked Strapi sessions, link sign-ins outside intercepted routes ([#15](https://github.com/Schero94/Magic-Sessionmanager/issues/15)) ([0a8d584](https://github.com/Schero94/Magic-Sessionmanager/commit/0a8d584c1c802c61b412f581c8317a64a77fb336))
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
Release type: minor (`feat` and `fix`), no breaking change. No migration needed; existing routes and responses are unchanged, `GET /sessions/stats` gains one field.
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
* **Strapi sessions created outside Strapi's own REST auth routes are now linked** (`jwtManagement: 'refresh'`). They used to stay without session details and showed up in the "open Strapi sessions" notice:
|
|
15
|
+
* hosts with a custom REST prefix (`api.rest.prefix`, for example `/v1`): no login, refresh, password change or logout was tracked;
|
|
16
|
+
* the GraphQL `login`, `register` and `emailConfirmation` mutations;
|
|
17
|
+
* custom login routes and other plugins that create a session with `strapi.sessionManager('users-permissions')` or the refresh-mode `jwt.issue()` and return the token in the response;
|
|
18
|
+
* intercepted routes whose response carries only an access token (refresh-mode `jwt.issue()`); they no longer fail closed, and an unawaited `jwt.issue()` Promise is resolved so the client gets a real token instead of `{}`.
|
|
19
|
+
* A sign-in that the plugin failed closed (503) before its Strapi session was resolved no longer leaves that Strapi session open.
|
|
20
|
+
* The untracked-session count no longer includes sessions past their absolute expiry (`absoluteExpiresAt`), which Strapi already rejects.
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
* `GET /magic-sessionmanager/sessions/native-only/summary` (admin, `plugin::magic-sessionmanager.access`, read rate limit): count-only diagnostics of untracked Strapi sessions. Created before or after this plugin started tracking, per creation month, by how Strapi created them (sign-in with device details, password change or reset, token only), by device class (from Strapi's device label, first 2,000 rows) and expiring within 7 and 30 days. No session IDs, user data or IP addresses.
|
|
25
|
+
* `POST /magic-sessionmanager/sessions/native-only/end` (admin, `plugin::magic-sessionmanager.access`, signed-in administrators only, 5 requests per minute): ends untracked Users & Permissions sessions in batches of 200, at most 5,000 per request, and reports how many remain. Strapi administrator sessions, sessions listed in the plugin and sessions younger than two minutes are never touched. Logged with counts only.
|
|
26
|
+
* `GET /sessions/stats` returns `nativeOnlyAfterTracking`: untracked sessions created after the tracking start, or `null` when unknown. The tracking start is stored once at startup in refresh mode (plugin store key `nativeTracking`): the login time of the oldest linked session, or the first start of this version.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
* **Untracked-session notice on the dashboard.** The blue notice "N open Strapi sessions have no session details" is replaced. It now says these are still-valid Strapi sign-ins (refresh tokens) that are not in the list and are not active or online sessions. It is neutral when every one predates tracking (legacy, expires on its own) and a warning, "possible tracking gap", when any was created afterwards. "Why?" opens the summary; "End these sessions" ends them after a confirmation. "How sessions work" explains untracked sign-ins. All five languages.
|
|
31
|
+
|
|
32
|
+
### Known limits
|
|
33
|
+
|
|
34
|
+
* A session whose token never appears in the response that created it (a token sent by email or another channel, stored server-side, created by a background job) cannot be linked. It stays untracked and counts as "created after tracking". Return Strapi's `{ jwt, refreshToken }` from custom login code, or end such sessions from the dashboard.
|
|
35
|
+
|
|
1
36
|
# [4.12.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.11.0...v4.12.0) (2026-11-10)
|
|
2
37
|
|
|
3
38
|
|
|
@@ -5,9 +40,9 @@
|
|
|
5
40
|
|
|
6
41
|
* **sessions:** page, filter and count sessions on the server ([#9](https://github.com/Schero94/Magic-Sessionmanager/issues/9)) ([c389614](https://github.com/Schero94/Magic-Sessionmanager/commit/c38961432d4415ded4b9c37c80414dbe787e518a))
|
|
7
42
|
|
|
8
|
-
|
|
43
|
+
### 4.12.0 details
|
|
9
44
|
|
|
10
|
-
|
|
45
|
+
No breaking change. Callers of `GET /sessions` without paging parameters get the same response as before.
|
|
11
46
|
|
|
12
47
|
### Changed
|
|
13
48
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/Schero94/Magic-Sessionmanager/main/docs/site/img/icon.svg" alt="Magic Session Manager icon" width="96" height="96" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# Magic Session Manager
|
|
2
6
|
|
|
3
7
|
**See who is signed in to your Strapi 5 app, end any session in one click, and stop password guessing before it reaches your users.**
|
|
@@ -121,6 +125,14 @@ All screenshots use synthetic data: users `*.example.test`, IP addresses from th
|
|
|
121
125
|
|
|
122
126
|

|
|
123
127
|
|
|
128
|
+
### Untracked Strapi sign-ins (refresh mode)
|
|
129
|
+
|
|
130
|
+

|
|
131
|
+
|
|
132
|
+

|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
124
136
|
### Mobile (390 px)
|
|
125
137
|
|
|
126
138
|
<p>
|
|
@@ -183,7 +195,7 @@ All screenshots use synthetic data: users `*.example.test`, IP addresses from th
|
|
|
183
195
|
- **Table:** Status (badge and a second line, for example "Ended manually · {date}"), User, Device, IP address, Signed in, Last active and the row actions **View details**, **End session** (disabled on ended rows) and **More actions › Delete record**. Clicking a row opens the details.
|
|
184
196
|
- Filters, search, page and page size are kept in the URL, so `?search=<email>` is a shareable link.
|
|
185
197
|
- Search, filters, sorting and paging run on the server, so the list, the counts and the page numbers cover every session, however many there are. Only the 25 to 100 rows on the screen are loaded.
|
|
186
|
-
- In `refresh` mode,
|
|
198
|
+
- In `refresh` mode, a notice above the cards counts **untracked Strapi sign-ins**: refresh tokens Strapi still accepts that have no session details from this plugin. They are not in the list and are not active or online sessions; each user's sessions panel lists them. The notice is neutral when all of them were created before this plugin started tracking, and a warning ("Possible tracking gap") when any was created afterwards. **Why?** opens a count-only summary; **End these sessions** ends them after a confirmation. See [Untracked Strapi sessions](#untracked-strapi-sessions).
|
|
187
199
|
- Below the large breakpoint the IP address and Signed in columns are hidden; below the medium breakpoint the table becomes a card list.
|
|
188
200
|
|
|
189
201
|
### Session details
|
|
@@ -286,6 +298,31 @@ Session Manager supports Users & Permissions end-user sessions in both the nativ
|
|
|
286
298
|
|
|
287
299
|
In this mode Strapi issues, rotates and revokes native sessions. Session Manager uses that state for end-user sessions and keeps its own metadata and history (device, IP address, location, security score). It does not issue or rotate a second token family. Rows created natively without a Session Manager record can appear with a `native_` ID; the admin marks them as "Strapi session", and their device, IP address and location are shown as "—" ("Not recorded").
|
|
288
300
|
|
|
301
|
+
### Untracked Strapi sessions
|
|
302
|
+
|
|
303
|
+
Strapi keeps its own session table (`admin::session`). The plugin links each Users & Permissions session it sees to a session record. A session without a record is **untracked**: its refresh token still works until it expires (Strapi defaults: 14 days idle, 30 days at most), but it is not in the dashboard list and never counts as active or online. The dashboard notice shows how many there are; the number counts unexpired refresh tokens, not people.
|
|
304
|
+
|
|
305
|
+
Which sign-ins are linked (tested with Strapi 5.61 on SQLite and PostgreSQL, `/api` and a custom `api.rest.prefix`):
|
|
306
|
+
|
|
307
|
+
| How the session is created | Linked |
|
|
308
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
|
|
309
|
+
| `POST /auth/local`, `/auth/local/register`, `GET /auth/:provider/callback`, `POST /auth/refresh` (the rotated session), `/auth/change-password`, `/auth/reset-password` | Yes, under any REST prefix |
|
|
310
|
+
| `GET /auth/email-confirmation` | Creates no session (redirects) |
|
|
311
|
+
| GraphQL `login`, `register`, `emailConfirmation` mutations | Yes |
|
|
312
|
+
| Custom routes or other plugins that call `strapi.sessionManager('users-permissions')` or the refresh-mode `jwt.issue()` and **return the token in the response** (`jwt`) | Yes, from the access token in the response |
|
|
313
|
+
| Code that **does not return the token** in the response that created it (token sent by email or another channel, stored server-side, created by a cron job or script) | **No.** The plugin cannot see which client holds it. It stays untracked. |
|
|
314
|
+
| Sessions created before this plugin started linking sessions | No; they expire on their own |
|
|
315
|
+
|
|
316
|
+
For the last two rows: return Strapi's `{ jwt, refreshToken }` (or the refresh cookie) from custom login code so the plugin can link it, or end untracked sessions from the dashboard.
|
|
317
|
+
|
|
318
|
+
**Reading the summary** (`GET /magic-sessionmanager/sessions/native-only/summary`, also behind **Why?**):
|
|
319
|
+
|
|
320
|
+
- `beforeTracking` / `afterTracking`: created before or after `trackingSince`, the date from which the plugin links sessions (stored once at startup as the login time of the oldest linked session, or the first start of this version). Only `beforeTracking` > 0: legacy rows, nothing to do; they disappear within the refresh-token lifetime. `afterTracking` > 0 and growing: a sign-in path the plugin does not see.
|
|
321
|
+
- `bySource`: `signIn` rows carry Strapi's sign-in details (local, register, provider callback, GraphQL login), `passwordChange` rows come from a password change or reset, `tokenOnly` rows from `jwt.issue()` or custom code. A growing `afterTracking` with `tokenOnly` points at custom code or another plugin; with `signIn`, at a login route on a path the plugin does not intercept that does not return the token.
|
|
322
|
+
- `byMonth`, `earlier`, `byDevice` (desktop, mobile, unknown, from Strapi's device label over at most 2,000 rows), `expiring.within7Days` / `within30Days`.
|
|
323
|
+
|
|
324
|
+
**Ending them** (`POST /magic-sessionmanager/sessions/native-only/end`, **End these sessions**) deletes untracked Users & Permissions rows from Strapi's session table, so their refresh tokens stop working; access tokens already issued run out within Strapi's access-token lifetime (10 minutes by default). Strapi administrator sessions, sessions listed in the plugin and sessions younger than two minutes are never touched. At most 5,000 per request; the response says how many remain.
|
|
325
|
+
|
|
289
326
|
### `legacy-support` mode
|
|
290
327
|
|
|
291
328
|
With `jwtManagement: 'legacy-support'`, Session Manager keeps its plugin-owned session behavior. It does not switch the host to refresh mode or migrate existing session records.
|
|
@@ -591,6 +628,8 @@ Prefix `/magic-sessionmanager` (Strapi admin API). Every route requires an authe
|
|
|
591
628
|
| GET | `/sessions` | Sessions dashboard: `?page=&pageSize=` (1-100), `status`, `reason`, `search`, `sort`; see below |
|
|
592
629
|
| GET | `/sessions/active` | Active sessions only; same paging parameters |
|
|
593
630
|
| GET | `/sessions/stats` | Dashboard cards and widget: counts only, cached 5 seconds per process |
|
|
631
|
+
| GET | `/sessions/native-only/summary` | **Why?** on the untracked-session notice: counts only, no query parameters (400 otherwise) |
|
|
632
|
+
| POST | `/sessions/native-only/end` | **End these sessions**: empty body; signed-in administrators only (admin API tokens get 403); 5 per minute |
|
|
594
633
|
| GET | `/sessions/analytics` | Analytics page: counts and grouped counts over every session, cached 30 seconds |
|
|
595
634
|
| GET | `/sessions/export` | Export batches of up to 1,000 rows, newest first; follow `meta.nextCursor` |
|
|
596
635
|
| GET | `/user/:userId/sessions` | Sessions panel |
|
|
@@ -609,7 +648,9 @@ Prefix `/magic-sessionmanager` (Strapi admin API). Every route requires an authe
|
|
|
609
648
|
|
|
610
649
|
**Session list parameters.** `page` (from 1), `pageSize` (1-100), `status` (`all`, `open`, `active`, `idle`, `ended`), `reason` (with `status=ended`: `logout`, `idle`, `expired`, `manual`, `blocked`, `unrecorded`), `search` (up to 100 characters; matches email, username, IP address, browser, operating system and device type) and `sort` (`loginTime:desc`, `loginTime:asc`, `lastActive:desc`, `lastActive:asc`). The response is `{ data, meta: { pagination: { page, pageSize, total, pageCount } } }` with exact totals. Unknown or out-of-range parameters return 400. Pages that start after the first 50,000 matching sessions return 400; narrow the filter or use the export, which walks every row with a cursor. Without `page` and `pageSize`, `GET /sessions` keeps the 4.x response (latest 1,000 rows, `meta.truncated`) for existing scripts.
|
|
611
650
|
|
|
612
|
-
|
|
651
|
+
Both untracked-session routes use the same `plugin::magic-sessionmanager.access` permission as **End session**; the plugin has no separate read-only permission. `POST /sessions/native-only/end` returns `{ data: { ended, remaining, limit } }` and writes one log line with the counts only, 409 while another clean-up runs.
|
|
652
|
+
|
|
653
|
+
The list, statistics, analytics, export, untracked-session summary and `/users/stats` routes share the read rate limit (120 requests per minute per admin, raise it with `rateLimitReadMax`).
|
|
613
654
|
|
|
614
655
|
**Block / unblock** (`toggle-block`): send `{ "blocked": true }` or `{ "blocked": false }`. This sets the state, is safe to retry and is what the admin UI sends. A request without a body still toggles, but is deprecated, because a retry after a lost response can reverse the intended state. A non-boolean `blocked` returns 400. The response contains `blocked` and `mode` (`explicit` or `toggle`). Blocking ends all open sessions with the reason `blocked`; if that fails, the response is 500 and the request can be retried.
|
|
615
656
|
|
|
@@ -808,15 +849,16 @@ The plugin sits in the request path of every authenticated Content API call, so
|
|
|
808
849
|
|
|
809
850
|
## Troubleshooting
|
|
810
851
|
|
|
811
|
-
| Problem | Fix
|
|
812
|
-
| --------------------------------------------------------------------- |
|
|
813
|
-
| No Session Manager menu item | Check `config/plugins.ts`, run `npm run build`, restart, hard-refresh the browser. For non-Super-Admin roles, grant "Access the Session Manager plugin".
|
|
814
|
-
| No sessions appear | Only end-user sign-ins through Users & Permissions are recorded, not Strapi admin sign-ins. Check the Strapi log.
|
|
815
|
-
| Startup fails with `SESSION_ENCRYPTION_KEY is required in production` | Set the variable and restart.
|
|
816
|
-
| 401 on every request after a sign-in | Check the `X-Session-Terminated-Reason` header. With Strict token check, tokens without a session record are rejected.
|
|
817
|
-
| 429 on sign-in | Temporary IP lockout. Wait 15 minutes or raise `maxFailedLogins`. Behind a proxy, turn on Trust proxy headers so the lockout targets the real client. With `Retry-After: 1`: more sign-ins from one address were running at once than `maxFailedLogins`; retry after a second.
|
|
818
|
-
| Location is always "—" | IP location lookup is off, the provider is `disabled`, or `local-mmdb` has no database. See Configuration › Location data.
|
|
819
|
-
|
|
|
852
|
+
| Problem | Fix |
|
|
853
|
+
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
854
|
+
| No Session Manager menu item | Check `config/plugins.ts`, run `npm run build`, restart, hard-refresh the browser. For non-Super-Admin roles, grant "Access the Session Manager plugin". |
|
|
855
|
+
| No sessions appear | Only end-user sign-ins through Users & Permissions are recorded, not Strapi admin sign-ins. Check the Strapi log. |
|
|
856
|
+
| Startup fails with `SESSION_ENCRYPTION_KEY is required in production` | Set the variable and restart. |
|
|
857
|
+
| 401 on every request after a sign-in | Check the `X-Session-Terminated-Reason` header. With Strict token check, tokens without a session record are rejected. |
|
|
858
|
+
| 429 on sign-in | Temporary IP lockout. Wait 15 minutes or raise `maxFailedLogins`. Behind a proxy, turn on Trust proxy headers so the lockout targets the real client. With `Retry-After: 1`: more sign-ins from one address were running at once than `maxFailedLogins`; retry after a second. |
|
|
859
|
+
| Location is always "—" | IP location lookup is off, the provider is `disabled`, or `local-mmdb` has no database. See Configuration › Location data. |
|
|
860
|
+
| Notice "Strapi sign-ins are not tracked" | These are unexpired Strapi refresh tokens without session details, not online users. Open **Why?**: only "Before tracking" means legacy rows that expire on their own; a growing "After tracking" means a sign-in path that does not return its token. See [Untracked Strapi sessions](#untracked-strapi-sessions). |
|
|
861
|
+
| Numbers differ from 4.x | The widget and Analytics now count Active and Idle by the configured inactivity timeout; "Online now" is now "Active sessions". |
|
|
820
862
|
|
|
821
863
|
The plugin stores sessions in the `magic_sessions` table and revocations in its own revoked-token table.
|
|
822
864
|
|
|
@@ -9,7 +9,7 @@ const styled = require("styled-components");
|
|
|
9
9
|
const designSystem = require("@strapi/design-system");
|
|
10
10
|
const icons = require("@strapi/icons");
|
|
11
11
|
const symbols = require("@strapi/icons/symbols");
|
|
12
|
-
const index = require("./index-
|
|
12
|
+
const index = require("./index-DyE1rLW0.js");
|
|
13
13
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -7,7 +7,7 @@ import styled from "styled-components";
|
|
|
7
7
|
import { Typography, Flex, LinkButton, Button, EmptyStateLayout, VisuallyHidden } from "@strapi/design-system";
|
|
8
8
|
import { ArrowClockwise, ChartBubble, User, Clock, Calendar } from "@strapi/icons";
|
|
9
9
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
10
|
-
import { J as normalizeDeviceType, u as useSessionFormatters, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, v as PageShell, w as StatGrid, x as StatCard, F as EqualGrid, b as getTranslation, K as getDeviceTypeMessage } from "./index-
|
|
10
|
+
import { J as normalizeDeviceType, u as useSessionFormatters, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, v as PageShell, w as StatGrid, x as StatCard, F as EqualGrid, b as getTranslation, K as getDeviceTypeMessage } from "./index-mCVi1j7e.mjs";
|
|
11
11
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
12
12
|
const ANALYTICS_UNKNOWN_KEY = "unknown";
|
|
13
13
|
const VERSION_TOKEN = /^v?\d[\w.]*$/i;
|