strapi-plugin-magic-sessionmanager 4.19.1 → 4.20.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +136 -1
  3. package/dist/admin/{Analytics-BqFlgLnN.mjs → Analytics-B-MVQ6dQ.mjs} +1 -1
  4. package/dist/admin/{Analytics-BElmzyNJ.js → Analytics-B5GnwMtH.js} +1 -1
  5. package/dist/admin/{App-0thsC_P9.mjs → App-DzbP5VPQ.mjs} +2 -2
  6. package/dist/admin/{App-D_J2eeEG.js → App-xBOmg4g9.js} +2 -2
  7. package/dist/admin/{OnlineUsersWidget-BgJ1ws-5.mjs → OnlineUsersWidget-Bf3BICmx.mjs} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-DMZBwqdY.js → OnlineUsersWidget-FuPPPCCV.js} +1 -1
  9. package/dist/admin/{Settings-FOkui_ke.js → Settings-WRIXHLDa.js} +280 -65
  10. package/dist/admin/{Settings-QN3Mu4AQ.mjs → Settings-hpkloyO6.mjs} +250 -35
  11. package/dist/admin/{de-uGKSKVYD.mjs → de-Bzd14FzX.mjs} +63 -1
  12. package/dist/admin/{de-CEyi4lpp.js → de-Uqb30N5n.js} +63 -1
  13. package/dist/admin/{en-CSXeJYKy.js → en-CDBcocLk.js} +63 -1
  14. package/dist/admin/{en-Yu7tfwqx.mjs → en-DovyVwa5.mjs} +63 -1
  15. package/dist/admin/{es-iNG9Amf9.mjs → es-BygJxl1J.mjs} +63 -1
  16. package/dist/admin/{es-BrKqXhAU.js → es-DA1X0RPv.js} +63 -1
  17. package/dist/admin/{fr-DKZNfdlH.js → fr-CPPA27jW.js} +63 -1
  18. package/dist/admin/{fr-CaFICHlf.mjs → fr-DONxL73-.mjs} +63 -1
  19. package/dist/admin/{index-h-ksmM8A.mjs → index-DsaGGK7x.mjs} +627 -61
  20. package/dist/admin/{index-DEYtqPc3.js → index-Q_D-5LlE.js} +612 -46
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +2 -2
  23. package/dist/admin/{pt-IEagyVDL.js → pt-BMuwyaan.js} +63 -1
  24. package/dist/admin/{pt-Bz2hWVrq.mjs → pt-D2yGNz2N.mjs} +63 -1
  25. package/dist/admin/{settingsTabs-D02CuEvs.mjs → settingsTabs--7IsqMdn.mjs} +5 -1
  26. package/dist/admin/{settingsTabs-N4TFn-mw.js → settingsTabs-Dxlevody.js} +5 -1
  27. package/dist/server/index.js +1485 -19
  28. package/dist/server/index.mjs +1485 -19
  29. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # [4.20.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.19.1...v4.20.0) (2026-11-25)
2
+
3
+
4
+ ### Features
5
+
6
+ * impersonate app users with a one-time hand-off, restrictions and audit ([#41](https://github.com/Schero94/Magic-Sessionmanager/issues/41)) ([940e6f3](https://github.com/Schero94/Magic-Sessionmanager/commit/940e6f316be961bd69c42734fbd97171245cdbc4))
7
+
8
+
9
+ Release type: minor (`feat`: impersonation of app users). Additive: a new RBAC action, four admin routes, one public Content API route, a new internal content type and a settings key that is off by default. No existing route, response or permission changes.
10
+
11
+ ### Features
12
+
13
+ * **Impersonate app users.** Admins whose role holds the new permission **Impersonate app users** (Settings › Roles › Plugins › Session Manager › Impersonation; Super Admin holds it automatically) can act as a Users & Permissions user for 15, 30 or 60 minutes to reproduce a problem. **Impersonate…** in the user's Sessions panel in the Content Manager asks for a reason (3 to 255 characters), the duration and whether to email the user, then hands over a short-lived credential once.
14
+ * **Short-lived credential only.** In refresh mode (`jwtManagement: 'refresh'`) a Strapi session is created through `strapi.sessionManager('users-permissions')` on its own device id and marked in the session metadata, which Strapi keeps across refresh; in legacy mode a JWT whose `exp` is the end of the impersonation. Both get a Magic session row. The user's password is never touched or shown, and no long-lived token is issued.
15
+ * **Frontend hand-off.** With `impersonation.frontendUrl` in the plugin config (https only, origin on `impersonation.allowedFrontendOrigins`), the admin panel posts a one-time code to that URL in a new tab (HTTP POST, never in a URL). The frontend exchanges it at `POST /api/magic-sessionmanager/impersonation/exchange` within 60 seconds; the code is stored as a hash and works once (atomic). Without the setting the token is shown once with a copy button and a warning.
16
+ * **What an impersonation cannot do.** A global middleware refuses, with 403 and `details.reason` `impersonation-credentials`, `-account` or `-sessions`: every `/auth/*` route except `POST /auth/refresh` and `GET /auth/sessions` (password change and reset, email confirmation, sign-in, register, providers, logout, ending sessions), `/connect/*`, writes to `/users`, the plugin's own write routes (logout, ending own sessions), the data export (`GET /my-data`), "This wasn't me" links, Magic Link and passwordless sign-in, and GraphQL mutations of that kind. Every response carries `X-Magic-Impersonation: true`.
17
+ * **Ending.** Impersonations end at their time (request check plus a sweep every 30 seconds), with **End impersonation** in the dialog, in the Sessions panel, or in the new list **Settings › Session Manager › Impersonation › Active impersonations**, and all at once when the switch is turned off.
18
+ * **Switch and security log.** The new **Impersonation** settings tab has **Allow impersonation**, off by default and a protected setting (`settings.update`). `impersonation.started`, `.ended`, `.expired` and `.refused` go to the security log with the real admin as actor, the user as target, the reason and the duration; no code or token. The events stay when the admin's account is deleted.
19
+ * **Limits.** Ten starts per admin per ten minutes; ten code exchanges per minute per IP address. Admin API tokens cannot impersonate.
20
+
21
+ ### Migration
22
+
23
+ * Nothing to do. The feature stays off until a Super Admin turns on **Allow impersonation**. A new table `magic_sessions_impersonations` is created at start-up. To use the frontend hand-off, add `impersonation.frontendUrl` to the plugin config and expose the `X-Magic-Impersonation` header through `strapi::cors` (see README › Impersonation).
24
+
1
25
  ## [4.19.1](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.19.0...v4.19.1) (2026-11-25)
2
26
 
3
27
 
package/README.md CHANGED
@@ -42,6 +42,7 @@ Live docs: [https://schero94.github.io/Magic-Sessionmanager/](https://schero94.g
42
42
  - [Optional route policy: `session-required`](#optional-route-policy-session-required)
43
43
  - [Admin API and permissions](#admin-api-and-permissions)
44
44
  - [Admin activity and sign-in history](#admin-activity-and-sign-in-history)
45
+ - [Impersonation](#impersonation)
45
46
  - [Running several instances (Railway replicas, pm2 cluster)](#running-several-instances-railway-replicas-pm2-cluster)
46
47
  - [Performance](#performance)
47
48
  - [Security and privacy](#security-and-privacy)
@@ -626,6 +627,7 @@ Prefix `/api/magic-sessionmanager`. Every route requires a Users & Permissions J
626
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 |
627
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 |
628
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 |
629
631
 
630
632
  `POST /api/auth/logout` also ends the current session; the plugin mounts it when Users & Permissions does not provide it.
631
633
 
@@ -761,10 +763,11 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
761
763
  | `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) |
762
764
  | `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
765
  | `plugin::magic-sessionmanager.lockouts.unlock` | Unlock locked sign-ins | **Unlock** in Login protection › Locked now (also needs `access`) |
766
+ | `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 |
764
767
 
765
768
  **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.
766
769
 
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.
770
+ **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.
768
771
 
769
772
  | Method | Path | Admin UI action |
770
773
  | -------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -799,6 +802,10 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
799
802
  | GET | `/lockouts` | **Locked now**: `{ data: [{ id, kind: 'ip' \| 'account', ip, user, failures, lockedAt, until }] }`; read rate limit |
800
803
  | POST | `/lockouts/unlock` | **Unlock**: body `{ id }` from the list; needs `lockouts.unlock`; 404 when the lock already ended; 10 per minute |
801
804
  | GET | `/roles` | Users & Permissions roles (without Public) for **Different rules for some roles** |
805
+ | GET | `/impersonation/status` | `{ data: { enabled, handoff: 'frontend' \| 'token', frontendOrigin, durations, mode } }` |
806
+ | POST | `/impersonation/users/:userId` | **Start impersonation**: body `{ reason, durationMinutes: 15 \| 30 \| 60, notifyUser? }`; needs `impersonate.users`; signed-in admins only; 201 `{ data: { impersonation, handoff } }` (`Cache-Control: no-store`); 10 per 10 minutes |
807
+ | GET | `/impersonation/active` | **Active impersonations**: `{ data: [{ id, targetType, targetId, targetLabel, actorId, actorLabel, startedByYou, reason, durationMinutes, handoff, credentialIssued, startedAt, expiresAt, state }] }`; needs `impersonate.users` |
808
+ | POST | `/impersonation/:id/end` | **End impersonation**: `{ data: { ended } }`; needs `impersonate.users`; 404 for unknown ids |
802
809
 
803
810
  **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.
804
811
 
@@ -896,6 +903,132 @@ Measured with `scripts/bench-admin-activity.cjs` (Strapi 5.63, SQLite, Node 22,
896
903
 
897
904
  The difference is within the run-to-run noise: recording adds no measurable latency, because the request only pushes an object onto the queue.
898
905
 
906
+ ## Impersonation
907
+
908
+ Support staff sometimes need to see the app exactly as a user sees it. Since 4.20 an admin can act as a Users & Permissions user for a limited time, with a reason that is recorded. Off by default.
909
+
910
+ **Turn it on.** Settings › Session Manager › **Impersonation** › **Allow impersonation** (a protected setting: needs **Change protected settings**). Then grant **Impersonate app users** (`plugin::magic-sessionmanager.impersonate.users`) to the roles that may use it under Settings › Administration Panel › Roles › Plugins › Session Manager › Impersonation. The Super Admin role holds it automatically, like every plugin permission; other roles get 403 until it is granted. Turning the switch off ends every running impersonation at once.
911
+
912
+ **Start one.** Open the user in the Content Manager. The Sessions panel shows **Impersonate…** (only with the permission and the switch on). Enter a reason (3 to 255 characters; stored in the security log), choose 15, 30 or 60 minutes (default 15) and, if you like, **Email the user that their account was opened** (through Strapi's email plugin, with the reason and the duration; no admin name). Blocked users cannot be impersonated, and one user has at most one running impersonation.
913
+
914
+ **What you get.** A short-lived credential for that user and nothing else; the password is never read, shown or changed.
915
+
916
+ - `jwtManagement: 'refresh'`: a Strapi session created with `strapi.sessionManager('users-permissions').generateRefreshToken(userId, deviceId, { type: 'session', metadata })` on its own device id, marked in the session metadata (Strapi keeps the metadata when the refresh token rotates), plus an access token. `POST /api/auth/refresh` keeps working until the end; at the end the plugin deletes the session (`invalidateRefreshToken(userId, deviceId)`), so access and refresh tokens stop at once.
917
+ - `legacy-support`: a JWT with an `msmImp` claim whose `exp` is the end of the impersonation. Ending it puts the token on the plugin's revocation list.
918
+ - Either way the user's session list shows a Magic session row for it, and the plugin's own session checks apply.
919
+
920
+ **Frontend hand-off (recommended).** Configure where the frontend accepts it:
921
+
922
+ ```js
923
+ // config/plugins.js
924
+ 'magic-sessionmanager': {
925
+ config: {
926
+ impersonation: {
927
+ frontendUrl: 'https://app.example.com/impersonate',
928
+ allowedFrontendOrigins: ['https://app.example.com'], // optional allow-list; default: the URL's origin
929
+ },
930
+ },
931
+ },
932
+ ```
933
+
934
+ `frontendUrl` must be https (plain http only for `localhost` outside production), without user info, query or fragment, and its origin must be on `allowedFrontendOrigins`; otherwise Strapi refuses to start with a message naming the key. Admins cannot change it in the UI. After **Start impersonation** the dialog shows **Open frontend**: the admin panel sends a one-time code to `frontendUrl` with an HTTP **POST** form in a new tab (field `code`), so the code never appears in a URL, the browser history, a `Referer` header or an access log. The frontend's server exchanges it within **60 seconds**:
935
+
936
+ ```js
937
+ // Next.js route handler (app/impersonate/route.js), as an example
938
+ export async function POST(request) {
939
+ const form = await request.formData();
940
+ const response = await fetch(
941
+ `${process.env.STRAPI_URL}/api/magic-sessionmanager/impersonation/exchange`,
942
+ {
943
+ method: 'POST',
944
+ headers: { 'Content-Type': 'application/json' },
945
+ body: JSON.stringify({ code: form.get('code') }),
946
+ }
947
+ );
948
+ if (!response.ok) return new Response('This link has expired.', { status: 400 });
949
+ const { data } = await response.json(); // { jwt, refreshToken?, expiresAt, user, impersonation }
950
+ // Store the credential the way your app stores a normal sign-in (for example an httpOnly cookie
951
+ // that expires at data.expiresAt), then redirect to the app.
952
+ }
953
+ ```
954
+
955
+ Strapi's default Content-Security-Policy for the admin panel only lets forms post to Strapi itself (`form-action 'self'`), so allow the frontend origin, and only that one:
956
+
957
+ ```js
958
+ // config/middlewares.js
959
+ {
960
+ name: 'strapi::security',
961
+ config: {
962
+ contentSecurityPolicy: {
963
+ useDefaults: true,
964
+ directives: { 'form-action': ["'self'", 'https://app.example.com'] },
965
+ },
966
+ },
967
+ },
968
+ ```
969
+
970
+ Strapi logs a warning at start-up while `frontendUrl` is set but its origin is missing from `form-action`, and the dialog explains the block when the browser reports it.
971
+
972
+ The code is 32 random bytes, stored only as a SHA-256 hash, valid for 60 seconds and usable once (an atomic update, so two parallel exchanges give one credential). Every unknown, used, expired or malformed code gets the same `400 Invalid or expired code`. The exchange route is public on purpose (the code is the credential) and limited to 10 requests per minute per IP address. Because the frontend accepts a cross-site POST, only start a session from it after a successful exchange, and never on GET.
973
+
974
+ **Without `frontendUrl`** the dialog shows the access token (and, in refresh mode, the refresh token) once, read-only, with a copy button and a warning. Use it in a private browser window or an API client and do not store it.
975
+
976
+ **What an impersonation cannot do.** A global middleware recognises impersonation credentials (the claim or the session marker; Strapi checks the signature afterwards, so a forged token can only add restrictions) and refuses with 403, `error.details.reason` `impersonation-credentials`, `impersonation-account` or `impersonation-sessions`:
977
+
978
+ - 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/*`;
979
+ - `POST`, `PUT` and `DELETE` on `/api/users` and `/api/users/:id` (email, password and account changes, account deletion);
980
+ - 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);
981
+ - 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`, …).
982
+
983
+ Everything else of your API works as for the user. An ended or expired impersonation gets 401 with `impersonation-ended` or `impersonation-expired`.
984
+
985
+ **Show a banner in your frontend.** Every response to an impersonation request carries `X-Magic-Impersonation: true`. Browsers let cross-origin JavaScript read it only when CORS exposes it:
986
+
987
+ ```js
988
+ // config/middlewares.js
989
+ { name: 'strapi::cors', config: { expose: ['X-Magic-Impersonation', 'X-Session-Terminated-Reason'] } },
990
+ ```
991
+
992
+ ```js
993
+ // A small fetch wrapper
994
+ export async function api(path, init) {
995
+ const response = await fetch(`${STRAPI_URL}${path}`, init);
996
+ const impersonating = response.headers.get('X-Magic-Impersonation') === 'true';
997
+ document.body.toggleAttribute('data-impersonating', impersonating);
998
+ return response;
999
+ }
1000
+ ```
1001
+
1002
+ ```css
1003
+ body[data-impersonating]::before {
1004
+ content: 'Support is signed in as this user. Changes are recorded.';
1005
+ position: sticky;
1006
+ top: 0;
1007
+ display: block;
1008
+ padding: 8px 16px;
1009
+ background: #fdf4dc;
1010
+ color: #3d2e00;
1011
+ font: 14px/1.4 system-ui;
1012
+ z-index: 1000;
1013
+ }
1014
+ ```
1015
+
1016
+ **Ending.** An impersonation ends by itself at its time (checked on every request and by a sweep every 30 seconds), with **End impersonation** in the dialog or in the user's Sessions panel, in **Settings › Impersonation › Active impersonations** (who, started by, reason, end time), or for all of them when the switch is turned off. Admins with **Impersonate app users** see and can end every running impersonation of an app user.
1017
+
1018
+ **Security log.** `impersonation.started` (actor: the real admin; target: the user; `meta`: reason, duration, hand-off, whether the user was emailed), `impersonation.ended` (actor: the admin who ended it, `meta.startedBy`), `impersonation.expired` (actor: system) and `impersonation.refused` (`meta.refusal`: `disabled`, `blocked`, `already-active`, `api-token`, or `call-credentials` / `call-account` / `call-sessions` for a refused request, at most one per minute and reason). No code, token or hash is ever logged. The events stay when the admin's account is deleted (the actor reference is cleared) and are deleted with the user. Rows of the impersonation table (`magic_sessions_impersonations`) are deleted 7 days after the impersonation ended.
1019
+
1020
+ **Limits.** 10 starts per admin per 10 minutes; 10 code exchanges per minute per IP address. Admin API tokens cannot impersonate (403 `api-token`); only a signed-in admin can.
1021
+
1022
+ **Security model.**
1023
+
1024
+ - Who: only roles granted **Impersonate app users**, only while the switch (a protected setting) is on, only signed-in admins.
1025
+ - What: a credential of the user's own permissions, never more; credential, account and session changes are refused.
1026
+ - How long: at most 60 minutes, enforced server-side; codes 60 seconds and single use.
1027
+ - Accountability: reason, duration, actor and target in the security log; optional email to the user.
1028
+ - Not covered: requests your own routes make on the user's behalf are not restricted unless they match the list above; review custom routes that change credentials or emails. Admins of the admin panel cannot be impersonated (see below).
1029
+
1030
+ **Works councils and GDPR (information, not legal advice).** Acting as a user processes that user's personal data. A typical basis is a legitimate interest in support and in fixing faults (Art. 6(1)(f) GDPR) or the contract with the user; tell users in your privacy information (Art. 13) and consider turning on the email notice. The security log shows which admin did what and when; in Germany a technical system that can monitor employees' behaviour or performance is subject to the works council's co-determination (Section 87(1) no. 6 BetrVG), and comparable rules exist elsewhere. Agree the feature with the works council where there is one before you turn it on, keep the circle of roles small, and check whether a data protection impact assessment (Art. 35 GDPR) is needed.
1031
+
899
1032
  ## Running several instances (Railway replicas, pm2 cluster)
900
1033
 
901
1034
  The plugin works with several Strapi processes that share one database, for example 2 Railway replicas with 4 pm2 cluster workers each (8 processes). No sticky sessions are needed (Railway does not offer them) and no extra infrastructure: the database is the single source of truth.
@@ -1084,6 +1217,7 @@ The plugin sits in the request path of every authenticated Content API call, so
1084
1217
  - **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.
1085
1218
  - **Secrets.** MaxMind license keys are never returned to the browser. Webhook URLs grant posting rights to your channel; treat them as secrets. Exports never contain tokens.
1086
1219
  - **Admin panel sessions.** The Admin panel view reads Strapi's own `admin::session` records (origin `admin`). Only Super Admin can see or sign out admins until another role is granted `admin-sessions.read` / `admin-sessions.revoke`; a delegated role cannot sign out a Super Admin. Sign-outs need a signed-in administrator (not an admin API token), are rate limited and logged with admin ids and counts only.
1220
+ - **Impersonation.** Off by default; only roles with **Impersonate app users**, only signed-in admins, at most 60 minutes, credential and account changes refused, every start, end, expiry and refusal in the security log. Details: [Impersonation](#impersonation).
1087
1221
  - **Admin activity and sign-in history.** The plugin's security log stores admin sign-ins with IP address and user agent (on by default; IP anonymisation and retention configurable) and, only when you turn it on, Content Manager activity. Only Super Admin sees it until another role gets `admin-activity.read`. Typed emails of failed sign-ins, passwords and request bodies are never stored. Details and legal notes: [Admin activity and sign-in history](#admin-activity-and-sign-in-history).
1088
1222
 
1089
1223
  ---
@@ -1102,6 +1236,7 @@ Information for your records of processing, a data protection impact assessment
1102
1236
  | 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 |
1103
1237
  | "Locked now" entries | While a lock lasts | `magic_sm_cache` | Until the lock ends | Admins with plugin access | Follows the log's IP options |
1104
1238
  | 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) |
1239
+ | 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) |
1105
1240
 
1106
1241
  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.
1107
1242
 
@@ -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, 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-h-ksmM8A.mjs";
10
+ import { N 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, A as EqualGrid, b as getTranslation, O as getDeviceTypeMessage } from "./index-DsaGGK7x.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;
@@ -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-DEYtqPc3.js");
12
+ const index = require("./index-Q_D-5LlE.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,8 +7,8 @@ import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Li
7
7
  import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut, Information, Webhooks, WarningCircle, Monitor, Key, Stack, Lock, CrossCircle, Shield, CheckCircle, ArrowRight } from "@strapi/icons";
8
8
  import { EmptyDocuments } from "@strapi/icons/symbols";
9
9
  import styled, { useTheme } from "styled-components";
10
- import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as isCancelledRequest, o as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, q as PageShell, r as StatGrid, s as StatCard, v as restoreDialogFocus, w as requireSessionList, x as getBadgeColors, T as TargetLink$1 } from "./index-h-ksmM8A.mjs";
11
- import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, u as useElementWidth, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters, S as SETTINGS_TAB_IDS, o as SETTINGS_TAB_FIELDS, q as SETTINGS_FIELD_LABELS, t as SETTINGS_TAB_LABELS } from "./settingsTabs-D02CuEvs.mjs";
10
+ import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as isCancelledRequest, o as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, q as PageShell, r as StatGrid, s as StatCard, v as restoreDialogFocus, w as requireSessionList, x as getBadgeColors, T as TargetLink$1 } from "./index-DsaGGK7x.mjs";
11
+ import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, u as useElementWidth, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters, S as SETTINGS_TAB_IDS, o as SETTINGS_TAB_FIELDS, q as SETTINGS_FIELD_LABELS, t as SETTINGS_TAB_LABELS } from "./settingsTabs--7IsqMdn.mjs";
12
12
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
13
13
  const { formatMessage } = useIntl();
14
14
  const key = reason || getSessionEndReason(session);
@@ -9,8 +9,8 @@ const designSystem = require("@strapi/design-system");
9
9
  const icons = require("@strapi/icons");
10
10
  const symbols = require("@strapi/icons/symbols");
11
11
  const styled = require("styled-components");
12
- const index = require("./index-DEYtqPc3.js");
13
- const settingsTabs = require("./settingsTabs-N4TFn-mw.js");
12
+ const index = require("./index-Q_D-5LlE.js");
13
+ const settingsTabs = require("./settingsTabs-Dxlevody.js");
14
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
15
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
16
16
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
@@ -6,7 +6,7 @@ import { Flex, Loader, Button, Box, Typography } from "@strapi/design-system";
6
6
  import { User, Lightning, Clock, Lock, WarningCircle } from "@strapi/icons";
7
7
  import * as StrapiAdmin from "@strapi/strapi/admin";
8
8
  import { useFetchClient } from "@strapi/strapi/admin";
9
- import { l as logSafeAdminError, n as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-h-ksmM8A.mjs";
9
+ import { l as logSafeAdminError, n as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-DsaGGK7x.mjs";
10
10
  function normalizeUserCounts(response) {
11
11
  const totalUsers = response?.data?.totalUsers;
12
12
  const blockedUsers = response?.data?.blockedUsers;
@@ -7,7 +7,7 @@ const styled = require("styled-components");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
9
  const StrapiAdmin = require("@strapi/strapi/admin");
10
- const index = require("./index-DEYtqPc3.js");
10
+ const index = require("./index-Q_D-5LlE.js");
11
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule) return e;