strapi-plugin-magic-sessionmanager 4.16.1 → 4.18.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 +76 -0
- package/README.md +119 -25
- package/dist/admin/{Analytics-CMR62DiD.js → Analytics-C8fV6LDV.js} +1 -1
- package/dist/admin/{Analytics-FcRt0X62.mjs → Analytics-CBspdl1I.mjs} +1 -1
- package/dist/admin/{App-CmytGbze.js → App-D92MTQmn.js} +33 -170
- package/dist/admin/{App-DBieSWB0.mjs → App-PLwqaRSQ.mjs} +3 -140
- package/dist/admin/{OnlineUsersWidget-Lzx9XB74.js → OnlineUsersWidget-CiKapC1B.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-zP9Hl_it.mjs → OnlineUsersWidget-CwfBJdIX.mjs} +1 -1
- package/dist/admin/{Settings-CZOPusQK.mjs → Settings-CMgL-Aub.mjs} +2013 -78
- package/dist/admin/{Settings-1v--SXC0.js → Settings-Duil_4jv.js} +2017 -82
- package/dist/admin/dashboardModel-BhUonEqc.mjs +189 -0
- package/dist/admin/dashboardModel-sksvIc1c.js +188 -0
- package/dist/admin/{de-y_9mdVT7.js → de-CnInuvMY.js} +196 -11
- package/dist/admin/{de-D3TSA066.mjs → de-D2BqfY1f.mjs} +196 -11
- package/dist/admin/{en-B60I97bK.mjs → en-BPy208we.mjs} +196 -11
- package/dist/admin/{en-CIQB8nfI.js → en-KnmmYHTF.js} +196 -11
- package/dist/admin/{es-CJEL_iGC.mjs → es-B4VNeT0A.mjs} +196 -11
- package/dist/admin/{es-DHhHzlRY.js → es-D1NGCAJK.js} +196 -11
- package/dist/admin/{fr-BfBK_iuV.mjs → fr-AwhLN1BC.mjs} +196 -11
- package/dist/admin/{fr-D86FTt1w.js → fr-D1KNyogi.js} +196 -11
- package/dist/admin/{index-tt61o2VH.mjs → index-BmnC2BPs.mjs} +40 -38
- package/dist/admin/{index-CSJJn4qy.js → index-Bnt0Jq6O.js} +12 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-C3PSvC7z.mjs → pt-D6m1TijL.mjs} +196 -11
- package/dist/admin/{pt-BE-FT-L8.js → pt-EKThRXPY.js} +196 -11
- package/dist/server/index.js +3230 -129
- package/dist/server/index.mjs +3230 -129
- package/package.json +1 -1
- package/dist/admin/riskData-BVs9GpgD.js +0 -26
- package/dist/admin/riskData-CI1gm2yI.mjs +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
+
# [4.18.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.17.0...v4.18.0) (2026-11-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* new-device email with "This wasn't me", impossible travel, signed webhook and GDPR self-service ([#37](https://github.com/Schero94/Magic-Sessionmanager/issues/37)) ([92af596](https://github.com/Schero94/Magic-Sessionmanager/commit/92af5962b647827851a4225d0b135c1fff95dffe))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Release type: minor (`feat`). Additive: one new admin route, three new Content API routes, one new Content API permission, one new private session column and new settings keys; see Migration.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
* **New-device email with "This wasn't me"** (Alerts › Security emails › Sign-in from a new device, `alertOnNewDevice`, off by default). A device is the browser family, operating system family and device type from the User-Agent, plus the `deviceId` the app may send at sign-in; the plugin stores only `deviceKey`, an HMAC-SHA256 of these with a key derived from `SESSION_ENCRYPTION_KEY` (new private session column). No fingerprinting, no cookie. New = not seen in the user's last 50 sessions; the first sign-in is never new. Event `user.sign-in.new-device`.
|
|
14
|
+
* **"This wasn't me" link** in the new-device and impossible-travel emails: `GET /api/magic-sessionmanager/not-me?token=` shows a confirmation page only (mail scanners cannot end sessions); `POST /api/magic-sessionmanager/not-me` (`token`, `scope=session|all`, form or JSON) ends that session or every session of the user. The token is signed (HMAC-SHA256, purpose key), expires after 72 hours and works once across all processes; both routes are public on purpose and rate-limited per address (30 and 10 per minute). Event `user.not-me`. The link is built from `server.url` (no link without an absolute http(s) URL).
|
|
15
|
+
* **Impossible travel** (Login protection › Impossible travel, `impossibleTravelEnabled`, off by default): distance between the locations of this and the previous sign-in divided by the time between them; flagged above `impossibleTravelSpeedKmh` (1000) over at least `impossibleTravelMinDistanceKm` (500). Needs a location database with cities; while on, session locations are stored rounded to 0.1 degree. Action `alert` (default: event `user.sign-in.impossible-travel`, optional email `alertOnImpossibleTravel`, webhook) or `reauthenticate` (every session of the user ends; the sign-in gets `401` with `details.code: "REAUTHENTICATION_REQUIRED"` and no token).
|
|
16
|
+
* **Signed webhook** (Alerts › Signed webhook, off by default): POST JSON `{ id, event, createdAt, data }` to your https endpoint with `X-Magic-Sessionmanager-Signature: t=<unix>,v1=<HMAC-SHA256 of "t.body">`, `X-Magic-Sessionmanager-Event` and `X-Magic-Sessionmanager-Delivery`. SSRF guard: https only, no credentials in the URL, every resolved address must be public (no loopback, private, link-local incl. 169.254.169.254, CGNAT, multicast, reserved, documentation, unique-local IPv6), the connection is pinned to the checked address, redirects are not followed, 5-second timeout, at most 64 KB of the answer read. Retries after 2 and 10 seconds for network errors, timeouts, 429 and 5xx. The URL and the secret are write-only: the admin API returns only `hasGenericWebhook` / `hasGenericWebhookSecret`, the secret is stored encrypted; a PUT without the fields keeps them. **Send test** (`POST /magic-sessionmanager/webhook/test`) reports a safe result code.
|
|
17
|
+
* **Events to send** (`webhookEvents`): one selection for Discord, Slack and the signed webhook: every successful sign-in, suspicious, new country, new device, impossible travel, failed, refused, lockout, lock lifted, session limit, password change, "This wasn't me".
|
|
18
|
+
* **Own-data export** (GDPR Art. 15): `GET /api/magic-sessionmanager/my-data` (signed-in user, own data only, 3 per hour) returns the user's sessions and security events as a JSON download, without tokens, hashes, device keys or native ids. The Authenticated role gets the new permission `self-service.exportOwnData` once (installations at permission version 2 get only this action). Event `user.data.exported`.
|
|
19
|
+
* **Shorten IP addresses of sessions** (Data and retention › Privacy, `sessionIpAnonymize`, off by default): new sessions store 203.0.113.0 instead of 203.0.113.42 (IPv6 /48).
|
|
20
|
+
* **Retention presets** (Data and retention): Minimal (sessions 7 days, events 30), Standard (90/90), Extended (365/365); the security log part needs "View admin activity" and "Change protected settings".
|
|
21
|
+
* The signed webhook, the event selection, impossible travel and **Shorten IP addresses of sessions** are **protected settings** (`settings.update`), like the Discord and Slack webhooks; **Send test** (`POST /magic-sessionmanager/webhook/test`) needs the same permission. The new-device and impossible-travel email switches stay with plugin access, like the other alert emails. The signed webhook URL is returned only as `hasGenericWebhook` with `genericWebhookHint` (scheme and host), the secret only as `hasGenericWebhookSecret`.
|
|
22
|
+
* README: "What is recorded" fact sheet for data protection and works councils, webhook verification snippet, the not-me and export routes.
|
|
23
|
+
|
|
24
|
+
### Migration
|
|
25
|
+
|
|
26
|
+
* `X-Session-Terminated-Reason` keeps its five values: sessions ended by the session limit, "This wasn't me" or "Require a new sign-in" report `manual`, by a password change `logout`.
|
|
27
|
+
* **Discord and Slack no longer post every sign-in by default.** New installations send only the selected events (default: suspicious, new country, new device, impossible travel, lockout, "This wasn't me"). An installation upgraded from 4.16 or earlier keeps posting every sign-in (`webhookEvents` is stored once as `login.success`, `login.suspicious`, `login.new_location`) until an administrator changes **Events to send**.
|
|
28
|
+
* The session table gets a private `deviceKey` column (Strapi adds it on start). Sessions from before the upgrade have none and are compared by browser and system family.
|
|
29
|
+
* Content API permission version 3: the Authenticated role gets `self-service.exportOwnData` once; actions an administrator removed stay removed.
|
|
30
|
+
|
|
31
|
+
### Tests
|
|
32
|
+
|
|
33
|
+
* `tests/isolated-signals-http.test.js` (real Strapi): new-device email and link, not-me GET/POST (single use, tampered token, scope all, German page), impossible travel (alert with email, re-sign-in), write-only webhook URL and secret, test send refused for 127.0.0.1 and 169.254.169.254, RBAC, event selection, own-data export (no token material, rate limit), permission grant, shortened IPs. CI runs it on SQLite and PostgreSQL in both JWT modes and on the 5.50 floor.
|
|
34
|
+
* Unit tests for the SSRF guard (incl. IPv4-mapped forms), signatures and their verification, pinned delivery, retries, the not-me token (tamper, expiry, parallel single use), device keys, travel maths and detection settings; rendered tests for the event checklist and the signed webhook card.
|
|
35
|
+
|
|
36
|
+
# [4.17.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.16.1...v4.17.0) (2026-11-25)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* account and IP lockout with unlock, session limits, sign-out on password change and per-role rules ([#35](https://github.com/Schero94/Magic-Sessionmanager/issues/35)) ([faeac7c](https://github.com/Schero94/Magic-Sessionmanager/commit/faeac7cc1a299043c3b9d6c03c54cfec96f9fa43))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Release type: minor (`feat`). Additive: three new admin routes, one new permission and new settings keys; no existing route, response or setting changes meaning. One default differs between new and existing installations (see Migration).
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
* **Account lockout** next to the IP lockout (Configuration › Login protection › Failed sign-ins): **Lock an account after** N failed sign-ins for one account from any address (0 = off, the default). Counted by a SHA-256 hash of the lower-cased identifier; the typed identifier is never stored. An unknown account is locked and answered exactly like an existing one.
|
|
49
|
+
* **Configurable window and lock duration** (`lockoutWindowMinutes` 1-1440, `lockoutDurationMinutes` 1-10080; both default 15, as before). `Retry-After` follows the lock. When a lock ends, the failures that caused it no longer count.
|
|
50
|
+
* **Trusted addresses** (`lockoutTrustedAddresses`, up to 100 IPs or CIDR ranges, IPv4 and IPv6): never locked by IP; their accounts can still be locked.
|
|
51
|
+
* **Locked now** card with **Unlock**: lists locked IP addresses (as the security log stores IPs: full, shortened or hidden) and locked accounts with their user. Seeing it needs plugin access; **Unlock** needs the new permission **Unlock locked sign-ins** (`plugin::magic-sessionmanager.lockouts.unlock`, Super Admin only at first). Every unlock is recorded with the admin who did it. Admin routes `GET /lockouts`, `POST /lockouts/unlock` (`{ id }`, write rate limit) and `GET /roles`.
|
|
52
|
+
* **Lockout email** (`lockoutNotifyUser`, off by default): the account owner gets the new **Account locked** template (editable under Alerts › Email templates) through Strapi's email plugin, so Magic Mail delivers it when installed.
|
|
53
|
+
* **Security log events for app users** (switch **Record failed and refused sign-ins**, `recordUserSignInEvents`, on by default): `user.sign-in.failed`, `user.sign-in.refused` (`meta.reason`: lockout, too-many-attempts, session-limit, country, risk, location-unavailable), `user.lockout`, plus `user.lockout.lifted` (actor = admin), `user.session.limit` and `user.password-change.ended-others`. A client that keeps hitting a lock is logged once per minute; sign-ins naming an account that does not exist are aggregated to one event per anonymised address per 5 minutes (`meta.unknownAccount`), and no typed identifier or title is stored. Deleting a user deletes their events.
|
|
54
|
+
* The new policy settings are **protected settings**: changing them needs **Change protected settings** (`settings.update`, from 4.16.1) as well as plugin access; roles without it see them read-only and can still save the rest of the form.
|
|
55
|
+
* **Concurrent session limit** (Sessions › Concurrent sessions, `maxSessionsPerUser`, 0 = off by default): **End the oldest session** (default) or **Refuse the new sign-in**. A refused sign-in answers `403` with `error.details.code: "SESSION_LIMIT_REACHED"` and `details.limit`; no token or refresh cookie leaves the server and the new session is ended. Idle and over-age sessions do not count. Applied in one cluster-wide critical section per user.
|
|
56
|
+
* **End other sessions after a password change** (`endOtherSessionsOnPasswordChange`) for `POST /auth/change-password` in both JWT modes; the session that made the change stays. A failure fails closed (503) like the password reset.
|
|
57
|
+
* **Different rules for some roles** (Sessions › Roles, collapsed): per Users & Permissions role an own session limit, inactivity timeout and account lockout threshold (`roleRules`, up to 50). The token check and the idle check apply the role's timeout; the overview still classifies "idle" by the general timeout.
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
* The IP lockout settings are labelled "Lock an IP address after" and the Login protection intro no longer says refused sign-ins are not recorded.
|
|
62
|
+
* With a role rule for the inactivity timeout, the idle check uses the Document Service path even when "Direct SQL" is selected (it needs each session's role).
|
|
63
|
+
|
|
64
|
+
### Migration
|
|
65
|
+
|
|
66
|
+
* **Existing installations keep their behaviour.** On the first start of this version, an installation that ran an earlier version gets `endOtherSessionsOnPasswordChange: false` stored once, so a password change keeps the other sessions as before. New installations end them by default. Turn it on under Sessions › Password change.
|
|
67
|
+
* Every other new setting is off or keeps the earlier value: IP lockout 5 failures / 15 minutes / 15 minutes, no account lockout, no session limit, no role rules. Failed and refused app-user sign-ins are now written to the security log; turn off **Record failed and refused sign-ins** to keep the previous behaviour.
|
|
68
|
+
* A custom `coordination.counterStore` receives a third `block(key, untilMs, { windowStart })` argument; a store that ignores it keeps working, but a client may get "Too many login attempts at once" until the counting window ends after a lock.
|
|
69
|
+
* `X-Session-Terminated-Reason` keeps its five values: sessions ended by the session limit report `manual`, by a password change `logout`.
|
|
70
|
+
|
|
71
|
+
### Tests
|
|
72
|
+
|
|
73
|
+
* `tests/isolated-policies-http.test.js` boots Strapi from this checkout and covers IP and account lockout across addresses, trusted addresses, Retry-After, the lock email (fake email plugin), Locked now with RBAC (401/403/200), Unlock with the actor in the log, the recording switch, session limit (end oldest, refuse with 403 and no tokens), per-role limit and idle timeout, ending other sessions after a password change and the switch, and event deletion with the user. CI runs it on SQLite and PostgreSQL in legacy and refresh mode, and on the Strapi 5.50 floor.
|
|
74
|
+
* The multi-process check (8 processes, SQLite and PostgreSQL) now drives the real lockout engine: exact per-IP and per-account limits across processes, one shared lock list and a cluster-wide unlock.
|
|
75
|
+
* Unit tests for the policy settings, the lockout engine, upgrade defaults, the session limit and the lock email; StrictMode tests for the Locked now card (states, RBAC, keyboard, unlock round trip) and the role rules editor.
|
|
76
|
+
|
|
1
77
|
## [4.16.1](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.16.0...v4.16.1) (2026-11-25)
|
|
2
78
|
|
|
3
79
|
|
package/README.md
CHANGED
|
@@ -498,17 +498,46 @@ Saved settings are not changed: a switch that was on stays stored and applies on
|
|
|
498
498
|
|
|
499
499
|
## Login protection
|
|
500
500
|
|
|
501
|
-
Configuration › Login protection checks **new sign-ins only**. Existing sessions are not affected
|
|
501
|
+
Configuration › Login protection checks **new sign-ins only**. Existing sessions are not affected. Failed and refused sign-ins are written to the [security log](#admin-activity-and-sign-in-history) while **Record failed and refused sign-ins** is on (default).
|
|
502
502
|
|
|
503
|
-
| Rule | Response | Notes
|
|
504
|
-
| ----------------------------- | ----------------------------------- |
|
|
505
|
-
|
|
|
506
|
-
| Reject suspicious sign-ins | 403 | VPN, proxy or Tor address, or, with security scoring on, a score below 50. Needs a [risk data source](#risk-data-vpn-proxy-tor); without one this rule refuses nothing.
|
|
507
|
-
| Country rules | 403 | Allow only listed countries, or reject listed countries. With "Allow only listed countries", an empty list allows every country.
|
|
508
|
-
| Location cannot be determined | 403 "Login temporarily unavailable" | When `geoLookupFailureMode` says reject (`auto` rejects only when "Reject suspicious sign-ins" is on).
|
|
503
|
+
| Rule | Response | Notes |
|
|
504
|
+
| ----------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
505
|
+
| IP and account lockout | 429 with `Retry-After` | After `maxFailedLogins` failed sign-ins from one IP address, or `maxFailedLoginsPerAccount` for one account from any address (off by default), within `lockoutWindowMinutes` (15), that address or account is refused for `lockoutDurationMinutes` (15). Shared by all server processes. Each attempt is counted before the password check, so a parallel burst cannot exceed the limit; extra attempts running at once get 429 with `Retry-After: 1` and no lock. See [Lockout, trusted addresses and Locked now](#lockout-trusted-addresses-and-locked-now). |
|
|
506
|
+
| Reject suspicious sign-ins | 403 | VPN, proxy or Tor address, or, with security scoring on, a score below 50. Needs a [risk data source](#risk-data-vpn-proxy-tor); without one this rule refuses nothing. |
|
|
507
|
+
| Country rules | 403 | Allow only listed countries, or reject listed countries. With "Allow only listed countries", an empty list allows every country. |
|
|
508
|
+
| Location cannot be determined | 403 "Login temporarily unavailable" | When `geoLookupFailureMode` says reject (`auto` rejects only when "Reject suspicious sign-ins" is on). |
|
|
509
|
+
| Session limit (policy Refuse) | 403 `SESSION_LIMIT_REACHED` | The user already has `maxSessionsPerUser` open sessions. See [Concurrent session limit](#concurrent-session-limit). |
|
|
509
510
|
|
|
510
511
|
Requests with an ended session get **401** with the header `X-Session-Terminated-Reason` (`logout`, `manual`, `idle`, `expired` or `blocked`).
|
|
511
512
|
|
|
513
|
+
### Lockout, trusted addresses and Locked now
|
|
514
|
+
|
|
515
|
+
- **Per IP** (`maxFailedLogins`, default 5) and **per account** (`maxFailedLoginsPerAccount`, default 0 = off). The account counter uses a SHA-256 hash of the lower-cased identifier (`identifier` of `/auth/local`, `email` of the Magic Link routes); the typed identifier is never stored. An unknown account is counted and answered exactly like an existing one, so the response does not reveal which accounts exist.
|
|
516
|
+
- Anyone who knows an account name can lock that account. Keep the account threshold higher than the IP threshold; admins can lift a lock at once.
|
|
517
|
+
- **Window and duration**: `lockoutWindowMinutes` (1-1440) and `lockoutDurationMinutes` (1-10080). When a lock ends, the failures that caused it no longer count.
|
|
518
|
+
- **Trusted addresses** (`lockoutTrustedAddresses`, up to 100 IPs or CIDR ranges such as `192.0.2.0/24` or `2001:db8::/32`) are never locked by IP. Their accounts can still be locked. Use it for an office NAT or a backend that signs in for many users.
|
|
519
|
+
- **Locked now** (same tab) lists every active lock: IP addresses as the security log stores them (full, shortened or hidden) and accounts with their user. **Unlock** needs the permission **Unlock locked sign-ins** and is recorded with the admin who did it.
|
|
520
|
+
- **Lockout email** (`lockoutNotifyUser`, off by default) tells the account owner about an account lock, through Strapi's email plugin (Magic Mail delivers it when installed). The text is the **Account locked** template under Alerts › Email templates (`{{user.email}}`, `{{user.username}}`, `{{lock.minutes}}`, `{{lock.until}}`).
|
|
521
|
+
|
|
522
|
+
### Concurrent session limit
|
|
523
|
+
|
|
524
|
+
Sessions › Concurrent sessions: `maxSessionsPerUser` (0 = no limit, the default). Sessions that are idle or past their maximum age do not count.
|
|
525
|
+
|
|
526
|
+
| Policy (`sessionLimitPolicy`) | What happens at the limit |
|
|
527
|
+
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
528
|
+
| `end-oldest` (default) | The new sign-in succeeds; the oldest open sessions end (`X-Session-Terminated-Reason: manual`). |
|
|
529
|
+
| `refuse` | The sign-in answers `403` with `{ error: { name: 'ForbiddenError', details: { code: 'SESSION_LIMIT_REACHED', limit } } }`. No token or refresh cookie is sent; Strapi's new session is ended at once. |
|
|
530
|
+
|
|
531
|
+
The check and the session creation run in one cluster-wide critical section per user, so parallel sign-ins on several processes cannot pass the limit together.
|
|
532
|
+
|
|
533
|
+
### Password change
|
|
534
|
+
|
|
535
|
+
Sessions › Password change › **End other sessions after a password change** (`endOtherSessionsOnPasswordChange`): after `POST /auth/change-password` every other session of the user ends (`logout`), in legacy and refresh mode; the session that made the change stays. On by default for new installations; installations upgraded from 4.16 or earlier keep the previous behaviour (off) until it is turned on. A password reset always ends the other sessions.
|
|
536
|
+
|
|
537
|
+
### Different rules for some roles
|
|
538
|
+
|
|
539
|
+
Sessions › Roles › **Different rules for some roles** (collapsed): per Users & Permissions role an own session limit, inactivity timeout and account lockout threshold (`roleRules`: `[{ role: '<role documentId>', maxSessionsPerUser, inactivityTimeout, maxFailedLoginsPerAccount }]`, `null` = general value, up to 50 rules). The token check and the idle check use the role's timeout. The dashboard's Active/Idle counts still use the general timeout.
|
|
540
|
+
|
|
512
541
|
---
|
|
513
542
|
|
|
514
543
|
## Alerts
|
|
@@ -516,7 +545,46 @@ Requests with an ended session get **401** with the header `X-Session-Terminated
|
|
|
516
545
|
Configuration › Alerts. Both kinds are sent only when location data is available for the sign-in.
|
|
517
546
|
|
|
518
547
|
- **Security emails to users** go to the end user's own email address, not to administrators: suspicious sign-in, sign-in from a new country (differs from the user's last 50 sessions), VPN or proxy. Suspicious sign-in and VPN or proxy need a [risk data source](#risk-data-vpn-proxy-tor); the new-country email needs location data only. They use Strapi's Email plugin, so configure an email provider first (for example `@strapi/provider-email-nodemailer`).
|
|
519
|
-
- **Team notifications** post
|
|
548
|
+
- **Team notifications** post the events selected under **Events to send** to Discord or Slack. A sign-in is sent as `login.suspicious`, otherwise `login.new_location`, otherwise `login.success`, when that event is selected. New installations leave out `login.success` (every sign-in); installations upgraded from 4.16 or earlier keep it selected until it is changed. Without a [risk data source](#risk-data-vpn-proxy-tor), `login.suspicious` is never sent. Only `https://discord.com`, `https://discordapp.com` and `https://hooks.slack.com` URLs are accepted; Save rejects any other URL with a field error. A webhook URL is a secret (anyone with it can post to the channel), so since 4.17 it is never sent back to the browser: a stored URL shows as **Saved** with the host (`https://discord.com/…`) and **Replace** / **Remove**. Over the API, `GET /settings` returns `hasDiscordWebhook` / `hasSlackWebhook` and `discordWebhookHint` / `slackWebhookHint` instead of the URLs; a `PUT` without the URL key keeps the stored URL, an empty string removes it. Changing webhooks and the event selection needs **Change protected settings**.
|
|
549
|
+
|
|
550
|
+
- **New device** (`alertOnNewDevice`, off) and **impossible travel** (`alertOnImpossibleTravel`, off, needs [impossible travel](#new-device-and-impossible-travel)) emails carry a **"This wasn't me"** link. These two are evaluated even without location data for the new-device case.
|
|
551
|
+
|
|
552
|
+
### New device and impossible travel
|
|
553
|
+
|
|
554
|
+
- **Device, without fingerprinting.** Browser family, operating system family and device type from the User-Agent header, plus the optional `deviceId` your app sends in the sign-in body (Users & Permissions uses the same field for its sessions). No cookie is set and nothing else is read. The session stores `deviceKey`, an HMAC-SHA256 of these values with a key derived from `SESSION_ENCRYPTION_KEY`, so it cannot be linked to a device outside your installation. A sign-in is from a **new device** when none of the user's last 50 sessions has the same key; the first sign-in of a user is never new. Sessions created before 4.17 have no key and are compared by browser and system family.
|
|
555
|
+
- **Impossible travel** (Login protection › Impossible travel, off). The great-circle distance between this sign-in and the user's previous sign-in with a location, divided by the time between them. Flagged when the distance is at least `impossibleTravelMinDistanceKm` (500) and the speed is above `impossibleTravelSpeedKmh` (1000). Needs a location database with cities (coordinates); while the feature is on, locations are stored rounded to 0.1 degree (about 11 km). VPNs and mobile networks cause false alarms, so the default action only records and alerts. **Require a new sign-in** ends every session of the user and answers `401` with `error.details.code: "REAUTHENTICATION_REQUIRED"`; signing in again from the new place then works.
|
|
556
|
+
- **"This wasn't me"**: the link opens `GET /api/magic-sessionmanager/not-me?token=…`, a confirmation page in the user's browser language (en, de, fr, es, pt) that changes nothing; **Sign out that device** or **Sign out everywhere** posts to the same path. The token is signed (HMAC-SHA256 with its own derived key), expires after 72 hours and works once, also across processes. The link is built from `server.url`; without an absolute http(s) URL the email has no link. Both routes are public on purpose and rate-limited per address.
|
|
557
|
+
|
|
558
|
+
### Signed webhook
|
|
559
|
+
|
|
560
|
+
Alerts › **Signed webhook** sends the selected events to your own https endpoint (for example a SIEM):
|
|
561
|
+
|
|
562
|
+
```http
|
|
563
|
+
POST /your/endpoint HTTP/1.1
|
|
564
|
+
Content-Type: application/json
|
|
565
|
+
X-Magic-Sessionmanager-Event: lockout
|
|
566
|
+
X-Magic-Sessionmanager-Delivery: 0f7c9a1e-…
|
|
567
|
+
X-Magic-Sessionmanager-Signature: t=1795000000,v1=5b1f…
|
|
568
|
+
|
|
569
|
+
{"id":"0f7c9a1e-…","event":"lockout","createdAt":"2026-11-25T09:00:00.000Z","data":{"user":{"documentId":"…"},"ip":"203.0.113.0","userAgent":"…","location":{"country":"DE","city":"Berlin"},"details":{"kind":"account","failures":5,"minutes":15}}}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Verify every delivery before you trust it (Node.js):
|
|
573
|
+
|
|
574
|
+
```js
|
|
575
|
+
const crypto = require('node:crypto');
|
|
576
|
+
|
|
577
|
+
function verifyMagicSignature(secret, rawBody, header, toleranceSeconds = 300) {
|
|
578
|
+
const match = /^t=(\d+),v1=([a-f0-9]{64})$/.exec(header || '');
|
|
579
|
+
if (!match) return false;
|
|
580
|
+
if (Math.abs(Date.now() / 1000 - Number(match[1])) > toleranceSeconds) return false; // replay
|
|
581
|
+
const expected = crypto.createHmac('sha256', secret).update(`${match[1]}.${rawBody}`).digest();
|
|
582
|
+
const given = Buffer.from(match[2], 'hex');
|
|
583
|
+
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
Use the raw request body (before JSON parsing). The URL and the secret are write-only: after saving, the admin panel only shows that they are set (the URL with its host, `https://hooks.example.com/…`); the secret is stored encrypted. Over the API, `GET /settings` returns `hasGenericWebhook`, `genericWebhookHint` and `hasGenericWebhookSecret` instead of the values; a `PUT` without `genericWebhookUrl` / `genericWebhookSecret` keeps the stored value, an empty string removes it. Changing the signed webhook, the event selection and **Send test** need **Change protected settings**. The server refuses URLs that are not https or contain credentials, and checks before every delivery that **every** address the host resolves to is public (no loopback, private, link-local including `169.254.169.254`, CGNAT, multicast, reserved, documentation or unique-local IPv6 address); it then connects to the checked address, does not follow redirects, times out after 5 seconds and reads at most 64 KB of the answer. Network errors, timeouts, 429 and 5xx are retried after 2 and 10 seconds. **Send test** sends one `test` event and shows the result.
|
|
520
588
|
|
|
521
589
|
Example email provider configuration:
|
|
522
590
|
|
|
@@ -547,15 +615,17 @@ export default ({ env }) => ({
|
|
|
547
615
|
|
|
548
616
|
Prefix `/api/magic-sessionmanager`. Every route requires a Users & Permissions JWT (`Authorization: Bearer <JWT>`), works on the caller's **own** sessions only and is rate-limited (writes 10, reads 120 requests per minute by default; 429 with `Retry-After`).
|
|
549
617
|
|
|
550
|
-
| Method
|
|
551
|
-
|
|
|
552
|
-
| GET
|
|
553
|
-
| GET
|
|
554
|
-
| GET
|
|
555
|
-
| POST
|
|
556
|
-
| POST
|
|
557
|
-
| POST
|
|
558
|
-
| DELETE
|
|
618
|
+
| Method | Path | Purpose | Response |
|
|
619
|
+
| --------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
620
|
+
| GET | `/my-sessions` | Own sessions (up to 200), current session first | `{ data: [...], meta: { count, active, hasMore, limit } }` |
|
|
621
|
+
| GET | `/current-session` | The session of the current token | `{ data: {..., isCurrentSession: true } }`; 404 when none |
|
|
622
|
+
| GET | `/user/:userId/sessions` | Sessions of a user; only your own `userId` | 403 for another user |
|
|
623
|
+
| POST | `/logout` | End the current session (reason `logout`) | `{ message, terminated }` |
|
|
624
|
+
| POST | `/logout-all` | End all own sessions (reason `logout`) | `{ message, terminatedCount }` |
|
|
625
|
+
| POST | `/logout-others` | End all own sessions except the current one | `{ message, terminatedCount, currentSessionPreserved }` |
|
|
626
|
+
| DELETE | `/my-sessions/:sessionId` | End one own session that is not the current one (reason `manual`) | `{ message, success, alreadyTerminated }`; 400 for the current session, 404 for unknown or foreign IDs |
|
|
627
|
+
| GET | `/my-data` | Own sessions and security events as a JSON download (GDPR Art. 15); 3 per hour | `{ exportedAt, user, sessions, securityEvents }` with `Content-Disposition: attachment`; no tokens, hashes or device keys |
|
|
628
|
+
| GET, POST | `/not-me` | **Public** (no JWT): the "This wasn't me" link of the security emails; GET shows a confirmation, POST `{ token, scope: 'session' \| 'all' }` ends sessions | HTML page, or `{ data: { ended, scope } }` with `Accept: application/json`; 410 when the link is invalid, expired or used |
|
|
559
629
|
|
|
560
630
|
`POST /api/auth/logout` also ends the current session; the plugin mounts it when Users & Permissions does not provide it.
|
|
561
631
|
|
|
@@ -684,16 +754,17 @@ Prefix `/magic-sessionmanager` (Strapi admin API). Every route requires an authe
|
|
|
684
754
|
|
|
685
755
|
The **Admin panel sessions** routes need two more permissions, which only the Super Admin role has by default (Settings › Administration Panel › Roles › Plugins › Session Manager › Admin panel):
|
|
686
756
|
|
|
687
|
-
| Permission | Name in the role editor
|
|
688
|
-
| ---------------------------------------------------- |
|
|
689
|
-
| `plugin::magic-sessionmanager.admin-sessions.read` | Read admin panel sessions
|
|
690
|
-
| `plugin::magic-sessionmanager.admin-sessions.revoke` | Sign out admins
|
|
691
|
-
| `plugin::magic-sessionmanager.admin-activity.read` | View admin activity
|
|
692
|
-
| `plugin::magic-sessionmanager.settings.update` | Change protected settings (location lookup, webhooks, security log) | Changing IP location lookup, provider, lookup failure mode and database file, team notification webhooks, and (with View admin activity) the security log settings. Since 4.17; Super Admin only by default |
|
|
757
|
+
| Permission | Name in the role editor | Allows |
|
|
758
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
759
|
+
| `plugin::magic-sessionmanager.admin-sessions.read` | Read admin panel sessions | The Admin panel view and its two GET routes |
|
|
760
|
+
| `plugin::magic-sessionmanager.admin-sessions.revoke` | Sign out admins | **Sign out** and **Sign out everywhere** (also needs read) |
|
|
761
|
+
| `plugin::magic-sessionmanager.admin-activity.read` | View admin activity | Sign-in history, Activity, Recent sign-in activity, CSV exports and changing the Admin activity settings (also needs read) |
|
|
762
|
+
| `plugin::magic-sessionmanager.settings.update` | Change protected settings (location lookup, webhooks, security log, sign-in policies) | Changing IP location lookup, provider, lookup failure mode and database file, team notification webhooks, the sign-in and session policies (lockout, trusted addresses, session limit, password-change sign-out, role rules), the signed webhook and its **Send test**, the event selection, impossible travel and shortened session IPs, and (with View admin activity) the security log settings. Since 4.17; Super Admin only by default |
|
|
763
|
+
| `plugin::magic-sessionmanager.lockouts.unlock` | Unlock locked sign-ins | **Unlock** in Login protection › Locked now (also needs `access`) |
|
|
693
764
|
|
|
694
765
|
**What the admin panel view shows about other admins (4.17).** Names, emails and roles of admins are Strapi's own user data. The Admin panel view and the sign-in history return them only to roles that may also read them in Settings › Users: email and name need Strapi's **Read** permission on Users (`admin::users.read`), role names need it or **Read** on Roles (`admin::roles.read`). Without them the list shows "Admin #12", "Email hidden" and "Hidden" (roles), and the search matches the admin id only. Every admin always sees their own row. Grant `admin::users.read` to roles that should keep seeing names and emails.
|
|
695
766
|
|
|
696
|
-
**Protected settings (4.17).** `PUT /settings` still needs only `access`, so roles that change the session, login-protection, alert-email and retention options keep working. Changing a protected key needs **Change protected settings** as well, else 403 with `error.details.reason: "settings-update-permission"`: `enableGeolocation`, `geoIpProvider`, `geoLookupFailureMode`, `geoIpDatabasePath`, `enableWebhooks`, `discordWebhookUrl`, `slackWebhookUrl
|
|
767
|
+
**Protected settings (4.17).** `PUT /settings` still needs only `access`, so roles that change the session, login-protection, alert-email and retention options keep working. Changing a protected key needs **Change protected settings** as well, else 403 with `error.details.reason: "settings-update-permission"`: `enableGeolocation`, `geoIpProvider`, `geoLookupFailureMode`, `geoIpDatabasePath`, `enableWebhooks`, `discordWebhookUrl`, `slackWebhookUrl`, every security log key (those also keep needing **View admin activity**, reason `admin-activity-permission`) and the sign-in and session policy keys (`maxFailedLoginsPerAccount`, `lockoutWindowMinutes`, `lockoutDurationMinutes`, `lockoutTrustedAddresses`, `lockoutNotifyUser`, `recordUserSignInEvents`, `maxSessionsPerUser`, `sessionLimitPolicy`, `endOtherSessionsOnPasswordChange`, `roleRules`), and the detection and integration keys (`impossibleTravelEnabled`, `impossibleTravelSpeedKmh`, `impossibleTravelMinDistanceKm`, `impossibleTravelAction`, `webhookEvents`, `genericWebhookEnabled`, `genericWebhookUrl`, `genericWebhookSecret`, `sessionIpAnonymize`). The new-device and impossible-travel email switches stay with `access`, like the other alert emails. Sending a protected key back with its stored value is not a change, so these roles can still save the whole form. The admin UI shows these controls read-only for them.
|
|
697
768
|
|
|
698
769
|
| Method | Path | Admin UI action |
|
|
699
770
|
| -------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -725,6 +796,9 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
|
|
|
725
796
|
| GET | `/admin-activity/sign-ins/export` | CSV export batches of 500 rows, newest first; same filters plus `cursor`; follow `meta.nextCursor` |
|
|
726
797
|
| GET | `/admin-activity/content` | **Activity**: `adminId`, `action` (`all`, `view`, `create`, `update`, `publish`, `unpublish`, `discard`, `delete`, `clone`), `contentType` (uid), `from`, `to`, `page`, `pageSize`; needs `admin-activity.read` |
|
|
727
798
|
| GET | `/admin-activity/content/export` | CSV export batches of 500 rows; same filters plus `cursor` |
|
|
799
|
+
| GET | `/lockouts` | **Locked now**: `{ data: [{ id, kind: 'ip' \| 'account', ip, user, failures, lockedAt, until }] }`; read rate limit |
|
|
800
|
+
| POST | `/lockouts/unlock` | **Unlock**: body `{ id }` from the list; needs `lockouts.unlock`; 404 when the lock already ended; 10 per minute |
|
|
801
|
+
| GET | `/roles` | Users & Permissions roles (without Public) for **Different rules for some roles** |
|
|
728
802
|
|
|
729
803
|
**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.
|
|
730
804
|
|
|
@@ -1001,7 +1075,8 @@ The plugin sits in the request path of every authenticated Content API call, so
|
|
|
1001
1075
|
|
|
1002
1076
|
- **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.
|
|
1003
1077
|
- **Revocation.** Ended, expired and revoked sessions and blocked users are rejected on every Content API request, in both token check modes. Tokens of deleted records stay on a revocation list.
|
|
1004
|
-
- **Password reset.** A successful password reset ends every older session of the user in both JWT modes.
|
|
1078
|
+
- **Password reset and change.** A successful password reset ends every older session of the user in both JWT modes; a password change does the same when **End other sessions after a password change** is on.
|
|
1079
|
+
- **Lockout data.** Lock counters store SHA-256 hashes of IPs and identifiers, never the typed identifier. The Locked now list shows IPs as the security log stores them and expires with the lock. Failed and refused app-user sign-ins go to the security log (switch **Record failed and refused sign-ins**); deleting a user deletes their events.
|
|
1005
1080
|
- **Privacy.** Session records contain IP addresses, user agents and location data. With the `auto` or `ipapi` provider, IP addresses can be sent to ipapi.co; use `local-mmdb` or turn off IP location lookup to avoid that. The details dialog never looks up a location unless you click **Look up location**. Set **Keep ended sessions for** to match your retention policy, and use **Delete ended sessions** or **Delete record** to remove history.
|
|
1006
1081
|
- **What leaves your server.** Only what you turn on: IP lookups of end-user sign-ins at ipapi.co (provider `auto` without a local database, or `ipapi`; admin security events only with **Look up the location of security events** and the explicit `ipapi` provider, and then only the anonymised address), Discord or Slack webhooks (Team notifications), emails through your own Email provider (Security emails) and the MaxMind database download when you click **Update database** or run the updater. There is no telemetry, no install ping and no license check.
|
|
1007
1082
|
- **Reporting a vulnerability.** Please do not post exploit details in a public issue. Open an issue that asks for a private contact, or use the email address on the maintainer's GitHub profile, and you will get a reply before anything is published.
|
|
@@ -1011,6 +1086,25 @@ The plugin sits in the request path of every authenticated Content API call, so
|
|
|
1011
1086
|
|
|
1012
1087
|
---
|
|
1013
1088
|
|
|
1089
|
+
## What is recorded (fact sheet for data protection and works councils)
|
|
1090
|
+
|
|
1091
|
+
Information for your records of processing, a data protection impact assessment or a works agreement (Germany: section 87(1) no. 6 BetrVG when the users are employees). It describes the software, not your legal basis; it is not legal advice.
|
|
1092
|
+
|
|
1093
|
+
| Data | When it is recorded | Where | Kept for | Who can see it | Switch |
|
|
1094
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
1095
|
+
| App-user session: user, sign-in, last activity and sign-out time, end reason, IP address, browser, system, device type, country and city (when location lookup is on) | Every sign-in and while the session is used | `magic_sessions` | Ended sessions: `retentionDays` (default 90; presets 7, 90, 365; or forever) | Admins with **Access the Session Manager plugin**; the user through the Content API | IP shortening: **Shorten IP addresses of sessions** (off); location: **IP location lookup** |
|
|
1096
|
+
| Device key (HMAC of browser family, system family, device type and the app's `deviceId`) | Every sign-in | `magic_sessions.device_key` | With the session | Nobody in the UI (used only to compare devices) | Always; it cannot be turned back into the device |
|
|
1097
|
+
| Rounded location (0.1 degree, about 11 km) | Every sign-in while **Detect impossible travel** is on | Inside the session's location | With the session | Admins with plugin access | **Detect impossible travel** (off) |
|
|
1098
|
+
| Failed and refused app-user sign-ins, locks, unlocks (with the admin who unlocked), session-limit and password-change endings, new device, impossible travel, "This wasn't me", data exports | When they happen | `magic_sessions_security_events` | `securityLogRetentionDays` (default 90) | Admins with **View admin activity** (log), the user (own-data export) | **Record failed and refused sign-ins** (on) for failed/refused/locks; the others only while their feature is on |
|
|
1099
|
+
| Unknown-account sign-ins | Once per anonymised address per 5 minutes | Same log, without account and without the typed name | Same | Same | Same |
|
|
1100
|
+
| Lock counters | During the counting window and the lock | `magic_sm_counters` (SHA-256 hashes of IP and identifier) | Until the lock ends | Nobody (hashes) | Lockout thresholds; 0 turns a lock off |
|
|
1101
|
+
| "Locked now" entries | While a lock lasts | `magic_sm_cache` | Until the lock ends | Admins with plugin access | Follows the log's IP options |
|
|
1102
|
+
| Admin sign-ins and, opt-in, Content Manager activity | See [Admin activity](#admin-activity-and-sign-in-history) | Security log | `securityLogRetentionDays` | Admins with **View admin activity** | **Record admin sign-ins** (on), **Record Content Manager activity** (off) |
|
|
1103
|
+
|
|
1104
|
+
What leaves the server, only when you turn it on: security emails through Strapi's email provider; Discord, Slack and the signed webhook with the selected events (user documentId, IP as the log stores it, browser, country, city, event details; never email addresses or passwords); IP lookups at ipapi.co only with the `auto`/`ipapi` provider. No telemetry.
|
|
1105
|
+
|
|
1106
|
+
Purpose: protecting accounts (lockouts, session control, detection of misuse). No performance or behaviour scoring of people is computed. Users can download their own data (`GET /api/magic-sessionmanager/my-data`); deleting a user deletes their security events; retention jobs delete older data daily.
|
|
1107
|
+
|
|
1014
1108
|
## Troubleshooting
|
|
1015
1109
|
|
|
1016
1110
|
| Problem | Fix |
|
|
@@ -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-Bnt0Jq6O.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 { K as normalizeDeviceType, u as useSessionFormatters,
|
|
10
|
+
import { K as normalizeDeviceType, u as useSessionFormatters, f as pluginId, n as isCancelledRequest, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, q as PageShell, r as StatGrid, s as StatCard, z as EqualGrid, b as getTranslation, L as getDeviceTypeMessage } from "./index-BmnC2BPs.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;
|