strapi-plugin-magic-sessionmanager 4.9.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -4
- package/README.md +195 -41
- package/dist/admin/{Analytics-B6d-39Qh.js → Analytics-CdmRsigN.js} +1 -1
- package/dist/admin/{Analytics-DxOWXHn8.mjs → Analytics-PRqsLMEx.mjs} +1 -1
- package/dist/admin/{App-ZsSGj7n8.mjs → App-BSeYF7KA.mjs} +2 -2
- package/dist/admin/{App-mRFV50K6.js → App-DUMCbuCr.js} +2 -2
- package/dist/admin/{License-DXt2oi6u.js → License-BeD7Du6r.js} +1 -1
- package/dist/admin/{License-BE6UQ_V3.mjs → License-D5W_l35e.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-_tJ6aeWl.mjs → OnlineUsersWidget-B5pXzqM9.mjs} +2 -1
- package/dist/admin/{OnlineUsersWidget-CFvM3Vbp.js → OnlineUsersWidget-CDZ19_PT.js} +2 -1
- package/dist/admin/{Settings-dtW7cjTX.mjs → Settings-B-GRuWjT.mjs} +13 -3
- package/dist/admin/{Settings-BUc12TP5.js → Settings-CrLzRXrA.js} +13 -3
- package/dist/admin/{de-j0oZH9Pz.mjs → de-DwUCBY1b.mjs} +1 -0
- package/dist/admin/{de-BFKoGEVT.js → de-Dzo1tVoJ.js} +1 -0
- package/dist/admin/{en-s7Ksdkcg.js → en-CL5llI55.js} +1 -0
- package/dist/admin/{en-UY4Tb5tE.mjs → en-Dd0wXfgR.mjs} +1 -0
- package/dist/admin/{es-07OGMe_5.js → es-CiNDwv_f.js} +1 -0
- package/dist/admin/{es-DGBcZwQy.mjs → es-Cl5IwDA4.mjs} +1 -0
- package/dist/admin/{fr-ETj_2UBY.js → fr-DBOQ-UDm.js} +1 -0
- package/dist/admin/{fr-B6-DWhGO.mjs → fr-DhADj8Zs.mjs} +1 -0
- package/dist/admin/{index-C_SyRULc.mjs → index-CHACmZsg.mjs} +42 -32
- package/dist/admin/{index-D4kEnXSp.js → index-CaLVyCio.js} +26 -16
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-YMRLm9gx.mjs → pt-CT6VpDMM.mjs} +1 -0
- package/dist/admin/{pt-C7PwrQtV.js → pt-m73K1nJ0.js} +1 -0
- package/dist/server/index.js +1329 -268
- package/dist/server/index.mjs +1329 -268
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
# [4.10.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.9.1...v4.10.0) (2026-11-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **server:** hold the lockout and rate limits exactly under parallel bursts ([7fd9a1a](https://github.com/Schero94/Magic-Sessionmanager/commit/7fd9a1aed8d3959027a46791ad6603489812f6eb))
|
|
7
|
+
* **server:** let a shortened job interval take over an over-long lease ([618f564](https://github.com/Schero94/Magic-Sessionmanager/commit/618f5643ba83ea6a4ee175d65068dad089626d64))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **admin:** send the settings revision and explain a concurrent save ([ef4e08a](https://github.com/Schero94/Magic-Sessionmanager/commit/ef4e08a19ac853e37c0affda27c54d1024879ab1))
|
|
13
|
+
* **server:** keep lockout, rate limits, jobs and settings consistent across instances ([976fa67](https://github.com/Schero94/Magic-Sessionmanager/commit/976fa67e5299fcb3d02f1852645fecd85bb4419c))
|
|
14
|
+
|
|
15
|
+
## [Unreleased]
|
|
16
|
+
|
|
17
|
+
Release type: minor (`feat` commits, no breaking change; API clients that send no settings `revision` behave as before).
|
|
18
|
+
|
|
19
|
+
### Multi-instance deployments (pm2 cluster, Railway replicas)
|
|
20
|
+
|
|
21
|
+
Every hazard from the multi-instance audit (SM-MI-01 to SM-MI-14) is addressed for several Node processes sharing one database:
|
|
22
|
+
|
|
23
|
+
* **Failed-login lockout and Content API rate limits are cluster-wide.** Counters live in the new `magic_sm_counters` table (IP and caller keys stored as SHA-256 hashes) and are updated atomically. Before, each process counted on its own, so 8 processes allowed about 8x the configured attempts.
|
|
24
|
+
* **Fix: the failed-login lockout never counted wrong passwords** in Strapi 5, because Users & Permissions throws a `ValidationError` and the counting code after `await next()` did not run. Thrown errors are now classified like Strapi's errors middleware does and re-thrown unchanged.
|
|
25
|
+
* **Cleanup and retention run on one process per interval** via a job lease (`magic_sm_leases`). Retention now runs about 5 minutes after a start and then daily; before, the first run came 24 hours after a start, so frequent deploys could postpone it indefinitely.
|
|
26
|
+
* **Permission setup, session-index creation and all plugin-store writes run in a cluster-wide critical section** (`pg_advisory_xact_lock` on PostgreSQL, lease row elsewhere). Duplicate Core Store rows and duplicate Authenticated-role permissions from parallel first boots are removed automatically.
|
|
27
|
+
* **Conditional session updates.** Idle cleanup, the JWT check (idle, expired, legacy reactivation) and `lastActive` updates use compare-and-set `updateMany` calls, so a stale read can no longer revive a terminated session or overwrite a `manual` / `blocked` reason.
|
|
28
|
+
* **Settings reach every process within about 2 seconds** through a shared revision. `GET /settings` and `PUT /settings` return `revision`; a `PUT` that sends a stale `revision` gets 409 (the admin shows a new message in five languages). Clients that send no revision behave as before.
|
|
29
|
+
* **Shared ipapi.co cache and 429 back-off**, so 8 processes no longer use 8x the quota.
|
|
30
|
+
* **Toggle-mode user blocking** is serialised per user; the admin already uses the explicit mode.
|
|
31
|
+
* **Encryption key check:** instances with different `SESSION_ENCRYPTION_KEY` values log an error at startup (only an HMAC check value is compared).
|
|
32
|
+
* GeoIP status reports `scope: "instance"` and a host fingerprint, because the MMDB file is local to each instance.
|
|
33
|
+
* New README section "Running several instances (Railway replicas, pm2 cluster)" with exact configuration, a pm2 ecosystem file, an optional Redis counter store and the Strapi core first-boot caveat.
|
|
34
|
+
* New `npm run test:concurrency` (8 processes on SQLite and PostgreSQL) and a CI job with a PostgreSQL 16 service.
|
|
35
|
+
* **Fix (found by the 4-process HTTP proof): a parallel burst bypassed the lockout.** The attempt was counted only after the password check, so every request of a burst passed the "is this IP locked?" check first (10 of 48 parallel wrong passwords reached the check with `maxFailedLogins: 5`, limited only by Strapi's own per-process limiter). The attempt is now reserved before the check: at most `maxFailedLogins` failed or still-running attempts per IP reach the password check, cluster-wide. Behaviour change: when more than `maxFailedLogins` login requests from one IP are in flight at the same moment, the extra ones get HTTP 429 with `Retry-After: 1` and the message "Too many login attempts at once. Please try again." They do not lock the IP; only completed failures do. A login that ends with a 5xx gives its reserved attempt back.
|
|
36
|
+
* **Fix: shared counters reported a count that included later concurrent hits,** so under a burst the Content API rate limit let fewer requests through than configured (2 of 48 parallel `logout-others` calls with a limit of 10). Counters now return the value written by the request itself (`UPDATE ... RETURNING` on PostgreSQL and SQLite, UPDATE + `SELECT ... FOR UPDATE` in one transaction on MySQL). The same applies to settings revisions.
|
|
37
|
+
* **Fix: a shortened cleanup interval could wait for the old job lease.** The idle-cleanup lease lasts one interval; a lease taken under the 30-minute default (for example by the process that ran before a restart) kept blocking the cleanup for up to 30 minutes after the interval was set to 5. A lease that ends more than 60 seconds later than a fresh one would may now be taken over. After a restart without a settings change the job keeps its schedule, so the first run on the new process can come up to one interval after the last run on the old one.
|
|
38
|
+
* **Fix: parallel "log out other devices" calls could answer 500.** Two requests (on one or several instances) revoked the same native session; the one that lost the race treated "already revoked" as a failure. A native revoke that is not confirmed now succeeds when the session is no longer active, and still fails when it is.
|
|
39
|
+
|
|
40
|
+
### Migration
|
|
41
|
+
|
|
42
|
+
* On start the plugin creates three tables: `magic_sm_counters`, `magic_sm_leases`, `magic_sm_cache`. The database user needs the `CREATE` privilege once. Strapi's schema sync does not touch these tables.
|
|
43
|
+
* New optional config `coordination: { enabled, counterStore }`. `enabled: false` restores per-process state.
|
|
44
|
+
* Lockout counters start empty after the upgrade.
|
|
45
|
+
|
|
46
|
+
## [4.9.1](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.9.0...v4.9.1) (2026-11-07)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* **admin:** keep the console free of handled request failures ([d5b55ca](https://github.com/Schero94/Magic-Sessionmanager/commit/d5b55ca4efc5d3412c63ee81ad2d9bba21244277))
|
|
52
|
+
|
|
1
53
|
# [4.9.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.8.0...v4.9.0) (2026-11-07)
|
|
2
54
|
|
|
3
55
|
|
|
@@ -20,13 +72,11 @@
|
|
|
20
72
|
* **admin:** apply session information architecture to every screen ([9a4c30d](https://github.com/Schero94/Magic-Sessionmanager/commit/9a4c30dd2af47e4559d5c3521f7ee9d6938e39a9))
|
|
21
73
|
* **admin:** rebuild UI on shared Design System blocks and fix review findings ([187dbac](https://github.com/Schero94/Magic-Sessionmanager/commit/187dbacac505abc747e1f761d913f8dc74874bc6))
|
|
22
74
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Branch `claude/sessionmanager-ui-redesign`. Not yet accepted: see `GATES.md` and `gates/ui-redesign.md`. Whoever cuts the next release must fold this section into the generated release entry, so it does not stay behind as a second `[Unreleased]` block.
|
|
75
|
+
The following notes for 4.9.0 were moved here on 2026-11-07 from a stale `[Unreleased]` block (branch `claude/sessionmanager-ui-redesign`, released as 4.9.0).
|
|
26
76
|
|
|
27
77
|
### Known issues in 4.8.0
|
|
28
78
|
|
|
29
|
-
4.8.0 was released before its acceptance gates closed, although its release-readiness audit said not to publish. It is not accepted. Known defects in 4.8.0, fixed
|
|
79
|
+
4.8.0 was released before its acceptance gates closed, although its release-readiness audit said not to publish. It is not accepted. Known defects in 4.8.0, fixed in 4.9.0:
|
|
30
80
|
|
|
31
81
|
* The Session Details dialog has no accessible name, and focus can land on the page body after Escape.
|
|
32
82
|
* Settings field hints, including the GeoIP privacy disclosure, never render.
|
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ Free and open under the MIT license. All features are available without a paid l
|
|
|
30
30
|
- [Content API](#content-api)
|
|
31
31
|
- [Optional route policy: `session-required`](#optional-route-policy-session-required)
|
|
32
32
|
- [Admin API and permissions](#admin-api-and-permissions)
|
|
33
|
+
- [Running several instances (Railway replicas, pm2 cluster)](#running-several-instances-railway-replicas-pm2-cluster)
|
|
33
34
|
- [Security and privacy](#security-and-privacy)
|
|
34
35
|
- [Troubleshooting](#troubleshooting)
|
|
35
36
|
- [Development and tests](#development-and-tests)
|
|
@@ -275,32 +276,32 @@ export default () => ({
|
|
|
275
276
|
|
|
276
277
|
Static defaults from `server/src/config/index.js`; admin units and ranges from the settings validation in `server/src/controllers/settings.js`. Out-of-range admin values are rejected with a field error, not clamped silently.
|
|
277
278
|
|
|
278
|
-
| Key | Default | Admin unit and range | Configuration tab | Meaning
|
|
279
|
-
| ------------------------------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------- | ----------------------------- |
|
|
280
|
-
| `inactivityTimeout` | 15 min (`900000` ms) | min, 1–1440 | Sessions | Unused this long, a session becomes idle and then ends as "Timed out". Also decides who counts as online.
|
|
281
|
-
| `maxSessionAgeDays` | 30 | days, 1–365 | Sessions | Maximum age from sign-in, regardless of activity. Applied on the session's next request.
|
|
282
|
-
| `lastSeenRateLimit` | 30 s (`30000` ms) | s, 5–300 | Sessions › Advanced | Minimum interval between "Last active" updates.
|
|
283
|
-
| `cleanupInterval` | 30 min (`1800000` ms) | min, 5–1440 | Sessions › Advanced | How often the idle check runs. It ends idle sessions and deletes nothing. It also runs
|
|
284
|
-
| `cleanupUseDbDirect` | `false` | boolean | Sessions › Advanced | Idle check with one SQL update instead of the Document Service (skips lifecycle hooks).
|
|
285
|
-
| `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.
|
|
286
|
-
| `sessionCreationGraceMs` | `5000` | ms, 0–30000 (shown in seconds) | Sessions › Advanced | Window after sign-in in which a token is accepted while its record is being created.
|
|
287
|
-
| `maxFailedLogins` | 5 | 0–100, 0 = off | Login protection | Temporary IP lockout threshold (failed sign-ins from one IP within 15 minutes).
|
|
288
|
-
| `trustedProxies` | off | boolean | Login protection | Read the client IP from proxy headers. Only behind a proxy you control.
|
|
289
|
-
| `blockSuspiciousSessions` | `false` | boolean | Login protection | Reject suspicious sign-ins.
|
|
290
|
-
| `geoLookupFailureMode` | `'auto'` | auto, allow, block | Login protection | What happens when the location cannot be determined.
|
|
291
|
-
| `enableGeofencing` | `false` | boolean | Login protection | Use country rules.
|
|
292
|
-
| `allowedCountries` / `blockedCountries` | `[]` | ISO 3166-1 alpha-2 codes | Login protection | Allow only listed countries / Reject listed countries.
|
|
293
|
-
| `enableGeolocation` | `true` | boolean | Location data | IP location lookup at sign-in. Required by country rules, suspicious-sign-in checks and alerts.
|
|
294
|
-
| `enableSecurityScoring` | `true` | boolean | Location data | Apply the security score thresholds (below 70: suspicious-sign-in email, below 50: rejection if enabled).
|
|
295
|
-
| `geoIpProvider` | `'auto'` | auto, local-mmdb, ipapi, disabled | Location data | Where location data comes from.
|
|
296
|
-
| `geoIpDatabasePath` | `MAGIC_SESSIONMANAGER_GEOIP_DATABASE` or `''` | file name | Location data › Advanced | Local MaxMind-compatible database.
|
|
297
|
-
| `enableEmailAlerts` | `false` | boolean | Alerts | Security emails to users.
|
|
298
|
-
| `alertOnSuspiciousLogin` / `alertOnNewLocation` / `alertOnVpnProxy` | `true` | boolean | Alerts | Which events send an email.
|
|
299
|
-
| `enableWebhooks` | `false` | boolean | Alerts | Team notifications.
|
|
300
|
-
| `discordWebhookUrl` / `slackWebhookUrl` | `''` | https URL on discord.com / discordapp.com, or hooks.slack.com | Alerts | Any other host is rejected.
|
|
301
|
-
| `retentionDays` | 90 | days, 1–365 or -1 (forever) | Data and retention | How long records of ended sessions are kept. Checked once a day, the first time about
|
|
302
|
-
| `rateLimitWriteMax` / `rateLimitReadMax` / `rateLimitWindowSeconds` | 10 / 120 / 60 | 1–1000 / 1–10000 / 10–3600 | not shown | Content API rate limits. Not editable in the UI; Save keeps the stored values. The write limit can only be made stricter than the route floor.
|
|
303
|
-
| `emailTemplates` | empty | subject ≤ 200, HTML ≤ 10,000 (sanitised), text ≤ 5,000 characters | Alerts › Edit email templates | As soon as any template has content, only stored templates are used. Fill in all three, or none.
|
|
279
|
+
| Key | Default | Admin unit and range | Configuration tab | Meaning |
|
|
280
|
+
| ------------------------------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
281
|
+
| `inactivityTimeout` | 15 min (`900000` ms) | min, 1–1440 | Sessions | Unused this long, a session becomes idle and then ends as "Timed out". Also decides who counts as online. |
|
|
282
|
+
| `maxSessionAgeDays` | 30 | days, 1–365 | Sessions | Maximum age from sign-in, regardless of activity. Applied on the session's next request. |
|
|
283
|
+
| `lastSeenRateLimit` | 30 s (`30000` ms) | s, 5–300 | Sessions › Advanced | Minimum interval between "Last active" updates. |
|
|
284
|
+
| `cleanupInterval` | 30 min (`1800000` ms) | min, 5–1440 | Sessions › Advanced | How often the idle check runs. It ends idle sessions and deletes nothing. It also runs at server start; with several instances only one runs it per interval. |
|
|
285
|
+
| `cleanupUseDbDirect` | `false` | boolean | Sessions › Advanced | Idle check with one SQL update instead of the Document Service (skips lifecycle hooks). |
|
|
286
|
+
| `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. |
|
|
287
|
+
| `sessionCreationGraceMs` | `5000` | ms, 0–30000 (shown in seconds) | Sessions › Advanced | Window after sign-in in which a token is accepted while its record is being created. |
|
|
288
|
+
| `maxFailedLogins` | 5 | 0–100, 0 = off | Login protection | Temporary IP lockout threshold (failed sign-ins from one IP within 15 minutes). |
|
|
289
|
+
| `trustedProxies` | off | boolean | Login protection | Read the client IP from proxy headers. Only behind a proxy you control. |
|
|
290
|
+
| `blockSuspiciousSessions` | `false` | boolean | Login protection | Reject suspicious sign-ins. |
|
|
291
|
+
| `geoLookupFailureMode` | `'auto'` | auto, allow, block | Login protection | What happens when the location cannot be determined. |
|
|
292
|
+
| `enableGeofencing` | `false` | boolean | Login protection | Use country rules. |
|
|
293
|
+
| `allowedCountries` / `blockedCountries` | `[]` | ISO 3166-1 alpha-2 codes | Login protection | Allow only listed countries / Reject listed countries. |
|
|
294
|
+
| `enableGeolocation` | `true` | boolean | Location data | IP location lookup at sign-in. Required by country rules, suspicious-sign-in checks and alerts. |
|
|
295
|
+
| `enableSecurityScoring` | `true` | boolean | Location data | Apply the security score thresholds (below 70: suspicious-sign-in email, below 50: rejection if enabled). |
|
|
296
|
+
| `geoIpProvider` | `'auto'` | auto, local-mmdb, ipapi, disabled | Location data | Where location data comes from. |
|
|
297
|
+
| `geoIpDatabasePath` | `MAGIC_SESSIONMANAGER_GEOIP_DATABASE` or `''` | file name | Location data › Advanced | Local MaxMind-compatible database. |
|
|
298
|
+
| `enableEmailAlerts` | `false` | boolean | Alerts | Security emails to users. |
|
|
299
|
+
| `alertOnSuspiciousLogin` / `alertOnNewLocation` / `alertOnVpnProxy` | `true` | boolean | Alerts | Which events send an email. |
|
|
300
|
+
| `enableWebhooks` | `false` | boolean | Alerts | Team notifications. |
|
|
301
|
+
| `discordWebhookUrl` / `slackWebhookUrl` | `''` | https URL on discord.com / discordapp.com, or hooks.slack.com | Alerts | Any other host is rejected. |
|
|
302
|
+
| `retentionDays` | 90 | days, 1–365 or -1 (forever) | Data and retention | How long records of ended sessions are kept. Checked once a day across all instances, the first time about 5 minutes after the server starts. Open sessions are never deleted by retention. |
|
|
303
|
+
| `rateLimitWriteMax` / `rateLimitReadMax` / `rateLimitWindowSeconds` | 10 / 120 / 60 | 1–1000 / 1–10000 / 10–3600 | not shown | Content API rate limits. Not editable in the UI; Save keeps the stored values. The write limit can only be made stricter than the route floor. |
|
|
304
|
+
| `emailTemplates` | empty | subject ≤ 200, HTML ≤ 10,000 (sanitised), text ≤ 5,000 characters | Alerts › Edit email templates | As soon as any template has content, only stored templates are used. Fill in all three, or none. |
|
|
304
305
|
|
|
305
306
|
### Environment variables
|
|
306
307
|
|
|
@@ -355,12 +356,12 @@ The updater checks MaxMind's `Last-Modified` header and skips the download when
|
|
|
355
356
|
|
|
356
357
|
Configuration › Login protection checks **new sign-ins only**. Existing sessions are not affected, and refused sign-ins are not recorded.
|
|
357
358
|
|
|
358
|
-
| Rule | Response | Notes
|
|
359
|
-
| ----------------------------- | ----------------------------------- |
|
|
360
|
-
| Temporary IP lockout | 429 with `Retry-After` | After `maxFailedLogins` failed sign-ins from one IP address within 15 minutes, that address is refused for 15 minutes. User accounts are not blocked.
|
|
361
|
-
| Reject suspicious sign-ins | 403 | VPN, proxy or known threat address, or, with security scoring on, a score below 50.
|
|
362
|
-
| Country rules | 403 | Allow only listed countries, or reject listed countries. With "Allow only listed countries", an empty list allows every country.
|
|
363
|
-
| Location cannot be determined | 403 "Login temporarily unavailable" | When `geoLookupFailureMode` says reject (`auto` rejects only when "Reject suspicious sign-ins" is on).
|
|
359
|
+
| Rule | Response | Notes |
|
|
360
|
+
| ----------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
361
|
+
| Temporary IP lockout | 429 with `Retry-After` | After `maxFailedLogins` failed sign-ins from one IP address within 15 minutes, that address is refused for 15 minutes. User accounts are not blocked. Shared by all server processes. Each attempt is counted before the password check, so a parallel burst cannot exceed the limit; when more attempts from one address are running at once than the limit, the extra ones get 429 with `Retry-After: 1` and no lock. |
|
|
362
|
+
| Reject suspicious sign-ins | 403 | VPN, proxy or known threat address, or, with security scoring on, a score below 50. |
|
|
363
|
+
| Country rules | 403 | Allow only listed countries, or reject listed countries. With "Allow only listed countries", an empty list allows every country. |
|
|
364
|
+
| Location cannot be determined | 403 "Login temporarily unavailable" | When `geoLookupFailureMode` says reject (`auto` rejects only when "Reject suspicious sign-ins" is on). |
|
|
364
365
|
|
|
365
366
|
Requests with an ended session get **401** with the header `X-Session-Terminated-Reason` (`logout`, `manual`, `idle`, `expired` or `blocked`).
|
|
366
367
|
|
|
@@ -505,6 +506,158 @@ Errors use Strapi's `{ data: null, error }` envelope: 400 for invalid input, 404
|
|
|
505
506
|
|
|
506
507
|
---
|
|
507
508
|
|
|
509
|
+
## Running several instances (Railway replicas, pm2 cluster)
|
|
510
|
+
|
|
511
|
+
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.
|
|
512
|
+
|
|
513
|
+
### What is shared and how
|
|
514
|
+
|
|
515
|
+
| State | How it stays consistent across processes |
|
|
516
|
+
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
517
|
+
| Session validity (end, block, revoke, idle, expiry) | Read from `magic_sessions` on every request. State changes are conditional updates (`UPDATE … WHERE isActive = …`), so a stale read on one process can never revive a terminated session or overwrite a `manual` / `blocked` reason set by another one. |
|
|
518
|
+
| Failed-login lockout (`maxFailedLogins`) | One counter per client IP (stored as a SHA-256 hash) in `magic_sm_counters`, updated with a single atomic `UPDATE`. A lock or a successful sign-in applies on every process at once and survives restarts. |
|
|
519
|
+
| Content API rate limits | Same shared counters, keyed by route template and caller. The configured limit is the limit for the whole cluster, not per process. |
|
|
520
|
+
| Idle cleanup, retention | A job lease in `magic_sm_leases`: every process keeps its timer, but only the process that takes the lease runs the job. Cleanup runs about once per `cleanupInterval`, retention once per day (first run about 5 minutes after a start). |
|
|
521
|
+
| Permission setup, session indexes, plugin-store writes (settings, GeoIP credentials, license data) | A cluster-wide critical section: `pg_advisory_xact_lock` on PostgreSQL, a lease row on SQLite and MySQL. Duplicate Core Store rows and duplicate Authenticated-role permissions left by older versions are removed automatically. |
|
|
522
|
+
| Settings cache | Each save bumps a shared revision. Every process checks it at most every 2 seconds and reloads when it changed, so a new policy applies everywhere within about 2 seconds. |
|
|
523
|
+
| Concurrent settings saves | The admin sends the revision it loaded. If another administrator saved in between, the save is refused with 409 and nothing is overwritten. API clients that send no `revision` keep the previous behaviour. |
|
|
524
|
+
| ipapi.co results and back-off | Shared through `magic_sm_cache` (IP stored only as a hash), so one lookup or one HTTP 429 serves all processes. |
|
|
525
|
+
| `SESSION_ENCRYPTION_KEY` | Each process compares an HMAC check value of its key (never the key) at start and logs an error when instances use different keys. |
|
|
526
|
+
|
|
527
|
+
The three `magic_sm_*` tables are created at startup with portable statements (PostgreSQL, MySQL, SQLite 3.24+). The database user needs the `CREATE` privilege once. Strapi leaves tables it does not manage untouched.
|
|
528
|
+
|
|
529
|
+
What stays per process, by design: the fail-open error budget in Relaxed token check mode (10 errors per minute per process; Strict mode never fails open), short in-process caches in front of the shared state, and the GeoIP database file (see below).
|
|
530
|
+
|
|
531
|
+
### Exact setup
|
|
532
|
+
|
|
533
|
+
1. **One PostgreSQL (or MySQL) database for all instances.** SQLite works only when all processes run on one machine and share the file.
|
|
534
|
+
2. **Identical secrets on every instance.** On Railway, define them as shared variables: `SESSION_ENCRYPTION_KEY`, `APP_KEYS`, `JWT_SECRET`, `ADMIN_JWT_SECRET`, `API_TOKEN_SALT`, `TRANSFER_TOKEN_SALT`, `ENCRYPTION_KEY`, and `NODE_ENV=production`. Different `SESSION_ENCRYPTION_KEY` values make stored tokens unreadable on the other instances; the plugin logs an error at startup when it detects that.
|
|
535
|
+
3. **The real client IP.** Railway and most platforms put a proxy in front of the app. Turn on Koa's proxy mode identically everywhere, otherwise lockout and rate limits see the proxy address:
|
|
536
|
+
|
|
537
|
+
```js
|
|
538
|
+
// config/server.js
|
|
539
|
+
module.exports = ({ env }) => ({
|
|
540
|
+
host: env('HOST', '0.0.0.0'),
|
|
541
|
+
port: env.int('PORT', 1337),
|
|
542
|
+
app: { keys: env.array('APP_KEYS') },
|
|
543
|
+
proxy: { koa: env.bool('IS_PROXIED', true), maxIpsCount: env.int('MAX_IPS_COUNT', 1) },
|
|
544
|
+
});
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
With `proxy.koa` on, the plugin reads the client IP from the proxy headers (`CF-Connecting-IP`, `X-Real-IP`, then the first `X-Forwarded-For` entry). Only enable it behind a proxy you control.
|
|
548
|
+
|
|
549
|
+
4. **pm2 in cluster mode** (one container or VM):
|
|
550
|
+
|
|
551
|
+
```js
|
|
552
|
+
// ecosystem.config.js
|
|
553
|
+
module.exports = {
|
|
554
|
+
apps: [
|
|
555
|
+
{
|
|
556
|
+
name: 'strapi',
|
|
557
|
+
script: 'node_modules/@strapi/strapi/bin/strapi.js',
|
|
558
|
+
args: 'start',
|
|
559
|
+
instances: 4,
|
|
560
|
+
exec_mode: 'cluster',
|
|
561
|
+
env: { NODE_ENV: 'production' },
|
|
562
|
+
},
|
|
563
|
+
],
|
|
564
|
+
};
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
Start it with `pm2-runtime start ecosystem.config.js` in containers.
|
|
568
|
+
|
|
569
|
+
5. **Start one process first after a schema change.** Strapi itself syncs its database schema at every start. On an empty database, several processes starting at the same moment race on Strapi's own tables (`strapi_migrations` already exists / duplicate key in `pg_type`) and crash; we reproduced this with 4 processes on PostgreSQL 16 and Strapi 5.61. This is Strapi core behaviour, not the plugin's. For the first deploy and for deploys that change content types, start a single process once (for example a Railway [pre-deploy command](https://docs.railway.com/deployments/pre-deploy-command) or one replica with `instances: 1`), then scale out. The plugin's own start-up work is safe to run in parallel.
|
|
570
|
+
6. **GeoIP database file on every instance.** Railway replicas cannot use volumes ([Railway docs](https://docs.railway.com/volumes/reference#caveats)), and the file is local to each container. With `local-mmdb`, download it during the build or before pm2 starts, so every replica has it:
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
# build or start command, before pm2 forks the workers
|
|
574
|
+
npx strapi-magic-sessionmanager-geoip && pm2-runtime start ecosystem.config.js
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
with `MAXMIND_ACCOUNT_ID`, `MAXMIND_LICENSE_KEY` and `MAXMIND_EDITION_ID=GeoLite2-City` set. **Update database** in the admin downloads the file only on the instance that answered; the GeoIP status reports `scope: "instance"` and a non-reversible `instance` fingerprint so you can tell instances apart. The pm2 workers of one container share the file.
|
|
578
|
+
|
|
579
|
+
### Configuration
|
|
580
|
+
|
|
581
|
+
```js
|
|
582
|
+
// config/plugins.js
|
|
583
|
+
module.exports = () => ({
|
|
584
|
+
'magic-sessionmanager': {
|
|
585
|
+
enabled: true,
|
|
586
|
+
config: {
|
|
587
|
+
coordination: {
|
|
588
|
+
enabled: true, // false = per-process state, the behaviour before 4.10
|
|
589
|
+
counterStore: null, // optional: Redis (or other) store for lockout and rate-limit counters
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
The database store needs nothing else. If you already run Redis and want the counters there, pass an object with four async methods (`hit` must return the count written by that call, as the Lua script below does) and an optional `release`. Example with [node-redis](https://github.com/redis/node-redis) (`npm i redis`); when Redis fails, the plugin falls back to the database for that call:
|
|
597
|
+
|
|
598
|
+
```js
|
|
599
|
+
// config/plugins.js
|
|
600
|
+
const { createClient } = require('redis');
|
|
601
|
+
|
|
602
|
+
const redis = createClient({ url: process.env.REDIS_URL });
|
|
603
|
+
redis.connect();
|
|
604
|
+
|
|
605
|
+
const HIT = `
|
|
606
|
+
local start = tonumber(redis.call('HGET', KEYS[1], 's') or '0')
|
|
607
|
+
local now, win = tonumber(ARGV[1]), tonumber(ARGV[2])
|
|
608
|
+
if start <= now - win then redis.call('HSET', KEYS[1], 'h', 1, 's', now)
|
|
609
|
+
else redis.call('HINCRBY', KEYS[1], 'h', 1) end
|
|
610
|
+
if redis.call('PTTL', KEYS[1]) < win then redis.call('PEXPIRE', KEYS[1], win) end
|
|
611
|
+
return redis.call('HMGET', KEYS[1], 'h', 's', 'b')`;
|
|
612
|
+
|
|
613
|
+
const toState = ([h, s, b]) =>
|
|
614
|
+
h === null && b === null
|
|
615
|
+
? null
|
|
616
|
+
: { hits: Number(h || 0), windowStart: Number(s || 0), blockedUntil: Number(b || 0) };
|
|
617
|
+
|
|
618
|
+
module.exports = () => ({
|
|
619
|
+
'magic-sessionmanager': {
|
|
620
|
+
config: {
|
|
621
|
+
coordination: {
|
|
622
|
+
counterStore: {
|
|
623
|
+
hit: async (key, windowMs) =>
|
|
624
|
+
toState(
|
|
625
|
+
await redis.eval(HIT, {
|
|
626
|
+
keys: [`msm:${key}`],
|
|
627
|
+
arguments: [String(Date.now()), String(windowMs)],
|
|
628
|
+
})
|
|
629
|
+
),
|
|
630
|
+
peek: async (key) => toState(await redis.hmGet(`msm:${key}`, ['h', 's', 'b'])),
|
|
631
|
+
block: async (key, untilMs) => {
|
|
632
|
+
await redis.hSet(`msm:${key}`, 'b', String(untilMs));
|
|
633
|
+
// Keep the key at least until the block ends (-1 = no expiry yet).
|
|
634
|
+
if ((await redis.pTTL(`msm:${key}`)) < untilMs - Date.now()) {
|
|
635
|
+
await redis.pExpireAt(`msm:${key}`, untilMs);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
clear: async (key) => {
|
|
639
|
+
await redis.del(`msm:${key}`);
|
|
640
|
+
},
|
|
641
|
+
// Optional: gives back one hit (a login that ended with a 5xx or
|
|
642
|
+
// was turned away as over the limit). Without it the hit stays.
|
|
643
|
+
release: async (key) => {
|
|
644
|
+
await redis.hIncrBy(`msm:${key}`, 'h', -1);
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### Verifying
|
|
654
|
+
|
|
655
|
+
`npm run test:concurrency` starts 8 Node processes against one database and checks exact shared counts (every hit also reports its own count), a single job-lease winner, lock-protected read-modify-write, no duplicate check-then-create rows, exact revision bumps and a cluster-wide lockout. It runs on SQLite by default and also on PostgreSQL with `MSM_TEST_PG_URL=postgres://user@host:5432/db`. A control step does the same check-then-create without the lock and reports the duplicates that Strapi's Core Store produces in that case.
|
|
656
|
+
|
|
657
|
+
Measured over HTTP on an isolated Strapi 5.61 host with one PostgreSQL 16 database (synthetic users and IPs, outbound network blocked), once with 4 separate processes and once with pm2 cluster mode (4 workers): 48 parallel wrong passwords from one IP let exactly `maxFailedLogins` (5) reach the password check, after which every process answers 429; 48 parallel `logout-others` calls with a limit of 10 allowed exactly 10; 50 parallel refreshes with one refresh token produced exactly one new token and one active session; 60 parallel partial settings saves lost no field; 20 saves with the same `revision` gave one 200 and nineteen 409; a settings change reached the other processes within 2.5 seconds; idle cleanup ran exactly once per interval and retention once. The same suite passed on SQLite with one process. Not covered: MySQL, the Redis counter store over HTTP, and Railway itself.
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
508
661
|
## Security and privacy
|
|
509
662
|
|
|
510
663
|
- **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:
|
|
@@ -524,15 +677,15 @@ Errors use Strapi's `{ data: null, error }` envelope: 400 for invalid input, 404
|
|
|
524
677
|
|
|
525
678
|
## Troubleshooting
|
|
526
679
|
|
|
527
|
-
| Problem | Fix
|
|
528
|
-
| --------------------------------------------------------------------- |
|
|
529
|
-
| No Session Manager menu item | Check `config/plugins.ts`, run `npm run build`, restart, hard-refresh the browser. For non-Super-Admin roles, grant "Access the Session Manager plugin".
|
|
530
|
-
| No sessions appear | Only end-user sign-ins through Users & Permissions are recorded, not Strapi admin sign-ins. Check the Strapi log.
|
|
531
|
-
| Startup fails with `SESSION_ENCRYPTION_KEY is required in production` | Set the variable and restart.
|
|
532
|
-
| 401 on every request after a sign-in | Check the `X-Session-Terminated-Reason` header. With Strict token check, tokens without a session record are rejected.
|
|
533
|
-
| 429 on sign-in | Temporary IP lockout. Wait 15 minutes or raise `maxFailedLogins`. Behind a proxy, turn on Trust proxy headers so the lockout targets the real client.
|
|
534
|
-
| Location is always "—" | IP location lookup is off, the provider is `disabled`, or `local-mmdb` has no database. See Configuration › Location data.
|
|
535
|
-
| Numbers differ from 4.x | The widget and Analytics now count Active and Idle by the configured inactivity timeout; "Online now" is now "Active sessions".
|
|
680
|
+
| Problem | Fix |
|
|
681
|
+
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
682
|
+
| No Session Manager menu item | Check `config/plugins.ts`, run `npm run build`, restart, hard-refresh the browser. For non-Super-Admin roles, grant "Access the Session Manager plugin". |
|
|
683
|
+
| No sessions appear | Only end-user sign-ins through Users & Permissions are recorded, not Strapi admin sign-ins. Check the Strapi log. |
|
|
684
|
+
| Startup fails with `SESSION_ENCRYPTION_KEY is required in production` | Set the variable and restart. |
|
|
685
|
+
| 401 on every request after a sign-in | Check the `X-Session-Terminated-Reason` header. With Strict token check, tokens without a session record are rejected. |
|
|
686
|
+
| 429 on sign-in | Temporary IP lockout. Wait 15 minutes or raise `maxFailedLogins`. Behind a proxy, turn on Trust proxy headers so the lockout targets the real client. With `Retry-After: 1`: more sign-ins from one address were running at once than `maxFailedLogins`; retry after a second. |
|
|
687
|
+
| Location is always "—" | IP location lookup is off, the provider is `disabled`, or `local-mmdb` has no database. See Configuration › Location data. |
|
|
688
|
+
| Numbers differ from 4.x | The widget and Analytics now count Active and Idle by the configured inactivity timeout; "Online now" is now "Active sessions". |
|
|
536
689
|
|
|
537
690
|
The plugin stores sessions in the `magic_sessions` table and revocations in its own revoked-token table.
|
|
538
691
|
|
|
@@ -543,6 +696,7 @@ The plugin stores sessions in the `magic_sessions` table and revocations in its
|
|
|
543
696
|
```bash
|
|
544
697
|
npm ci --legacy-peer-deps
|
|
545
698
|
npm test # node --test tests/*.test.js tests/*.test.mjs
|
|
699
|
+
npm run test:concurrency # 8 processes on one database (SQLite; PostgreSQL with MSM_TEST_PG_URL)
|
|
546
700
|
npm run test:ts:front
|
|
547
701
|
npm run test:ts:back
|
|
548
702
|
npm run build
|
|
@@ -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-CaLVyCio.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 {
|
|
10
|
+
import { N as normalizeDeviceType, u as useSessionFormatters, m as pluginId, s as requireSessionList, n as logSafeAdminError, o as PersistentAlert, R as ReadableText, z as PageShell, A as StatGrid, B as StatCard, I as EqualGrid, b as getTranslation, O as getDeviceTypeMessage } from "./index-CHACmZsg.mjs";
|
|
11
11
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
12
12
|
const ANALYTICS_UNKNOWN_KEY = "unknown";
|
|
13
13
|
function increment(target, key) {
|
|
@@ -7,7 +7,7 @@ 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 } 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, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getSessionState, f as getDevicePresentation, u as useSessionFormatters, h as getSessionStatus, j as isNativeOnlySession, k as getSessionEndReasonPresentation, l as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, m as pluginId, n as logSafeAdminError, o as PersistentAlert, R as ReadableText, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as requireSessionList, v as
|
|
10
|
+
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getSessionState, f as getDevicePresentation, u as useSessionFormatters, h as getSessionStatus, j as isNativeOnlySession, k as getSessionEndReasonPresentation, l as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, m as pluginId, n as logSafeAdminError, o as PersistentAlert, R as ReadableText, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as requireSessionList, v as isCancelledRequest, w as filterSessionsBySearch, x as filterSessionsByStatus, y as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, z as PageShell, A as StatGrid, B as StatCard, F as restoreDialogFocus, G as pluginPermissions } from "./index-CHACmZsg.mjs";
|
|
11
11
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
12
12
|
const { formatMessage } = useIntl();
|
|
13
13
|
const key = reason || getSessionEndReason(session);
|
|
@@ -1373,7 +1373,7 @@ const HomePage = () => {
|
|
|
1373
1373
|
setNow(Date.now());
|
|
1374
1374
|
hasLoadedRef.current = true;
|
|
1375
1375
|
} catch (err) {
|
|
1376
|
-
if (requestId !== requestIdRef.current) return;
|
|
1376
|
+
if (requestId !== requestIdRef.current || isCancelledRequest(err)) return;
|
|
1377
1377
|
setLoadError(true);
|
|
1378
1378
|
logSafeAdminError("dashboard.loadSessions", err);
|
|
1379
1379
|
} finally {
|
|
@@ -9,7 +9,7 @@ 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-
|
|
12
|
+
const index = require("./index-CaLVyCio.js");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
14
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
15
15
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
@@ -1377,7 +1377,7 @@ const HomePage = () => {
|
|
|
1377
1377
|
setNow(Date.now());
|
|
1378
1378
|
hasLoadedRef.current = true;
|
|
1379
1379
|
} catch (err) {
|
|
1380
|
-
if (requestId !== requestIdRef.current) return;
|
|
1380
|
+
if (requestId !== requestIdRef.current || index.isCancelledRequest(err)) return;
|
|
1381
1381
|
setLoadError(true);
|
|
1382
1382
|
index.logSafeAdminError("dashboard.loadSessions", err);
|
|
1383
1383
|
} finally {
|
|
@@ -6,7 +6,7 @@ const reactIntl = require("react-intl");
|
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
|
7
7
|
const StrapiAdmin = require("@strapi/strapi/admin");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
|
-
const index = require("./index-
|
|
9
|
+
const index = require("./index-CaLVyCio.js");
|
|
10
10
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
11
11
|
const maskSensitiveValue = require("./maskSensitiveValue-BWcSjow7.js");
|
|
12
12
|
const LICENSE_STATE_MESSAGES = Object.freeze({
|
|
@@ -4,7 +4,7 @@ import { useIntl } from "react-intl";
|
|
|
4
4
|
import { Badge, Button, Flex, Typography, Field, TextInput, IconButton } from "@strapi/design-system";
|
|
5
5
|
import { useFetchClient, useNotification, useClipboard, Page } from "@strapi/strapi/admin";
|
|
6
6
|
import { EyeStriked, Eye, Duplicate, Download, ArrowClockwise } from "@strapi/icons";
|
|
7
|
-
import { u as useSessionFormatters, m as pluginId, n as logSafeAdminError,
|
|
7
|
+
import { u as useSessionFormatters, m as pluginId, n as logSafeAdminError, z as PageShell, o as PersistentAlert, R as ReadableText, P as PropertyList, b as getTranslation } from "./index-CHACmZsg.mjs";
|
|
8
8
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
9
9
|
import { m as maskSensitiveValue } from "./maskSensitiveValue-lLRhN_S7.mjs";
|
|
10
10
|
const LICENSE_STATE_MESSAGES = Object.freeze({
|
|
@@ -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 { s as requireSessionList, n as logSafeAdminError, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-
|
|
9
|
+
import { s as requireSessionList, n as logSafeAdminError, v as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-CHACmZsg.mjs";
|
|
10
10
|
function getSessionUserKey(session) {
|
|
11
11
|
return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
|
|
12
12
|
}
|
|
@@ -166,6 +166,7 @@ const OnlineUsersWidget = () => {
|
|
|
166
166
|
if (showLoading) setUserCounts(null);
|
|
167
167
|
}
|
|
168
168
|
} catch (error) {
|
|
169
|
+
if (isCancelledRequest(error)) return;
|
|
169
170
|
logSafeAdminError("onlineUsers.loadSessions", error);
|
|
170
171
|
if (showLoading) setLoadError(true);
|
|
171
172
|
} finally {
|
|
@@ -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-CaLVyCio.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;
|
|
@@ -187,6 +187,7 @@ const OnlineUsersWidget = () => {
|
|
|
187
187
|
if (showLoading) setUserCounts(null);
|
|
188
188
|
}
|
|
189
189
|
} catch (error) {
|
|
190
|
+
if (index.isCancelledRequest(error)) return;
|
|
190
191
|
index.logSafeAdminError("onlineUsers.loadSessions", error);
|
|
191
192
|
if (showLoading) setLoadError(true);
|
|
192
193
|
} finally {
|
|
@@ -4,7 +4,7 @@ import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSe
|
|
|
4
4
|
import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
|
|
5
5
|
import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Check } from "@strapi/icons";
|
|
6
6
|
import styled from "styled-components";
|
|
7
|
-
import {
|
|
7
|
+
import { H as ReadableParagraphs, b as getTranslation, n as logSafeAdminError, R as ReadableText, I as EqualGrid, o as PersistentAlert, P as PropertyList, J as formatSessionDate, C as ConfirmAction, K as refocusIfLost, m as pluginId, L as requireSuccessfulMutation, z as PageShell } from "./index-CHACmZsg.mjs";
|
|
8
8
|
import { useIntl } from "react-intl";
|
|
9
9
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
10
10
|
import { m as maskSensitiveValue } from "./maskSensitiveValue-lLRhN_S7.mjs";
|
|
@@ -3100,6 +3100,7 @@ function useSettingsForm() {
|
|
|
3100
3100
|
const canSave = hasChanges && errorCount === 0 && !saving;
|
|
3101
3101
|
const settingsRef = useRef(settings);
|
|
3102
3102
|
const savedSettingsRef = useRef(savedSettings);
|
|
3103
|
+
const revisionRef = useRef(null);
|
|
3103
3104
|
useLayoutEffect(() => {
|
|
3104
3105
|
settingsRef.current = settings;
|
|
3105
3106
|
savedSettingsRef.current = savedSettings;
|
|
@@ -3150,6 +3151,7 @@ function useSettingsForm() {
|
|
|
3150
3151
|
throw new Error("Invalid settings response");
|
|
3151
3152
|
}
|
|
3152
3153
|
const nextSettings = normalizeSettings(response.data.settings);
|
|
3154
|
+
revisionRef.current = Number.isInteger(response.data.revision) ? response.data.revision : null;
|
|
3153
3155
|
setSettings(nextSettings);
|
|
3154
3156
|
setSavedSettings(nextSettings);
|
|
3155
3157
|
await fetchGeoIpStatus();
|
|
@@ -3179,10 +3181,14 @@ function useSettingsForm() {
|
|
|
3179
3181
|
if (Object.keys(validateSettings(submitted)).length > 0) return false;
|
|
3180
3182
|
setSaving(true);
|
|
3181
3183
|
try {
|
|
3182
|
-
const response = await put(
|
|
3184
|
+
const response = await put(
|
|
3185
|
+
`/${pluginId}/settings`,
|
|
3186
|
+
revisionRef.current === null ? submitted : { ...submitted, revision: revisionRef.current }
|
|
3187
|
+
);
|
|
3183
3188
|
if (!response?.data?.success) {
|
|
3184
3189
|
throw new Error("Save failed");
|
|
3185
3190
|
}
|
|
3191
|
+
revisionRef.current = Number.isInteger(response.data.revision) ? response.data.revision : null;
|
|
3186
3192
|
const storedPayload = response.data.settings ?? (await get(`/${pluginId}/settings`))?.data?.settings;
|
|
3187
3193
|
const stored = normalizeSettings(storedPayload);
|
|
3188
3194
|
setSettings(stored);
|
|
@@ -3205,9 +3211,13 @@ function useSettingsForm() {
|
|
|
3205
3211
|
return true;
|
|
3206
3212
|
} catch (err) {
|
|
3207
3213
|
logSafeAdminError("settings.save", err);
|
|
3214
|
+
const isConflict = err?.response?.status === 409 || err?.response?.data?.error?.status === 409;
|
|
3208
3215
|
toggleNotification({
|
|
3209
3216
|
type: "danger",
|
|
3210
|
-
message: t(
|
|
3217
|
+
message: isConflict ? t(
|
|
3218
|
+
"settings.config.feedback.conflict",
|
|
3219
|
+
"Another administrator saved the settings in the meantime. Reload the page to see their changes, then apply yours again."
|
|
3220
|
+
) : t(
|
|
3211
3221
|
"settings.config.feedback.saveError",
|
|
3212
3222
|
"Settings could not be saved. Your changes are still in the form."
|
|
3213
3223
|
)
|