strapi-plugin-magic-sessionmanager 4.22.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.
- package/CHANGELOG.md +49 -0
- package/README.md +46 -36
- package/dist/admin/{Analytics-DeDLGiCe.js → Analytics-B7BAjApz.js} +1 -1
- package/dist/admin/{Analytics-WbCUmkQQ.mjs → Analytics-CIHgaURb.mjs} +1 -1
- package/dist/admin/{App-C4bihk2K.mjs → App-CPE-CQGz.mjs} +2 -2
- package/dist/admin/{App-Bkv-W0Sv.js → App-DJkJC06E.js} +2 -2
- package/dist/admin/{OnlineUsersWidget-CSvNe2rC.js → OnlineUsersWidget-CcjNfzzf.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-q0Z6nbbO.mjs → OnlineUsersWidget-Dou2hxGY.mjs} +1 -1
- package/dist/admin/{Settings-xokFI5LO.js → Settings--eEiHv_a.js} +62 -39
- package/dist/admin/{Settings-avD0DbXP.mjs → Settings-h_exWUiI.mjs} +62 -39
- package/dist/admin/{dashboardModel-D4389iIV.js → dashboardModel-DNT_l-Bk.js} +1 -1
- package/dist/admin/{dashboardModel-BBNRgcEr.mjs → dashboardModel-fApbKGay.mjs} +1 -1
- package/dist/admin/{de-BQlEdBMr.mjs → de-Wz5Emtrb.mjs} +6 -3
- package/dist/admin/{de-HcJ19LKI.js → de-oBmcAcXj.js} +6 -3
- package/dist/admin/{en-DI-98CPM.js → en-B1TN5F62.js} +6 -3
- package/dist/admin/{en-DzuXWL1W.mjs → en-B_1Ka64U.mjs} +6 -3
- package/dist/admin/{es-Cm0Eklav.js → es-Bb515J0p.js} +6 -3
- package/dist/admin/{es-BfyED9YI.mjs → es-CVgw4zsj.mjs} +6 -3
- package/dist/admin/{fr-CzFNGWq0.mjs → fr-0AgMxTFc.mjs} +6 -3
- package/dist/admin/{fr-C3nzszsI.js → fr-yDdwunmg.js} +6 -3
- package/dist/admin/{index-6zc5D8eb.mjs → index-DVQ7tdTC.mjs} +30 -13
- package/dist/admin/{index-Dk5Jqe5U.js → index-qtN2dOm4.js} +30 -13
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-BPZ6chPT.js → pt-BAB07LY-.js} +6 -3
- package/dist/admin/{pt-DmyQnGI_.mjs → pt-DtM74ffN.mjs} +6 -3
- package/dist/server/index.js +928 -376
- package/dist/server/index.mjs +928 -376
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
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
|
+
|
|
1
50
|
# [4.22.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.21.0...v4.22.0) (2026-11-25)
|
|
2
51
|
|
|
3
52
|
|
package/README.md
CHANGED
|
@@ -387,7 +387,7 @@ Static defaults from `server/src/config/index.js`; admin units and ranges from t
|
|
|
387
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. |
|
|
388
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. |
|
|
389
389
|
| `maxFailedLogins` | 5 | 0 to 100, 0 = off | Login protection | Temporary IP lockout threshold (failed sign-ins from one IP within 15 minutes). |
|
|
390
|
-
| `trustedProxies` |
|
|
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. |
|
|
391
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. |
|
|
392
392
|
| `geoLookupFailureMode` | `'auto'` | auto, allow, block | Login protection | What happens when the location cannot be determined. |
|
|
393
393
|
| `enableGeofencing` | `false` | boolean | Login protection | Use country rules. |
|
|
@@ -406,14 +406,14 @@ Static defaults from `server/src/config/index.js`; admin units and ranges from t
|
|
|
406
406
|
|
|
407
407
|
### Environment variables
|
|
408
408
|
|
|
409
|
-
| Variable | Purpose
|
|
410
|
-
| -------------------------------------------- |
|
|
411
|
-
| `SESSION_ENCRYPTION_KEY` | Key for AES-256-GCM encryption of stored tokens. Required when `NODE_ENV=production` (startup fails without 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`.
|
|
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`. |
|
|
417
417
|
|
|
418
418
|
---
|
|
419
419
|
|
|
@@ -517,11 +517,20 @@ Requests with an ended session get **401** with the header `X-Session-Terminated
|
|
|
517
517
|
### Lockout, trusted addresses and Locked now
|
|
518
518
|
|
|
519
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.
|
|
520
|
-
-
|
|
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.
|
|
521
522
|
- **Window and duration**: `lockoutWindowMinutes` (1-1440) and `lockoutDurationMinutes` (1-10080). When a lock ends, the failures that caused it no longer count.
|
|
522
|
-
- **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
|
|
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.
|
|
523
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.
|
|
524
|
-
- **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.
|
|
525
534
|
|
|
526
535
|
### Concurrent session limit
|
|
527
536
|
|
|
@@ -557,7 +566,7 @@ Configuration › Alerts. Both kinds are sent only when location data is availab
|
|
|
557
566
|
|
|
558
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.
|
|
559
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.
|
|
560
|
-
- **"This wasn't me"**: the link opens `GET /api/magic-sessionmanager/not-me
|
|
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.
|
|
561
570
|
|
|
562
571
|
### Signed webhook
|
|
563
572
|
|
|
@@ -588,7 +597,7 @@ function verifyMagicSignature(secret, rawBody, header, toleranceSeconds = 300) {
|
|
|
588
597
|
}
|
|
589
598
|
```
|
|
590
599
|
|
|
591
|
-
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
|
|
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.
|
|
592
601
|
|
|
593
602
|
Example email provider configuration:
|
|
594
603
|
|
|
@@ -619,18 +628,18 @@ export default ({ env }) => ({
|
|
|
619
628
|
|
|
620
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`).
|
|
621
630
|
|
|
622
|
-
| Method | Path | Purpose | Response
|
|
623
|
-
| --------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
624
|
-
| GET | `/my-sessions` | Own sessions (up to 200), current session first | `{ data: [...], meta: { count, active, hasMore, limit } }`
|
|
625
|
-
| GET | `/current-session` | The session of the current token | `{ data: {..., isCurrentSession: true } }`; 404 when none
|
|
626
|
-
| GET | `/user/:userId/sessions` | Sessions of a user; only your own `userId` | 403 for another user
|
|
627
|
-
| POST | `/logout` | End the current session (reason `logout`) | `{ message, terminated }`
|
|
628
|
-
| POST | `/logout-all` | End all own sessions (reason `logout`) | `{ message, terminatedCount }`
|
|
629
|
-
| POST | `/logout-others` | End all own sessions except the current one | `{ message, terminatedCount, currentSessionPreserved }`
|
|
630
|
-
| 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
|
|
631
|
-
| 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 |
|
|
632
|
-
| 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
|
|
633
|
-
| 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 |
|
|
634
643
|
|
|
635
644
|
`POST /api/auth/logout` also ends the current session; the plugin mounts it when Users & Permissions does not provide it.
|
|
636
645
|
|
|
@@ -772,7 +781,7 @@ The **Admin panel sessions** routes need two more permissions, which only the Su
|
|
|
772
781
|
|
|
773
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.
|
|
774
783
|
|
|
775
|
-
**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.
|
|
776
785
|
|
|
777
786
|
| Method | Path | Admin UI action |
|
|
778
787
|
| -------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -861,11 +870,11 @@ Red marks a security signal (failed, refused, locked, impossible travel, "This w
|
|
|
861
870
|
|
|
862
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:
|
|
863
872
|
|
|
864
|
-
| Recorded | Events
|
|
865
|
-
| ------------------------------------ |
|
|
866
|
-
| **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)
|
|
867
|
-
| **Content Manager activity** | `admin.content.view` (opening an entry), `.create`, `.update`, `.publish`, `.unpublish`, `.discard`, `.delete`, `.clone`, with content type, document id and locale
|
|
868
|
-
| **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 |
|
|
869
878
|
|
|
870
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.
|
|
871
880
|
|
|
@@ -1012,7 +1021,8 @@ The code is 32 random bytes, stored only as a SHA-256 hash, valid for 60 seconds
|
|
|
1012
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/*`;
|
|
1013
1022
|
- `POST`, `PUT` and `DELETE` on `/api/users` and `/api/users/:id` (email, password and account changes, account deletion);
|
|
1014
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);
|
|
1015
|
-
- Magic Link and passwordless sign-in routes
|
|
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.
|
|
1016
1026
|
|
|
1017
1027
|
Everything else of your API works as for the user. An ended or expired impersonation gets 401 with `impersonation-ended` or `impersonation-expired`.
|
|
1018
1028
|
|
|
@@ -1068,7 +1078,7 @@ body[data-impersonating]::before {
|
|
|
1068
1078
|
**Anti-escalation (server-side).** Refused with 403 and `details.reason`:
|
|
1069
1079
|
|
|
1070
1080
|
- `self`: nobody views themselves;
|
|
1071
|
-
- `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;
|
|
1072
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;
|
|
1073
1083
|
- `api-token`: admin API tokens cannot start one;
|
|
1074
1084
|
- nesting is impossible: a preview creates no credential, and an app-user impersonation token cannot reach admin routes (401).
|
|
@@ -1117,7 +1127,7 @@ What stays per process, by design: the fail-open error budget in Relaxed token c
|
|
|
1117
1127
|
});
|
|
1118
1128
|
```
|
|
1119
1129
|
|
|
1120
|
-
With `proxy.koa` on,
|
|
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.
|
|
1121
1131
|
|
|
1122
1132
|
4. **pm2 in cluster mode** (one container or VM):
|
|
1123
1133
|
|
|
@@ -1252,7 +1262,7 @@ The plugin sits in the request path of every authenticated Content API call, so
|
|
|
1252
1262
|
|
|
1253
1263
|
## Security and privacy
|
|
1254
1264
|
|
|
1255
|
-
- **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:
|
|
1256
1266
|
|
|
1257
1267
|
```bash
|
|
1258
1268
|
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
|
|
@@ -9,7 +9,7 @@ const styled = require("styled-components");
|
|
|
9
9
|
const designSystem = require("@strapi/design-system");
|
|
10
10
|
const icons = require("@strapi/icons");
|
|
11
11
|
const symbols = require("@strapi/icons/symbols");
|
|
12
|
-
const index = require("./index-
|
|
12
|
+
const index = require("./index-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 { 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-
|
|
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;
|
|
@@ -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, ArrowRight, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut } 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 buildSignInParams, o as useEventList, q as SignInEventTable, r as PERIOD_OPTIONS, s as buildSignInCsv, v as SIGN_IN_FILTER_OPTIONS, w as buildActivityParams, x as buildActivityCsv, A as ActivityEventTable, y as ACTIVITY_ACTION_OPTIONS, z as ACTIVITY_ACTION_LABELS, B as downloadCsv, E as MAX_EVENT_EXPORT_ROWS, F as isCancelledRequest, G as RECENT_EVENT_LIMIT, H as buildUserActivityParams, I as RECENT_USER_EVENT_LIMIT, U as USER_ACTIVITY_API_PATH, J as USER_ACTIVITY_PAGE_PATH, K as UserEventTable, L as useElementWidth, N as SESSION_FILTER_OPTIONS, O as END_REASON_FILTER_OPTIONS, Q as PageShell, T as StatGrid, W as StatCard, X as buildSessionCsv, Y as buildSessionJson, Z as restoreDialogFocus, _ as requireSessionList, $ as getAdminStatusPresentation, a0 as getBadgeColors, a1 as useSettingsTranslate, a2 as useSecondsLeft, a3 as validateReason, a4 as REASON_MAX, a5 as formatClock, a6 as parseAdminPanelQuery, a7 as buildAdminListParams, a8 as withIdentityPlaceholders, a9 as ADMIN_FILTER_OPTIONS, aa as ADMIN_PAGE_SIZE_OPTIONS, ab as ADMIN_DEFAULT_PAGE_SIZE, ac as hasAdminFilters, ad as getSignOutErrorMessage, ae as splitDuration, af as parseActivityPageQuery, ag as EVENT_PAGE_SIZE, ah as ACTIVITY_PAGE_SIZE_OPTIONS, ai as ALL_ADMINS_FILTER_OPTIONS, aj as hasActivityPageFilters, ak as parseUserActivityQuery, al as userText, am as buildUserActivityCsv, an as USER_ACTIVITY_SETTINGS_PATH, ao as USER_ACTIVITY_FILTER_OPTIONS, ap as USER_ACTIVITY_FILTER_LABELS, aq as hasUserActivityFilters } from "./index-
|
|
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, 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 } from "./dashboardModel-
|
|
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 buildSignInParams, o as useEventList, q as SignInEventTable, r as PERIOD_OPTIONS, s as buildSignInCsv, v as SIGN_IN_FILTER_OPTIONS, w as buildActivityParams, x as buildActivityCsv, A as ActivityEventTable, y as ACTIVITY_ACTION_OPTIONS, z as ACTIVITY_ACTION_LABELS, B as downloadCsv, E as MAX_EVENT_EXPORT_ROWS, F as isCancelledRequest, G as RECENT_EVENT_LIMIT, H as buildUserActivityParams, I as RECENT_USER_EVENT_LIMIT, U as USER_ACTIVITY_API_PATH, J as USER_ACTIVITY_PAGE_PATH, K as UserEventTable, L as useElementWidth, N as SESSION_FILTER_OPTIONS, O as END_REASON_FILTER_OPTIONS, Q as PageShell, T as StatGrid, W as StatCard, X as buildSessionCsv, Y as buildSessionJson, Z as restoreDialogFocus, _ as requireSessionList, $ as getAdminStatusPresentation, a0 as getBadgeColors, a1 as useSettingsTranslate, a2 as useSecondsLeft, a3 as validateReason, a4 as REASON_MAX, a5 as formatClock, a6 as parseAdminPanelQuery, a7 as buildAdminListParams, a8 as withIdentityPlaceholders, a9 as ADMIN_FILTER_OPTIONS, aa as ADMIN_PAGE_SIZE_OPTIONS, ab as ADMIN_DEFAULT_PAGE_SIZE, ac as hasAdminFilters, ad as getSignOutErrorMessage, ae as splitDuration, af as parseActivityPageQuery, ag as EVENT_PAGE_SIZE, ah as ACTIVITY_PAGE_SIZE_OPTIONS, ai as ALL_ADMINS_FILTER_OPTIONS, aj as hasActivityPageFilters, ak as parseUserActivityQuery, al as userText, am as buildUserActivityCsv, an as USER_ACTIVITY_SETTINGS_PATH, ao as USER_ACTIVITY_FILTER_OPTIONS, ap as USER_ACTIVITY_FILTER_LABELS, aq as hasUserActivityFilters } from "./index-DVQ7tdTC.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, 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 } from "./dashboardModel-fApbKGay.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-
|
|
13
|
-
const dashboardModel = require("./dashboardModel-
|
|
12
|
+
const index = require("./index-qtN2dOm4.js");
|
|
13
|
+
const dashboardModel = require("./dashboardModel-DNT_l-Bk.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" }) => {
|
|
@@ -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-
|
|
10
|
+
const index = require("./index-qtN2dOm4.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;
|
|
@@ -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, F as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-
|
|
9
|
+
import { l as logSafeAdminError, F as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-DVQ7tdTC.mjs";
|
|
10
10
|
function normalizeUserCounts(response) {
|
|
11
11
|
const totalUsers = response?.data?.totalUsers;
|
|
12
12
|
const blockedUsers = response?.data?.blockedUsers;
|
|
@@ -6,10 +6,10 @@ const designSystem = require("@strapi/design-system");
|
|
|
6
6
|
const StrapiAdmin = require("@strapi/strapi/admin");
|
|
7
7
|
const icons = require("@strapi/icons");
|
|
8
8
|
const styled = require("styled-components");
|
|
9
|
-
const index = require("./index-
|
|
9
|
+
const index = require("./index-qtN2dOm4.js");
|
|
10
10
|
require("react-intl");
|
|
11
11
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
12
|
-
const dashboardModel = require("./dashboardModel-
|
|
12
|
+
const dashboardModel = require("./dashboardModel-DNT_l-Bk.js");
|
|
13
13
|
const symbols = require("@strapi/icons/symbols");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -571,6 +571,7 @@ const ROLE_RULE_RANGES = Object.freeze({
|
|
|
571
571
|
});
|
|
572
572
|
const ROLE_RULE_FIELDS = Object.freeze(Object.keys(ROLE_RULE_RANGES));
|
|
573
573
|
const MAX_TRUSTED_ADDRESSES = 100;
|
|
574
|
+
const MAX_TRUSTED_PROXIES = 50;
|
|
574
575
|
const message$2 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
|
|
575
576
|
function validateWholeNumber(value, { min, max }) {
|
|
576
577
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -613,17 +614,24 @@ function validatePolicyFields(settings) {
|
|
|
613
614
|
const error = validateWholeNumber(source[key], range);
|
|
614
615
|
if (error) errors[key] = error;
|
|
615
616
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
for (const [field, max] of [
|
|
618
|
+
["lockoutTrustedAddresses", MAX_TRUSTED_ADDRESSES],
|
|
619
|
+
["trustedProxies", MAX_TRUSTED_PROXIES]
|
|
620
|
+
]) {
|
|
621
|
+
const entries = Array.isArray(source[field]) ? source[field] : [];
|
|
622
|
+
if (entries.length > max) {
|
|
623
|
+
errors[field] = message$2(
|
|
624
|
+
"settings.validation.trustedTooMany",
|
|
625
|
+
"Enter at most {max} addresses.",
|
|
626
|
+
{
|
|
627
|
+
max
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
624
632
|
const invalid = entries.find((entry) => !isTrustedAddressLine(entry));
|
|
625
633
|
if (invalid !== void 0) {
|
|
626
|
-
errors
|
|
634
|
+
errors[field] = message$2(
|
|
627
635
|
"settings.validation.trustedAddress",
|
|
628
636
|
'"{value}" is not an IP address or CIDR range. Use for example 192.0.2.10 or 192.0.2.0/24.',
|
|
629
637
|
{ value: String(invalid).slice(0, 64) }
|
|
@@ -2072,7 +2080,8 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
2072
2080
|
sessionCreationGraceMs: 5e3,
|
|
2073
2081
|
cleanupUseDbDirect: false,
|
|
2074
2082
|
strictSessionEnforcement: false,
|
|
2075
|
-
|
|
2083
|
+
// Proxy addresses or CIDR ranges (4.22.1); empty = Strapi's server.proxy settings.
|
|
2084
|
+
trustedProxies: [],
|
|
2076
2085
|
enableGeolocation: true,
|
|
2077
2086
|
enableSecurityScoring: true,
|
|
2078
2087
|
blockSuspiciousSessions: false,
|
|
@@ -2133,6 +2142,7 @@ function normalizeSettings(loaded) {
|
|
|
2133
2142
|
allowedCountries: Array.isArray(loaded.allowedCountries) ? loaded.allowedCountries : [],
|
|
2134
2143
|
blockedCountries: Array.isArray(loaded.blockedCountries) ? loaded.blockedCountries : [],
|
|
2135
2144
|
lockoutTrustedAddresses: Array.isArray(loaded.lockoutTrustedAddresses) ? loaded.lockoutTrustedAddresses : [],
|
|
2145
|
+
trustedProxies: Array.isArray(loaded.trustedProxies) ? loaded.trustedProxies : [],
|
|
2136
2146
|
roleRules: Array.isArray(loaded.roleRules) ? loaded.roleRules : [],
|
|
2137
2147
|
webhookEvents: Array.isArray(loaded.webhookEvents) ? loaded.webhookEvents : [...SIGNALS_FORM_DEFAULTS.webhookEvents],
|
|
2138
2148
|
emailTemplates: fillMissingTemplates(loaded.emailTemplates)
|
|
@@ -2498,37 +2508,43 @@ const LockedNowCard = () => {
|
|
|
2498
2508
|
}
|
|
2499
2509
|
);
|
|
2500
2510
|
};
|
|
2501
|
-
const TrustedAddressesField = ({
|
|
2511
|
+
const TrustedAddressesField = ({
|
|
2512
|
+
form,
|
|
2513
|
+
disabled = false,
|
|
2514
|
+
field = "lockoutTrustedAddresses",
|
|
2515
|
+
id = "lockout-trusted-addresses",
|
|
2516
|
+
label,
|
|
2517
|
+
description,
|
|
2518
|
+
placeholder = "192.0.2.0/24"
|
|
2519
|
+
}) => {
|
|
2502
2520
|
const { t, tError } = index.useSettingsTranslate();
|
|
2503
2521
|
const { settings, handleChange, errors, draftVersion } = form;
|
|
2504
|
-
const [text, setText] = react.useState(
|
|
2505
|
-
() => formatTrustedAddressText(settings.lockoutTrustedAddresses)
|
|
2506
|
-
);
|
|
2522
|
+
const [text, setText] = react.useState(() => formatTrustedAddressText(settings[field]));
|
|
2507
2523
|
const [version, setVersion] = react.useState(draftVersion);
|
|
2508
2524
|
if (version !== draftVersion) {
|
|
2509
2525
|
setVersion(draftVersion);
|
|
2510
|
-
setText(formatTrustedAddressText(settings
|
|
2526
|
+
setText(formatTrustedAddressText(settings[field]));
|
|
2511
2527
|
}
|
|
2512
2528
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2513
2529
|
FormField,
|
|
2514
2530
|
{
|
|
2515
|
-
id
|
|
2516
|
-
name:
|
|
2517
|
-
label: t("settings.config.failed.trusted.label", "Trusted addresses"),
|
|
2518
|
-
description: t(
|
|
2531
|
+
id,
|
|
2532
|
+
name: field,
|
|
2533
|
+
label: label ?? t("settings.config.failed.trusted.label", "Trusted addresses"),
|
|
2534
|
+
description: description ?? t(
|
|
2519
2535
|
"settings.config.failed.trusted.hint",
|
|
2520
2536
|
"One IP address or CIDR range per line, for example 192.0.2.10 or 192.0.2.0/24. These addresses are never locked by IP; accounts can still be locked. Use it for an office network or a server that signs in for many users."
|
|
2521
2537
|
),
|
|
2522
|
-
error: tError(errors
|
|
2538
|
+
error: tError(errors[field]),
|
|
2523
2539
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2524
2540
|
designSystem.Textarea,
|
|
2525
2541
|
{
|
|
2526
2542
|
value: text,
|
|
2527
|
-
placeholder
|
|
2543
|
+
placeholder,
|
|
2528
2544
|
disabled,
|
|
2529
2545
|
onChange: (event) => {
|
|
2530
2546
|
setText(event.target.value);
|
|
2531
|
-
handleChange(
|
|
2547
|
+
handleChange(field, parseTrustedAddressText(event.target.value));
|
|
2532
2548
|
}
|
|
2533
2549
|
}
|
|
2534
2550
|
)
|
|
@@ -3152,6 +3168,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3152
3168
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3153
3169
|
designSystem.NumberInput,
|
|
3154
3170
|
{
|
|
3171
|
+
disabled: policyLocked,
|
|
3155
3172
|
value: settings.maxFailedLogins,
|
|
3156
3173
|
onValueChange: (value) => handleChange("maxFailedLogins", value),
|
|
3157
3174
|
min: MAX_FAILED_LOGINS_RANGE.min,
|
|
@@ -3305,7 +3322,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3305
3322
|
}
|
|
3306
3323
|
),
|
|
3307
3324
|
/* @__PURE__ */ jsxRuntime.jsx(LockedNowCard, {}),
|
|
3308
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3325
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3309
3326
|
SectionCard.SectionCard,
|
|
3310
3327
|
{
|
|
3311
3328
|
id: "client-ip-address",
|
|
@@ -3314,19 +3331,24 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3314
3331
|
"settings.config.clientIp.intro",
|
|
3315
3332
|
"All IP-based rules depend on reading the real client address."
|
|
3316
3333
|
),
|
|
3317
|
-
children:
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
"
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3334
|
+
children: [
|
|
3335
|
+
policyLocked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
3336
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3337
|
+
TrustedAddressesField,
|
|
3338
|
+
{
|
|
3339
|
+
form,
|
|
3340
|
+
disabled: policyLocked,
|
|
3341
|
+
field: "trustedProxies",
|
|
3342
|
+
id: "trusted-proxies",
|
|
3343
|
+
placeholder: "10.0.0.0/8",
|
|
3344
|
+
label: t("settings.config.clientIp.trustProxy.label", "Trusted proxies"),
|
|
3345
|
+
description: t(
|
|
3346
|
+
"settings.config.clientIp.trustProxy.hint",
|
|
3347
|
+
"Leave empty to use Strapi's server.proxy settings (koa, ipHeader, maxIpsCount). Otherwise list your proxies, one IP address or CIDR range per line: only a request that comes from a listed proxy has its X-Forwarded-For read, and the client is the right-most address that is not listed. Affects the recorded IP address, the IP lockout and location lookups."
|
|
3348
|
+
)
|
|
3349
|
+
}
|
|
3350
|
+
)
|
|
3351
|
+
]
|
|
3330
3352
|
}
|
|
3331
3353
|
),
|
|
3332
3354
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4827,12 +4849,13 @@ const AlertsTab = ({ form }) => {
|
|
|
4827
4849
|
] }, field);
|
|
4828
4850
|
}) }) })
|
|
4829
4851
|
] }),
|
|
4852
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
4830
4853
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4831
4854
|
AdvancedSection,
|
|
4832
4855
|
{
|
|
4833
4856
|
label: t("settings.config.email.templates.label", "Edit email templates"),
|
|
4834
4857
|
hasError: templateErrors,
|
|
4835
|
-
disabled: emailTypesDisabled,
|
|
4858
|
+
disabled: emailTypesDisabled || locked,
|
|
4836
4859
|
children: [
|
|
4837
4860
|
/* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "warning", closeLabel: t("common.close", "Close"), title: "", children: t(
|
|
4838
4861
|
"settings.config.email.templates.warning",
|