strapi-plugin-magic-sessionmanager 4.21.0 → 4.22.1

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +92 -47
  3. package/dist/admin/{Analytics-BqdZIBV4.js → Analytics-B7BAjApz.js} +1 -1
  4. package/dist/admin/{Analytics-C-OLLzoB.mjs → Analytics-CIHgaURb.mjs} +1 -1
  5. package/dist/admin/{App-BswHmNQT.mjs → App-CPE-CQGz.mjs} +1309 -2564
  6. package/dist/admin/{App-Cx9v6n_7.js → App-DJkJC06E.js} +1336 -2591
  7. package/dist/admin/{OnlineUsersWidget-BRmQPPp9.js → OnlineUsersWidget-CcjNfzzf.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-Dusgjc1d.mjs → OnlineUsersWidget-Dou2hxGY.mjs} +1 -1
  9. package/dist/admin/{Settings-DWGuf_Z3.js → Settings--eEiHv_a.js} +104 -81
  10. package/dist/admin/{Settings-DZyQheUS.mjs → Settings-h_exWUiI.mjs} +62 -39
  11. package/dist/admin/dashboardModel-DNT_l-Bk.js +169 -0
  12. package/dist/admin/dashboardModel-fApbKGay.mjs +170 -0
  13. package/dist/admin/{de-DUnrmFWk.mjs → de-Wz5Emtrb.mjs} +79 -7
  14. package/dist/admin/{de-24TPqzG6.js → de-oBmcAcXj.js} +79 -7
  15. package/dist/admin/{en-8mBSkWOF.js → en-B1TN5F62.js} +80 -8
  16. package/dist/admin/{en-D8J__tyF.mjs → en-B_1Ka64U.mjs} +80 -8
  17. package/dist/admin/{es-ChUKey-Q.js → es-Bb515J0p.js} +79 -7
  18. package/dist/admin/{es-BgpgWdk0.mjs → es-CVgw4zsj.mjs} +79 -7
  19. package/dist/admin/{fr-k1MHYKJo.mjs → fr-0AgMxTFc.mjs} +79 -7
  20. package/dist/admin/{fr-DE_CWmgq.js → fr-yDdwunmg.js} +79 -7
  21. package/dist/admin/index-DVQ7tdTC.mjs +4746 -0
  22. package/dist/admin/index-qtN2dOm4.js +4747 -0
  23. package/dist/admin/index.js +1 -1
  24. package/dist/admin/index.mjs +2 -2
  25. package/dist/admin/{pt-BjqU5ioB.js → pt-BAB07LY-.js} +79 -7
  26. package/dist/admin/{pt-DPO4DmDc.mjs → pt-DtM74ffN.mjs} +79 -7
  27. package/dist/server/index.js +1487 -438
  28. package/dist/server/index.mjs +1487 -438
  29. package/package.json +4 -3
  30. package/dist/admin/index-Ceh3Q1Ki.js +0 -2308
  31. package/dist/admin/index-meLDPPwt.mjs +0 -2307
  32. package/dist/admin/settingsTabs-C1q5iMMw.mjs +0 -437
  33. package/dist/admin/settingsTabs-CfquZuKH.js +0 -436
package/CHANGELOG.md CHANGED
@@ -1,3 +1,100 @@
1
+ ## [4.22.1](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.22.0...v4.22.1) (2026-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * second security review (GraphQL mutations while impersonating, socket-based client IP, lockout via auth callback, success resets only the account counter, smaller fixes) ([#45](https://github.com/Schero94/Magic-Sessionmanager/issues/45)) ([c208702](https://github.com/Schero94/Magic-Sessionmanager/commit/c2087025d098ab1c64022123af2caaa477307953))
7
+
8
+
9
+ Release type: patch (`fix`). Fixes every finding of the second security review of 4.21.0 (two High, two Medium, five Low, eight hardening items). The settings API stays compatible: `trustedProxies: true` is still accepted. Read the migration notes: three settings now need **Change protected settings**, `trustedProxies: true` no longer reads proxy headers, and a `SESSION_ENCRYPTION_KEY` shorter than 32 bytes now logs an error at every start (it still starts; the next major version will refuse it).
10
+
11
+ ### Security
12
+
13
+ * **H1: impersonation restrictions now cover GraphQL.** Strapi's body parser skips the GraphQL endpoint and Apollo's persisted queries send only a hash, so the request guard never saw GraphQL operations: an impersonating admin could change the user's email with `updateUsersPermissionsUser` and then reset the password. The plugin now adds an Apollo Server plugin to `plugin::graphql.apolloServer.plugins` (next to the host's own plugins) that refuses **every mutation** of an impersonated request in `didResolveOperation`, after Apollo has resolved the operation. This covers aliases, fragments, persisted queries and batched requests. The answer is 403 with `errors[0].extensions.code` `FORBIDDEN` and `extensions.error.details.reason` `impersonation-mutation`, recorded as `impersonation.refused` (`call-mutation`). Queries still work.
14
+ * **H2: the client IP no longer comes from client-set headers.** With `server.proxy.koa` on, or the `trustedProxies` switch on, the plugin read `CF-Connecting-IP`, `True-Client-IP`, `X-Real-IP` or the left-most `X-Forwarded-For` entry. It ignored `maxIpsCount` and `ipHeader`. So any client could bypass the IP lockout, pass country rules and forge stored addresses. The plugin now uses Koa's `ctx.request.ip`, which follows `server.proxy.koa`, `ipHeader` and `maxIpsCount`, and the custom header chain is gone. `trustedProxies` becomes a list of proxy addresses or CIDR ranges (up to 50): only a request whose TCP peer is on the list has its `X-Forwarded-For` read, and the client is the right-most entry that is not on the list. The admin UI shows it as a text field ("Trusted proxies") instead of the switch.
15
+ * **H2: `trustedProxies` and `maxFailedLogins` need Change protected settings.** Before, an admin with plugin access only could turn on proxy trust or raise the IP threshold.
16
+ * **M1 and L2: the lockout counts every sign-in path, and only wrong passwords.** The lockout matched the exact path `POST /api/auth/local`, so `/api/auth/local/`, `/API/auth/local` and the GraphQL `login` mutation still accepted guesses while an address was locked. It now runs inside Users & Permissions' `auth.callback` controller, which every spelling and GraphQL call. The controller is wrapped in the plugin's `register` phase, before Strapi builds the router. Only Users & Permissions' "Invalid identifier or password" counts. Refusals by the session limit, country rules, a blocked or unconfirmed account no longer count, so a shared office address is not locked by them. Magic Link routes keep the path check, which now also normalises case and slashes, and counts only 400 and 401 answers.
17
+ * **Hardening 3: the pre-sign-in location check covers every path too.** It runs in `auth.callback`, `register`, `resetPassword` and `emailConfirmation`, including the GraphQL mutations, and the path check normalises case and slashes.
18
+ * **M2: a successful sign-in no longer resets the address counter.** It cleared both counters, so an attacker could guess 4 times, sign in to their own account, and repeat without limit. A success now clears only the account counter and gives back its own reserved attempt on the address.
19
+ * **L1: the account lockout can no longer lock the owner out of their usual places.** Trusted addresses are no longer counted or refused by the account counter either. A sign-in from a known device (the app's `deviceId` of an earlier sign-in of that account) passes an account lock. The lock email goes out at most once per account per window, using a counter shared by all processes.
20
+ * **L3: the data export no longer shows the internal impersonation reason or the admin id.** `GET /my-data` showed impersonation events with `meta.reason` and `meta.startedBy`. They now show "An administrator opened your account" (ended: "The administrator access to your account ended"; refused: "An administrator access to your account was refused"), the time and the duration only. The reason stays in the admin log and in the optional email, and the dialog hint now says so.
21
+ * **L4: "View as admin" no longer reveals which admin ids are Super Admins.** Without `admin::users.read`, a Super Admin target answers the same 404 as an unknown id. The refusal is still logged as `super-admin`.
22
+ * **L5: the "This wasn't me" token stays out of access logs.** New emails carry the token in the URL fragment (`/not-me#token=…`), which browsers never send to the server. The page copies it into its form with a script allowed by its CSP hash (`script-src 'sha256-…'`). Links with `?token=` from earlier emails keep working until they expire (72 hours).
23
+ * **Hardening 1:** the webhook address check also blocks the IPv4-compatible (`::/96`) and IPv4-translated (`::ffff:0:0:0/96`) IPv6 forms.
24
+ * **Hardening 2:** a webhook delivery now has a 10-second total deadline (`AbortSignal.timeout`). Before, the 5-second idle timeout let a slow receiver hold a delivery for ever.
25
+ * **Hardening 4:** an active impersonation is read on every request instead of being cached for 5 seconds, so ending it on one process takes effect on every process at once.
26
+ * **Hardening 5:** a new signed-webhook URL is saved only together with the secret (400 on `genericWebhookSecret` otherwise), so the stored secret never signs events sent to another host.
27
+ * **Hardening 6:** the alert email templates (`emailTemplates`) need **Change protected settings**. They go to app users from your address, so they could be used for phishing.
28
+ * **Hardening 7:** rate limits and the IP lockout count an IPv6 client per /64.
29
+ * **Hardening 8:** CSV exports also escape a formula after U+061C (Arabic letter mark) and U+180E (Mongolian vowel separator).
30
+ * **Hardening 9:** a `SESSION_ENCRYPTION_KEY` shorter than 32 bytes logs an error at every start, in every environment, and is recorded once per key in the security log as `config.encryption-key.weak` (shown as **Weak encryption key** under Settings and log access, actor System). The key itself is never logged. It is not refused, because a patch release must not stop an installation from starting. **The next major version will refuse to start with a key shorter than 32 bytes.** Unchanged: production refuses to start without a key.
31
+ * **Hardening 10:** a signed-webhook URL whose host is a non-public IP literal (`127.0.0.1`, `0x7f000001`, `[::1]`, `169.254.169.254`, …) is refused when it is saved, not only when it is sent.
32
+
33
+ ### Changed
34
+
35
+ * The Users & Permissions `auth` controller actions `callback`, `register`, `resetPassword` and `emailConfirmation` are wrapped. A host that overrides them in `src/extensions/users-permissions/strapi-server.js` keeps its override: the plugin wraps the resolved action. The original actions are restored on `destroy`.
36
+ * Development: `@strapi/plugin-graphql` 5.64.0 is a devDependency for the GraphQL tests, and the development host moves to Strapi 5.64.0. The new real-HTTP suite `tests/isolated-security-review2-http.test.js` runs on SQLite and PostgreSQL, in both JWT modes and on the 5.50.0 floor.
37
+
38
+ ### Migration
39
+
40
+ * **Behind a reverse proxy:** set `server.proxy: { koa: true, maxIpsCount: <number of proxies> }` in `config/server.js` (Strapi 5.52+), or list your proxies in **Login protection › Client IP address › Trusted proxies** (`trustedProxies: ['10.0.0.0/8']`). Without either, every request shows the proxy's address. On Strapi 5.50 and 5.51 Koa has no `maxIpsCount`; use the `trustedProxies` list there.
41
+ * **`trustedProxies: true`** (switch on, or `true` in `config/plugins.js`) no longer reads proxy headers. A stored `true` is changed to an empty list at start-up, a configured `true` is read as empty, and both log a warning. If you relied on `CF-Connecting-IP` or `X-Real-IP`, configure Koa (`proxy.ipHeader`, `maxIpsCount`) or list the proxy addresses.
42
+ * **Roles with plugin access only** can no longer change `maxFailedLogins`, `trustedProxies` or the email templates (403, `settings-update-permission`). Sending the stored values back still saves the rest of the form. Grant **Change protected settings** to roles that should change them.
43
+ * **`SESSION_ENCRYPTION_KEY` shorter than 32 bytes:** nothing breaks in this release, but every start logs an error, and the next major version will refuse to start. Plan the change before you upgrade to that major: generate a new key (`node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"`) and treat it as a key rotation. Stored encrypted tokens and webhook secrets become unreadable, so users sign in again and the webhook secret must be entered again.
44
+ * **Lockout:** refusals by other rules no longer count as failed sign-ins, and an own successful sign-in no longer clears the address. An address that signs in correctly most of the time but also fails often can now reach the IP threshold sooner. Add office or backend addresses to the trusted addresses.
45
+ * **Account lock:** trusted addresses are no longer refused or counted by the account counter.
46
+ * **Signed webhook:** changing the URL over the API needs `genericWebhookSecret` in the same request. A stored URL with a non-public IP literal is read as empty (it could never be delivered).
47
+ * **GraphQL:** clients that relied on mutations during an impersonation now get 403 `FORBIDDEN`.
48
+ * **"This wasn't me":** if your frontend rewrites or proxies the link, keep the `#token=…` fragment.
49
+
50
+ # [4.22.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.21.0...v4.22.0) (2026-11-25)
51
+
52
+
53
+ ### Features
54
+
55
+ * app-user security activity with its own permission, full page and Content Manager panel ([#43](https://github.com/Schero94/Magic-Sessionmanager/issues/43)) ([8716281](https://github.com/Schero94/Magic-Sessionmanager/commit/8716281cb2f9a5599be5579d9e51d39b50f3d49e))
56
+
57
+
58
+ Release type: minor (`feat`). Additive: one RBAC action (`user-activity.read`, "View app-user security activity"), two read-only admin routes and new admin screens; no stored data changes. Four app-user event labels are shorter (see Changed), and a refused request during an impersonation now names the impersonated user (see Changed).
59
+
60
+ ### Features
61
+
62
+ * **Security activity of app users.** The app-user events the plugin has written to the security log since 4.17 (failed and refused sign-ins, lockouts and unlocks, session limits, the sign-out after a password change, new devices, impossible travel, "This wasn't me", personal data exports and impersonations of app users) were recorded but shown nowhere. They now have three places, all with the 4.19 event table, details dialog, colours, filters, pagination and CSV export:
63
+ * **App users tab › Security activity**: the latest eight events with **Show all**.
64
+ * **Full page** `/plugins/magic-sessionmanager/app-users/activity`: filters for the kind of event (Failed and refused sign-ins, Lockouts and unlocks, New devices / impossible travel / "This wasn't me", Session limit and password change, Personal data exports, Impersonation), the period and one user (**Show only events of …** in the details), Strapi's pagination and CSV export. Filters, page and user are in the URL.
65
+ * **Content Manager › user › Sessions panel › Security activity**: the latest three events of that user and **Show all security activity**, which opens the page filtered to the user.
66
+ * **Plain words for every event.** Each event has its own label, colour and icon, and a second line that says what happened, for example "Account locked for 15 minutes after 5 failed sign-ins", "Session limit of 3 reached", "9100 km from the last sign-in, 4550 km/h · DE to US", "The user downloaded 4 sessions and 12 security events". The details dialog adds **What happened**, the user, who did it (an admin, or **Automatic**), the address, place, browser, operating system, user agent and event id, and **Open user** (Content Manager) when the reader may see the user. All text in English, German (Sie), French, Spanish and Portuguese.
67
+ * **New permission "View app-user security activity"** (`plugin::magic-sessionmanager.user-activity.read`, Settings › Roles › Plugins › Session Manager › General). Super Admin holds it automatically; other roles only when granted. It guards both new routes and every new screen; without it nothing is requested.
68
+ * **API.** `GET /magic-sessionmanager/user-activity` (`event` = `all`, `failed`, `lockouts`, `suspicious`, `sessions`, `privacy`, `impersonation`; `userId` = documentId; `from`, `to`, `page`, `pageSize` 1-100; unknown keys are a 400) and `GET /magic-sessionmanager/user-activity/export` (500-row keyset batches, `cursor`). Rows: `id`, `event`, `at`, `target`, `user` (`{ id, documentId, email, username }`), `actor` (`{ type: 'admin' | 'system', id, name }`), `details` (numbers and codes of the event), `ipAddress`, `ipAnonymized`, `location`, `browser`, `os`, `deviceType`, `userAgent`; `meta.identity` says what was visible.
69
+
70
+ ### Security and privacy
71
+
72
+ * **Identities as in Strapi (4.16.1 rules).** A user's email and username are returned only when the reader may read that user in the Content Manager (`plugin::content-manager.explorer.read` on `plugin::users-permissions.user`, including conditions and field-level permissions on `email` and `username`); otherwise the screens show "User #id". Admin names need `admin::users.read` ("Admin #id" otherwise). The reason an admin gave for an impersonation is returned only to readers who hold **Impersonate app users**. No entry titles, typed identifiers, device hashes, socket addresses or tokens are ever returned.
73
+ * **No admin data through the app-user view.** Events an admin caused (lock lifted, impersonation) store the admin's own request; their IP address, browser and user agent stay with the admin activity (**View admin activity**) and are never returned here.
74
+ * **Export audit.** Every export of the app-user activity records an always-on `security-log.read` event (`list: 'user-activity'`, `exported: true`, `via: 'admin-panel'` or `'admin-token'`); reads with an admin API token are recorded as for the admin lists since 4.17 (once per token and list within 5 minutes). The admin **Security activity** page shows them as **Security log exported** / **Log read with an API token** under **Settings and log access**.
75
+ * **Privacy settings apply when reading.** Events older than the security log retention are hidden at once (the daily retention run deletes them); with **Anonymise IP addresses** on, older full addresses are shown shortened; with **Store IP addresses** off, no address and no place is returned. No location is looked up when reading; a place appears only where the opt-in location lookup stored one.
76
+
77
+ ### Fixed
78
+
79
+ * **Keyboard access to the event tables (also the 4.19 admin lists).** The column headers did not pass on the grid coordinates the DS table gives its cells, so no cell had `tabIndex=0` and Tab skipped every Security activity, Sign-in history and Activity table; only a mouse could open an event's details. Tab now enters the table once, the arrow keys move between cells and Enter or Space on the eye opens the details, as in Strapi's own tables.
80
+ * **Filter chips.** The removable "Admin: …" / "User: …" filter used the DS Tag, whose remove button is 28 × 28 px; it is now a DS IconButton of 32 px (WCAG 2.5.8, the plugin's mobile rule).
81
+
82
+ ### Changed
83
+
84
+ * The labels of four app-user events are shorter, because they only appear in the App users view: "Sign-in failed", "Sign-in refused", "Locked out", "Lock lifted" (were "App user sign-in failed", "App user sign-in refused", "App user locked out", "Lockout lifted"). Impersonation events have one label each (started, ended, timed out, request refused) instead of one shared label.
85
+ * A request refused during an impersonation (`impersonation.refused`, `meta.refusal: call-*`) now stores the impersonated user as target instead of none, so it appears in that user's activity and is deleted with the account. Older rows keep `targetId: null` and show "Unknown account".
86
+ * Internal: the three security log lists share one event table component and one query schema module (`server/src/utils/event-query.js`); the admin lists look and behave as before.
87
+
88
+ ### Migration
89
+
90
+ * Nothing to do. Strapi adds the new permission to the Super Admin role at start-up. Grant **View app-user security activity** to other roles that should see the app-user events (it shows personal data: emails, IP addresses, devices).
91
+ * Webhook deliveries are not written to the security log, so the new view has no webhook events.
92
+
93
+ ### Tests
94
+
95
+ * `tests/isolated-user-activity-http.test.js` (real Strapi, SQLite and PostgreSQL in CI, and the 5.50 floor): RBAC (anonymous 401, Editor and access-only 403, Super Admin automatically 200, granted 200, revoked 403), a real failed sign-in, every event type and no admin event, email masking with field-level Content Manager permissions, admin names, the impersonation reason, filters and paging with 400s for bad input, keyset export with the export audit, admin API token audit, anonymise and IP-off at read time, retention at read time and deletion with the user.
96
+ * Unit tests for the server model, the service rows and the controller audit; admin model tests for every label, the second lines, URL state and CSV; StrictMode tests for the App users section, the full page and the Sessions panel (with and without the permission).
97
+
1
98
  # [4.21.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.20.0...v4.21.0) (2026-11-25)
2
99
 
3
100
 
package/README.md CHANGED
@@ -41,6 +41,7 @@ Live docs: [https://schero94.github.io/Magic-Sessionmanager/](https://schero94.g
41
41
  - [Examples](#examples)
42
42
  - [Optional route policy: `session-required`](#optional-route-policy-session-required)
43
43
  - [Admin API and permissions](#admin-api-and-permissions)
44
+ - [Security activity of app users](#security-activity-of-app-users)
44
45
  - [Admin activity and sign-in history](#admin-activity-and-sign-in-history)
45
46
  - [Impersonation](#impersonation)
46
47
  - [Running several instances (Railway replicas, pm2 cluster)](#running-several-instances-railway-replicas-pm2-cluster)
@@ -180,6 +181,7 @@ Strapi 5.62, synthetic admins `*.example.test`. The [gallery](https://schero94.g
180
181
  | Content Manager, User edit view | **Sessions** panel | What access does this user have, and how do I cut it off? |
181
182
  | Strapi homepage | **Online users** widget | Who is online right now? |
182
183
  | Session Manager › Admin panel | **Admin panel sessions** | Who is signed in to this admin panel, and how do I sign someone out? |
184
+ | Session Manager › App users | **Security activity of app users** | Which security events happened to my app's users, and to whom? |
183
185
  | Settings › Session Manager | **Configuration** | How should sessions and sign-ins behave? |
184
186
  | Settings › Session Manager | **Analytics** | How are sessions used over time and by device? |
185
187
 
@@ -225,6 +227,7 @@ Shown on the edit view of a Users & Permissions user only.
225
227
  - **End all sessions:** signs the user out on every device. The user can sign in again unless the account is blocked.
226
228
  - **Block user** / **Unblock user:** blocking ends all open sessions and prevents sign-in. The open form's Blocked field is updated, so a later Save does not undo it. Setting the native Blocked field and saving has the same effect.
227
229
  - Up to five open sessions, then **Show all sessions**, which opens the dashboard filtered by the user's email.
230
+ - **Security activity** (roles with "View app-user security activity"): the user's latest three security events and **Show all security activity**, which opens [Security activity of app users](#security-activity-of-app-users) filtered by this user.
228
231
  - For an unsaved user the panel only says "Save this user before you can manage sessions."
229
232
 
230
233
  ### Online users widget
@@ -384,7 +387,7 @@ Static defaults from `server/src/config/index.js`; admin units and ranges from t
384
387
  | `strictSessionEnforcement` | `false` (Relaxed) | boolean | Sessions | Strict rejects tokens without a session record and requests where the check itself fails. Ended, expired and revoked sessions and blocked users are rejected in both modes. |
385
388
  | `sessionCreationGraceMs` | `5000` | ms, 0 to 30000 (shown in seconds) | Sessions › Advanced | Window after sign-in in which a token is accepted while its record is being created. |
386
389
  | `maxFailedLogins` | 5 | 0 to 100, 0 = off | Login protection | Temporary IP lockout threshold (failed sign-ins from one IP within 15 minutes). |
387
- | `trustedProxies` | off | boolean | Login protection | Read the client IP from proxy headers. Only behind a proxy you control. |
390
+ | `trustedProxies` | empty | list of IP addresses or CIDR ranges | Login protection | Proxies that may name the client in `X-Forwarded-For` (4.22.1). Empty: Strapi's `server.proxy` settings decide. See [Client IP address](#client-ip-address). The former `true` is read as empty. Protected setting. |
388
391
  | `blockSuspiciousSessions` | `false` | boolean | Login protection | Reject suspicious sign-ins. Needs a [risk data source](#risk-data-vpn-proxy-tor); without one it is shown off and disabled, and the saved value is kept. |
389
392
  | `geoLookupFailureMode` | `'auto'` | auto, allow, block | Login protection | What happens when the location cannot be determined. |
390
393
  | `enableGeofencing` | `false` | boolean | Login protection | Use country rules. |
@@ -403,14 +406,14 @@ Static defaults from `server/src/config/index.js`; admin units and ranges from t
403
406
 
404
407
  ### Environment variables
405
408
 
406
- | Variable | Purpose |
407
- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
408
- | `SESSION_ENCRYPTION_KEY` | Key for AES-256-GCM encryption of stored tokens. Required when `NODE_ENV=production` (startup fails without it). Keep it stable. |
409
- | `MAGIC_SESSIONMANAGER_GEOIP_DATABASE` | Path of a local MaxMind-compatible database (also `GEOIP_DATABASE_PATH`, `GEOLITE2_CITY_MMDB`, `GEOIP_CITY_DATABASE_PATH`, `GEOLITE2_COUNTRY_MMDB`, `GEOIP_COUNTRY_DATABASE_PATH`). |
410
- | `MAXMIND_ACCOUNT_ID`, `MAXMIND_LICENSE_KEY` | MaxMind credentials for database updates. They take precedence over credentials stored in the admin. |
411
- | `MAGIC_SESSIONMANAGER_ANONYMOUS_IP_DATABASE` | Path of a GeoIP2 Anonymous IP database (risk data). Default: `data/magic-sessionmanager/geoip/GeoIP2-Anonymous-IP.mmdb`. |
412
- | `MAGIC_SESSIONMANAGER_ASN_DATABASE` | Path of a GeoLite2 ASN database (hosting heuristic). Default: `data/magic-sessionmanager/geoip/GeoLite2-ASN.mmdb`. |
413
- | `MAXMIND_EDITION_ID` | Edition for the CLI updater, for example `GeoLite2-City`. |
409
+ | Variable | Purpose |
410
+ | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
411
+ | `SESSION_ENCRYPTION_KEY` | Key for AES-256-GCM encryption of stored tokens; use at least 32 bytes. Required when `NODE_ENV=production` (startup fails without it). Since 4.22.1 a shorter key logs an error at every start and a **Weak encryption key** event; the next major version will refuse to start with it. Keep it stable. |
412
+ | `MAGIC_SESSIONMANAGER_GEOIP_DATABASE` | Path of a local MaxMind-compatible database (also `GEOIP_DATABASE_PATH`, `GEOLITE2_CITY_MMDB`, `GEOIP_CITY_DATABASE_PATH`, `GEOLITE2_COUNTRY_MMDB`, `GEOIP_COUNTRY_DATABASE_PATH`). |
413
+ | `MAXMIND_ACCOUNT_ID`, `MAXMIND_LICENSE_KEY` | MaxMind credentials for database updates. They take precedence over credentials stored in the admin. |
414
+ | `MAGIC_SESSIONMANAGER_ANONYMOUS_IP_DATABASE` | Path of a GeoIP2 Anonymous IP database (risk data). Default: `data/magic-sessionmanager/geoip/GeoIP2-Anonymous-IP.mmdb`. |
415
+ | `MAGIC_SESSIONMANAGER_ASN_DATABASE` | Path of a GeoLite2 ASN database (hosting heuristic). Default: `data/magic-sessionmanager/geoip/GeoLite2-ASN.mmdb`. |
416
+ | `MAXMIND_EDITION_ID` | Edition for the CLI updater, for example `GeoLite2-City`. |
414
417
 
415
418
  ---
416
419
 
@@ -514,11 +517,20 @@ Requests with an ended session get **401** with the header `X-Session-Terminated
514
517
  ### Lockout, trusted addresses and Locked now
515
518
 
516
519
  - **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.
517
- - 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.
520
+ - **What counts (4.22.1).** Only a wrong identifier or password counts, on every spelling of `POST /api/auth/local` (`/api/auth/local/`, `/API/auth/local`, …) and the GraphQL `login` mutation: the check runs inside Users & Permissions' `auth.callback`, which all of them call. A sign-in refused by another rule (session limit, country rules, a blocked or unconfirmed account) is not a failed guess. A successful sign-in clears the account counter, never the address counter, so signing in to an own account does not reset an address. IPv6 addresses count per /64.
521
+ - Anyone who knows an account name can lock that account for others. Since 4.22.1 the owner still signs in from a trusted address or from a known device (a device id the app sent with an earlier successful sign-in of that account). Keep the account threshold higher than the IP threshold; admins can lift a lock at once.
518
522
  - **Window and duration**: `lockoutWindowMinutes` (1-1440) and `lockoutDurationMinutes` (1-10080). When a lock ends, the failures that caused it no longer count.
519
- - **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.
523
+ - **Trusted addresses** (`lockoutTrustedAddresses`, up to 100 IPs or CIDR ranges such as `192.0.2.0/24` or `2001:db8::/32`) are never counted or locked, by IP or (since 4.22.1) by account. Use it for an office NAT or a backend that signs in for many users.
520
524
  - **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.
521
- - **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}}`).
525
+ - **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), at most once per account per window (the longer of window and lock duration). The text is the **Account locked** template under Alerts › Email templates (`{{user.email}}`, `{{user.username}}`, `{{lock.minutes}}`, `{{lock.until}}`).
526
+
527
+ ### Client IP address
528
+
529
+ Every IP rule (lockout, rate limits, location rules) and every stored address uses one client address (4.22.1):
530
+
531
+ - **Default (`trustedProxies` empty):** Strapi's `ctx.request.ip`. Koa takes it from the socket, or, with `server.proxy.koa: true`, from `server.proxy.ipHeader` (default `X-Forwarded-For`) limited to the last `server.proxy.maxIpsCount` entries. Set `maxIpsCount` to the number of proxies in front of Strapi (Strapi 5.52+); see [the example](#client-ip-address-and-reverse-proxies). The plugin reads no proxy header itself, so `CF-Connecting-IP`, `True-Client-IP`, `X-Real-IP` or a left-most `X-Forwarded-For` entry sent by a client change nothing.
532
+ - **`trustedProxies`: a list of your proxies' addresses or CIDR ranges** (up to 50, Login protection › Client IP address). A request whose TCP peer is on the list uses the right-most `X-Forwarded-For` entry that is not on the list; a request from any other peer uses the peer's address, even when Koa trusts proxy headers. Use it when the proxy addresses are known but the number of hops varies.
533
+ - Up to 4.22 `trustedProxies: true` made the plugin read client-set headers. A stored `true` is changed to an empty list at start-up, a configured `true` is read as empty, and both log a warning.
522
534
 
523
535
  ### Concurrent session limit
524
536
 
@@ -554,7 +566,7 @@ Configuration › Alerts. Both kinds are sent only when location data is availab
554
566
 
555
567
  - **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.
556
568
  - **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.
557
- - **"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.
569
+ - **"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. Since 4.22.1 the token is in the URL fragment, which browsers never send to the server, so it does not appear in access logs; a script allowed by its CSP hash copies it into the form. Links with `?token=` from earlier emails still work until they expire: if your proxy or Strapi logs query strings, redact `token=` there. 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.
558
570
 
559
571
  ### Signed webhook
560
572
 
@@ -585,7 +597,7 @@ function verifyMagicSignature(secret, rawBody, header, toleranceSeconds = 300) {
585
597
  }
586
598
  ```
587
599
 
588
- 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.
600
+ 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, contain credentials or (since 4.22.1) name a non-public IP address, 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, unique-local, IPv4-compatible or IPv4-translated IPv6 address); it then connects to the checked address, does not follow redirects, times out after 5 seconds without data or 10 seconds in total, and reads at most 64 KB of the answer. A new URL is saved only together with the secret (4.22.1), so the stored secret never signs events for another host. Network errors, timeouts, 429 and 5xx are retried after 2 and 10 seconds. **Send test** sends one `test` event and shows the result.
589
601
 
590
602
  Example email provider configuration:
591
603
 
@@ -616,18 +628,18 @@ export default ({ env }) => ({
616
628
 
617
629
  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`).
618
630
 
619
- | Method | Path | Purpose | Response |
620
- | --------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
621
- | GET | `/my-sessions` | Own sessions (up to 200), current session first | `{ data: [...], meta: { count, active, hasMore, limit } }` |
622
- | GET | `/current-session` | The session of the current token | `{ data: {..., isCurrentSession: true } }`; 404 when none |
623
- | GET | `/user/:userId/sessions` | Sessions of a user; only your own `userId` | 403 for another user |
624
- | POST | `/logout` | End the current session (reason `logout`) | `{ message, terminated }` |
625
- | POST | `/logout-all` | End all own sessions (reason `logout`) | `{ message, terminatedCount }` |
626
- | POST | `/logout-others` | End all own sessions except the current one | `{ message, terminatedCount, currentSessionPreserved }` |
627
- | 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 |
628
- | 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 |
629
- | 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 |
630
- | POST | `/impersonation/exchange` | **Public** (no JWT): exchanges the one-time code of the [impersonation](#impersonation) hand-off, `{ code }`; 10 per minute per IP | `{ data: { jwt, refreshToken?, expiresAt, user, impersonation } }`; 400 for any unusable code |
631
+ | Method | Path | Purpose | Response |
632
+ | --------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
633
+ | GET | `/my-sessions` | Own sessions (up to 200), current session first | `{ data: [...], meta: { count, active, hasMore, limit } }` |
634
+ | GET | `/current-session` | The session of the current token | `{ data: {..., isCurrentSession: true } }`; 404 when none |
635
+ | GET | `/user/:userId/sessions` | Sessions of a user; only your own `userId` | 403 for another user |
636
+ | POST | `/logout` | End the current session (reason `logout`) | `{ message, terminated }` |
637
+ | POST | `/logout-all` | End all own sessions (reason `logout`) | `{ message, terminatedCount }` |
638
+ | POST | `/logout-others` | End all own sessions except the current one | `{ message, terminatedCount, currentSessionPreserved }` |
639
+ | 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 |
640
+ | 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; an impersonation shows only "An administrator opened your account", the time and the duration (4.22.1), never the admin or the reason |
641
+ | 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 |
642
+ | POST | `/impersonation/exchange` | **Public** (no JWT): exchanges the one-time code of the [impersonation](#impersonation) hand-off, `{ code }`; 10 per minute per IP | `{ data: { jwt, refreshToken?, expiresAt, user, impersonation } }`; 400 for any unusable code |
631
643
 
632
644
  `POST /api/auth/logout` also ends the current session; the plugin mounts it when Users & Permissions does not provide it.
633
645
 
@@ -761,6 +773,7 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
761
773
  | `plugin::magic-sessionmanager.admin-sessions.read` | Read admin panel sessions | The Admin panel view and its two GET routes |
762
774
  | `plugin::magic-sessionmanager.admin-sessions.revoke` | Sign out admins | **Sign out** and **Sign out everywhere** (also needs read) |
763
775
  | `plugin::magic-sessionmanager.admin-activity.read` | View admin activity | Sign-in history, Activity, Recent security activity and the Security activity page, CSV exports and changing the Admin activity settings (also needs read) |
776
+ | `plugin::magic-sessionmanager.user-activity.read` | View app-user security activity | **Security activity** on the App users tab and in the user's Sessions panel, the full page and its CSV export (also needs `access`, not `admin-sessions.read`); see [Security activity of app users](#security-activity-of-app-users) |
764
777
  | `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 |
765
778
  | `plugin::magic-sessionmanager.lockouts.unlock` | Unlock locked sign-ins | **Unlock** in Login protection › Locked now (also needs `access`) |
766
779
  | `plugin::magic-sessionmanager.impersonate.users` | Impersonate app users | Starting, listing and ending impersonations of app users (also needs `access` and the **Allow impersonation** switch); see [Impersonation](#impersonation). Since 4.20 |
@@ -768,7 +781,7 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
768
781
 
769
782
  **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.
770
783
 
771
- **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`), and `impersonationEnabled` (4.20). 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.
784
+ **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`), and `impersonationEnabled` (4.20), and since 4.22.1 `trustedProxies`, `maxFailedLogins` (the IP threshold) and `emailTemplates` (the alert texts go to app users from your address). 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.
772
785
 
773
786
  | Method | Path | Admin UI action |
774
787
  | -------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -800,6 +813,8 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
800
813
  | GET | `/admin-activity/sign-ins/export` | CSV export batches of 500 rows, newest first; same filters plus `cursor`; follow `meta.nextCursor` |
801
814
  | 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` |
802
815
  | GET | `/admin-activity/content/export` | CSV export batches of 500 rows; same filters plus `cursor` |
816
+ | GET | `/user-activity` | **Security activity of app users**: `event` (`all`, `failed`, `lockouts`, `suspicious`, `sessions`, `privacy`, `impersonation`), `userId` (documentId), `from`, `to`, `page`, `pageSize` (1-100); needs `user-activity.read` |
817
+ | GET | `/user-activity/export` | CSV export batches of 500 rows; same filters plus `cursor`; the first batch of every export is recorded in the security log |
803
818
  | GET | `/lockouts` | **Locked now**: `{ data: [{ id, kind: 'ip' \| 'account', ip, user, failures, lockedAt, until }] }`; read rate limit |
804
819
  | POST | `/lockouts/unlock` | **Unlock**: body `{ id }` from the list; needs `lockouts.unlock`; 404 when the lock already ended; 10 per minute |
805
820
  | GET | `/roles` | Users & Permissions roles (without Public) for **Different rules for some roles** |
@@ -826,15 +841,40 @@ Errors use Strapi's `{ data: null, error }` envelope: 400 for invalid input, 404
826
841
 
827
842
  ---
828
843
 
844
+ ## Security activity of app users
845
+
846
+ Since 4.17 the plugin writes app-user events to its security log; since 4.22 they are shown. Open **Session Manager** (the App users view) and scroll to **Security activity**: the latest eight events, newest first, with **Show all**. The same events of one user are in the user's **Sessions** panel in the Content Manager.
847
+
848
+ | Event | Shown as | Second line (example) |
849
+ | ------------------------------------------------------------ | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
850
+ | `user.sign-in.failed` | Sign-in failed | No account with this email or username |
851
+ | `user.sign-in.refused` | Sign-in refused | Session limit of 3 reached; Risky address (VPN, proxy or Tor); Sign-ins from this country are blocked |
852
+ | `user.lockout` | Locked out | Account locked for 15 minutes after 5 failed sign-ins |
853
+ | `user.lockout.lifted` | Lock lifted | An admin unlocked the account · by Ada Example |
854
+ | `user.session.limit` | Session limit reached | 1 older session ended to stay within 2 |
855
+ | `user.password-change.ended-others` | Signed out after a password change | 2 other sessions ended |
856
+ | `user.sign-in.new-device` | Sign-in from a new device | Firefox 133 on Linux (device column) |
857
+ | `user.sign-in.impossible-travel` | Impossible travel | 9100 km from the last sign-in, 4550 km/h · DE to US |
858
+ | `user.not-me` | Reported as "This wasn't me" | The user ended all their sessions |
859
+ | `user.data.exported` | Personal data exported | The user downloaded 4 sessions and 12 security events |
860
+ | `impersonation.started` / `.ended` / `.expired` / `.refused` | Impersonation started / ended / timed out / request refused | For 30 minutes; Ended by an admin; A sign-in, password or email request was blocked |
861
+
862
+ Red marks a security signal (failed, refused, locked, impossible travel, "This wasn't me", refused impersonation), amber a rule that ended sessions or a running impersonation, blue information (new device, data export, lock lifted), grey the end of an impersonation.
863
+
864
+ - **Full page** (`/plugins/magic-sessionmanager/app-users/activity`): the same table across the width with **Time**, **Event** (badge and what happened), **User**, **IP address and device** and **Done by** (an admin, or **Automatic**). Filters: kind of event, period, one user (**Show only events of …** in the details, removable tag). Strapi's pagination; filters, page and user live in the URL, so `?userId=<documentId>` is a shareable link. **Export CSV** exports every event that matches the filters (up to 10,000 newest).
865
+ - **Details** (row click or the eye button): the exact time, **What happened**, the user, who did it, the address, place, browser, operating system, user agent and event id, and **Open user** when you may see the user.
866
+ - **Below about 800 px** the table becomes stacked rows; the Sessions panel always uses them.
867
+ - **Permission:** "View app-user security activity" (`user-activity.read`); Super Admin has it automatically. Without it, the section, the page and the panel section are not shown and nothing is requested. Identities, retention and IP rules: see [What is recorded](#what-is-recorded-fact-sheet-for-data-protection-and-works-councils).
868
+
829
869
  ## Admin activity and sign-in history
830
870
 
831
871
  Since 4.15 the plugin keeps a **security log**: one table (`plugin::magic-sessionmanager.security-event`, collection `magic_sessions_security_events`, hidden from the Content Manager and the Content-Type Builder) where every event has an actor (`actorType` `admin`/`user`/`system`, `actorId`), a target (`targetType`, `targetId`), an `event` name, `ip`, `userAgent`, `geo`, a small `meta` object (at most 16 plain values, 2 KB) and `createdAt`. It is indexed on actor, target, event and time. The admin panel uses it for two things:
832
872
 
833
- | Recorded | Events | Default |
834
- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
835
- | **Admin sign-in history** | `admin.sign-in`, `admin.sign-in.failed` (reason), `admin.lockout`, `admin.sign-out`, `admin.session.revoked` (who signed out whom, one browser or everywhere) | On |
836
- | **Content Manager activity** | `admin.content.view` (opening an entry), `.create`, `.update`, `.publish`, `.unpublish`, `.discard`, `.delete`, `.clone`, with content type, document id and locale | **Off** |
837
- | **Changes to the log itself** (4.17) | `settings.updated` (who changed which settings keys, never the values), `security-log.retention.purged` (how many events the daily job deleted), `security-log.read` (a read of the history with an admin API token, once per token and list per 5 minutes) | Always |
873
+ | Recorded | Events | Default |
874
+ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
875
+ | **Admin sign-in history** | `admin.sign-in`, `admin.sign-in.failed` (reason), `admin.lockout`, `admin.sign-out`, `admin.session.revoked` (who signed out whom, one browser or everywhere) | On |
876
+ | **Content Manager activity** | `admin.content.view` (opening an entry), `.create`, `.update`, `.publish`, `.unpublish`, `.discard`, `.delete`, `.clone`, with content type, document id and locale | **Off** |
877
+ | **Changes to the log itself** (4.17) | `settings.updated` (who changed which settings keys, never the values), `security-log.retention.purged` (how many events the daily job deleted), `security-log.read` (a read of the history with an admin API token, once per token and list per 5 minutes), `config.encryption-key.weak` (4.22.1: `SESSION_ENCRYPTION_KEY` is shorter than 32 bytes, once per key) | Always |
838
878
 
839
879
  The changes to the log itself belong to no single admin's history: they are listed on the **Security activity** page (filter **Settings and log access**, also part of **All events**) and in **Recent security activity**, never in the Sign-in history tab of one admin.
840
880
 
@@ -981,7 +1021,8 @@ The code is 32 random bytes, stored only as a SHA-256 hash, valid for 60 seconds
981
1021
  - every `/api/auth/*` route except `POST /api/auth/refresh` and `GET /api/auth/sessions`: password change, reset and forgot-password, email confirmation, sign-in, registration, provider sign-in, logout and ending sessions; also `/api/connect/*`;
982
1022
  - `POST`, `PUT` and `DELETE` on `/api/users` and `/api/users/:id` (email, password and account changes, account deletion);
983
1023
  - the plugin's own routes except the three reads (`/my-sessions`, `/current-session`, `/user/:userId/sessions`): logout, ending own sessions, the data export `GET /my-data`, "This wasn't me" links and the exchange itself (no nesting);
984
- - Magic Link and passwordless sign-in routes, and GraphQL mutations that sign in, register or change the password or the user (`login`, `register`, `changePassword`, `updateUsersPermissionsUser`, …).
1024
+ - Magic Link and passwordless sign-in routes;
1025
+ - **every GraphQL mutation** (4.22.1), refused inside Apollo after it has resolved the operation, so aliases, fragments, persisted queries and batched requests are covered: 403, `errors[0].extensions.code` `FORBIDDEN`, `extensions.error.details.reason` `impersonation-mutation`. GraphQL queries work as for the user. The plugin adds this Apollo plugin to `plugin::graphql.apolloServer.plugins` at start-up, next to yours. Up to 4.22 GraphQL mutations were not restricted.
985
1026
 
986
1027
  Everything else of your API works as for the user. An ended or expired impersonation gets 401 with `impersonation-ended` or `impersonation-expired`.
987
1028
 
@@ -1037,7 +1078,7 @@ body[data-impersonating]::before {
1037
1078
  **Anti-escalation (server-side).** Refused with 403 and `details.reason`:
1038
1079
 
1039
1080
  - `self`: nobody views themselves;
1040
- - `super-admin`: nobody views a Super Admin, Super Admins included;
1081
+ - `super-admin`: nobody views a Super Admin, Super Admins included. Since 4.22.1 a caller without `admin::users.read` gets the same 404 as for an unknown id, so the preview does not reveal which admins are Super Admins;
1041
1082
  - `not-subset`: a non-Super-Admin views only an admin whose every effective permission they hold themselves (`details.uncovered` counts the others). The comparison follows Strapi's own permission ceiling rules: conditions are OR-ed, so a conditional permission does not cover an unconditional one; a property the holder does not restrict covers every value; a parent field covers its nested fields; unregistered conditions and, on localized types, missing locales are read the way the engine enforces them. A test compares it with Strapi 5.63's `isPermissionWithinCeiling` on more than 20,000 permission pairs;
1042
1083
  - `api-token`: admin API tokens cannot start one;
1043
1084
  - nesting is impossible: a preview creates no credential, and an app-user impersonation token cannot reach admin routes (401).
@@ -1086,7 +1127,7 @@ What stays per process, by design: the fail-open error budget in Relaxed token c
1086
1127
  });
1087
1128
  ```
1088
1129
 
1089
- With `proxy.koa` on, the plugin reads the client IP from the proxy headers (`CF-Connecting-IP`, `X-Real-IP`, then the first `X-Forwarded-For` entry). Only enable it behind a proxy you control.
1130
+ With `proxy.koa` on, Koa reads the client IP from `X-Forwarded-For`, limited to the last `maxIpsCount` entries; the plugin uses that address (see [Client IP address](#client-ip-address)). Only enable it behind a proxy you control.
1090
1131
 
1091
1132
  4. **pm2 in cluster mode** (one container or VM):
1092
1133
 
@@ -1221,7 +1262,7 @@ The plugin sits in the request path of every authenticated Content API call, so
1221
1262
 
1222
1263
  ## Security and privacy
1223
1264
 
1224
- - **Encryption key.** Stored tokens are encrypted with AES-256-GCM using `SESSION_ENCRYPTION_KEY`. In production, startup fails without it. Outside production a derived development key is used with a warning. Changing the key makes existing encrypted tokens unreadable, so keep it stable. Generate one in **Configuration › Sessions › Advanced** ("Copy for .env" copies `SESSION_ENCRYPTION_KEY="…"`; nothing is saved in Strapi) or with:
1265
+ - **Encryption key.** Stored tokens are encrypted with AES-256-GCM using `SESSION_ENCRYPTION_KEY`. In production, startup fails without it. Outside production a derived development key is used with a warning. Use at least 32 random bytes: a shorter key still works in 4.x but logs an error at every start and is recorded once in the security log (`config.encryption-key.weak`); the next major version will refuse it. Changing the key makes existing encrypted tokens unreadable, so keep it stable. Generate one in **Configuration › Sessions › Advanced** ("Copy for .env" copies `SESSION_ENCRYPTION_KEY="…"`; nothing is saved in Strapi) or with:
1225
1266
 
1226
1267
  ```bash
1227
1268
  node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
@@ -1245,20 +1286,22 @@ The plugin sits in the request path of every authenticated Content API call, so
1245
1286
 
1246
1287
  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.
1247
1288
 
1248
- | Data | When it is recorded | Where | Kept for | Who can see it | Switch |
1249
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
1250
- | 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** |
1251
- | 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 |
1252
- | 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) |
1253
- | 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 |
1254
- | Unknown-account sign-ins | Once per anonymised address per 5 minutes | Same log, without account and without the typed name | Same | Same | Same |
1255
- | 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 |
1256
- | "Locked now" entries | While a lock lasts | `magic_sm_cache` | Until the lock ends | Admins with plugin access | Follows the log's IP options |
1257
- | 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) |
1258
- | Impersonations: admin, user, reason, duration, start and end; refused starts and refused requests | When an admin impersonates a user | `magic_sessions_impersonations` and the security log | Table: 7 days after the end; log: `securityLogRetentionDays` | Admins with **Impersonate app users** (list), **View admin activity** (log) | **Allow impersonation** (off) |
1289
+ | Data | When it is recorded | Where | Kept for | Who can see it | Switch |
1290
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
1291
+ | 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** |
1292
+ | 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 |
1293
+ | 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) |
1294
+ | 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 app-user security activity** (emails only with Content Manager read access to users), the user (own-data export) | **Record failed and refused sign-ins** (on) for failed/refused/locks; the others only while their feature is on |
1295
+ | Unknown-account sign-ins | Once per anonymised address per 5 minutes | Same log, without account and without the typed name | Same | Same | Same |
1296
+ | 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 |
1297
+ | "Locked now" entries | While a lock lasts | `magic_sm_cache` | Until the lock ends | Admins with plugin access | Follows the log's IP options |
1298
+ | 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) |
1299
+ | Impersonations: admin, user, reason, duration, start and end; refused starts and refused requests | When an admin impersonates a user | `magic_sessions_impersonations` and the security log | Table: 7 days after the end; log: `securityLogRetentionDays` | Admins with **Impersonate app users** (list), **View admin activity** (log) | **Allow impersonation** (off) |
1259
1300
 
1260
1301
  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.
1261
1302
 
1303
+ **Security activity of app users (4.22).** These app-user events are shown in Session Manager › App users › Security activity, on its full page and in each user's Sessions panel, to roles with **View app-user security activity** only (Super Admin by default). The view shows the user's email and username only to admins who may read that user in the Content Manager (otherwise "User #id"), admin names only with Strapi's **Read** permission on Users, and an impersonation reason only to admins who may impersonate. It follows the security log settings when it reads: events older than `securityLogRetentionDays` are hidden at once, **Anonymise IP addresses** also shortens older addresses, and with **Store IP addresses** off no address or place is shown. It never looks up a location; a place appears only where the opt-in location lookup stored one. Events an admin caused (lock lifted, impersonation) show no IP address or browser in this view: those would be the admin's own, which stay behind **View admin activity**. Every CSV export (and every read with an admin API token) is itself recorded in the security log with the admin who did it (**Security log exported** under Settings and log access). Webhook deliveries are not recorded.
1304
+
1262
1305
  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.
1263
1306
 
1264
1307
  ## Troubleshooting
@@ -1376,6 +1419,8 @@ SESSION_HTTP_REQUIRED=1 SESSION_HTTP_STRAPI_NODE_MODULES=$PWD/node_modules node
1376
1419
 
1377
1420
  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.
1378
1421
 
1422
+ The app-user activity suite (`tests/isolated-user-activity-http.test.js`) checks RBAC (Super Admin automatically, 403 without the permission, 200 when granted), email masking with field-level Content Manager permissions, the export audit, filters, paging and the read-time privacy rules.
1423
+
1379
1424
  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.
1380
1425
 
1381
1426
  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**.
@@ -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-Ceh3Q1Ki.js");
12
+ const index = require("./index-qtN2dOm4.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 { W 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, H as EqualGrid, b as getTranslation, X as getDeviceTypeMessage } from "./index-meLDPPwt.mjs";
10
+ import { aN as normalizeDeviceType, u as useSessionFormatters, f as pluginId, F as isCancelledRequest, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, Q as PageShell, T as StatGrid, W as StatCard, au as EqualGrid, b as getTranslation, aO as getDeviceTypeMessage } from "./index-DVQ7tdTC.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;