strapi-plugin-magic-sessionmanager 4.14.3 → 4.16.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 +87 -0
- package/README.md +216 -85
- package/dist/admin/{Analytics-CFEgpg-G.mjs → Analytics-D4gsVwL0.mjs} +1 -1
- package/dist/admin/{Analytics-DSpn7W5A.js → Analytics-me4qzS0I.js} +1 -1
- package/dist/admin/{App-BBne8xI6.mjs → App-BJwtFWxl.mjs} +921 -106
- package/dist/admin/{App-UlRrLKcx.js → App-BTG-2Q26.js} +920 -105
- package/dist/admin/{OnlineUsersWidget-GFcYyZ9L.js → OnlineUsersWidget-DYS3Vy1Q.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-C3YMTEGD.mjs → OnlineUsersWidget-Yd283YDy.mjs} +1 -1
- package/dist/admin/{Settings-BbUNvjno.mjs → Settings-DIlvfdjZ.mjs} +427 -83
- package/dist/admin/{Settings-DVhW9XHB.js → Settings-TPZ9_75s.js} +425 -81
- package/dist/admin/{de-B0CBR1Dw.js → de-BuMw1gBJ.js} +130 -8
- package/dist/admin/{de-BlKn1pSD.mjs → de-DB9ldYwN.mjs} +130 -8
- package/dist/admin/{en-IT0YTY8f.mjs → en-BbLMPQB3.mjs} +130 -8
- package/dist/admin/{en-D0ZGIIjz.js → en-BqGhOJDy.js} +130 -8
- package/dist/admin/{es-CWee-XCR.js → es-BaIeckl9.js} +130 -8
- package/dist/admin/{es-BCGzaaCh.mjs → es-C5iaiE9G.mjs} +130 -8
- package/dist/admin/{fr-xBIH4Byq.mjs → fr-BEvBUCwI.mjs} +130 -8
- package/dist/admin/{fr-rQS1M7jE.js → fr-D1YKyTex.js} +130 -8
- package/dist/admin/{index-1KmiZSfy.js → index-CgZiLcJ1.js} +13 -10
- package/dist/admin/{index-MOJkFXcZ.mjs → index-DUESEUaO.mjs} +13 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-DWDeIDVa.mjs → pt-DeDih9cR.mjs} +130 -8
- package/dist/admin/{pt-C-yTLhnS.js → pt-DtnW-s0V.js} +130 -8
- package/dist/admin/riskData-BVs9GpgD.js +26 -0
- package/dist/admin/riskData-CI1gm2yI.mjs +27 -0
- package/dist/server/index.js +2500 -299
- package/dist/server/index.mjs +2500 -299
- package/package.json +1 -1
- package/scripts/geoip-updater.cjs +58 -15
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ Live docs: [https://schero94.github.io/Magic-Sessionmanager/](https://schero94.g
|
|
|
41
41
|
- [Examples](#examples)
|
|
42
42
|
- [Optional route policy: `session-required`](#optional-route-policy-session-required)
|
|
43
43
|
- [Admin API and permissions](#admin-api-and-permissions)
|
|
44
|
+
- [Admin activity and sign-in history](#admin-activity-and-sign-in-history)
|
|
44
45
|
- [Running several instances (Railway replicas, pm2 cluster)](#running-several-instances-railway-replicas-pm2-cluster)
|
|
45
46
|
- [Performance](#performance)
|
|
46
47
|
- [Security and privacy](#security-and-privacy)
|
|
@@ -58,19 +59,20 @@ Live docs: [https://schero94.github.io/Magic-Sessionmanager/](https://schero94.g
|
|
|
58
59
|
|
|
59
60
|
## Features
|
|
60
61
|
|
|
61
|
-
| Area | What you get
|
|
62
|
-
| ---------------------- |
|
|
63
|
-
| Overview | A sessions dashboard with Active, Idle and Ended counts, search, filters, CSV and JSON export, and a details dialog per session (device, browser, IP address, location, security score). |
|
|
64
|
-
| Control | End one session, end all sessions of a user, delete a record, or block a user. Ended sessions are rejected on the next request with 401 and a reason header.
|
|
65
|
-
| Your users | Content API routes for "my sessions", "current session", log out, log out everywhere and log out other devices. Each user only ever sees their own sessions.
|
|
66
|
-
| Login protection | Temporary IP lockout after failed sign-ins, Content API rate limits, optional rejection of VPN, proxy or low-score sign-ins, and country allow or block lists.
|
|
67
|
-
| Location | IP location from a local MaxMind GeoLite2 database (no third party in the sign-in path) or from ipapi.co, or turned off.
|
|
68
|
-
| Alerts | Security emails to the user through Strapi's Email plugin and sign-in notifications to Discord or Slack.
|
|
69
|
-
| Admin integration | A Sessions panel next to each user in the Content Manager and an Online users widget on the Strapi homepage.
|
|
70
|
-
| Admin panel sessions | Who can use the Strapi admin panel, who is signed in, on which browser and since when. Sign an admin out of one browser or everywhere; it takes effect on their next click.
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
62
|
+
| Area | What you get |
|
|
63
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
64
|
+
| Overview | A sessions dashboard with Active, Idle and Ended counts, search, filters, CSV and JSON export, and a details dialog per session (device, browser, IP address, location, and a security score when a [risk data source](#risk-data-vpn-proxy-tor) is set up). |
|
|
65
|
+
| Control | End one session, end all sessions of a user, delete a record, or block a user. Ended sessions are rejected on the next request with 401 and a reason header. |
|
|
66
|
+
| Your users | Content API routes for "my sessions", "current session", log out, log out everywhere and log out other devices. Each user only ever sees their own sessions. |
|
|
67
|
+
| Login protection | Temporary IP lockout after failed sign-ins, Content API rate limits, optional rejection of VPN, proxy or low-score sign-ins (needs a [risk data source](#risk-data-vpn-proxy-tor)), and country allow or block lists. |
|
|
68
|
+
| Location | IP location from a local MaxMind GeoLite2 database (no third party in the sign-in path) or from ipapi.co, or turned off. |
|
|
69
|
+
| Alerts | Security emails to the user through Strapi's Email plugin and sign-in notifications to Discord or Slack. |
|
|
70
|
+
| Admin integration | A Sessions panel next to each user in the Content Manager and an Online users widget on the Strapi homepage. |
|
|
71
|
+
| Admin panel sessions | Who can use the Strapi admin panel, who is signed in, on which browser and since when. Sign an admin out of one browser or everywhere; it takes effect on their next click. |
|
|
72
|
+
| Admin activity | A sign-in history per admin (sign-ins, failed attempts, lockouts, sign-outs, who signed out whom) with IP address, browser and location, and optional Content Manager activity. |
|
|
73
|
+
| Native Strapi sessions | Works with `jwtManagement: 'refresh'` (Strapi's own sessions and refresh tokens) and with `'legacy-support'`. |
|
|
74
|
+
| Several processes | Lockout, rate limits, jobs and settings stay consistent across pm2 workers and Railway replicas that share one database. |
|
|
75
|
+
| Privacy | Stored tokens are encrypted (AES-256-GCM) and never returned. Retention deletes old history automatically. No telemetry. |
|
|
74
76
|
|
|
75
77
|
---
|
|
76
78
|
|
|
@@ -203,12 +205,13 @@ Open **Session Manager** and switch to **Admin panel** (the switch below the tit
|
|
|
203
205
|
- **Sessions of an admin:** one entry per signed-in browser with Strapi's device label (for example "Chrome on macOS"), **This browser**, **Remember me**, Signed in, Last active and **Ends at the latest**. **Sign out** ends that browser, **Sign out everywhere** ends all of them, **Manage in Settings** opens the admin in Settings › Users.
|
|
204
206
|
- **Confirmation:** every sign-out asks first. Signing yourself out of the browser you are using shows a warning; you are then taken to the login page.
|
|
205
207
|
- **Protection:** an admin without the Super Admin role cannot sign out a Super Admin, so the last active Super Admin can never be signed out by someone else. The view explains this instead of showing a disabled button.
|
|
206
|
-
-
|
|
208
|
+
- **Sign-in history and activity** (roles with "View admin activity"): the details dialog gets three tabs, **Sessions**, **Sign-in history** and **Activity**. The history lists sign-ins with IP address, location, browser and operating system and whether that session is **Still signed in**, **Signed out** (and by whom) or **Session ended**, plus failed attempts with the reason, lockouts and sign-outs. **Activity** lists the entries the admin opened, created, edited, published, unpublished, discarded or deleted in the Content Manager, each with a link to the entry. Both tabs filter by event or action, content type and period, page with **Show more** and offer **Export CSV**. A **Recent sign-in activity** card under the table shows the latest five events of all admins, including failed sign-ins with an unknown email ("Unknown account"). See [Admin activity and sign-in history](#admin-activity-and-sign-in-history).
|
|
209
|
+
- "Last active" is the last time the browser renewed its access token (Strapi's own signal), not every click. Strapi's own session records hold no IP address; the IP addresses in the sign-in history come from the plugin's security log.
|
|
207
210
|
|
|
208
211
|
### Session details
|
|
209
212
|
|
|
210
213
|
- A state sentence that explains why the session is in its state, for example "Ended {time} · Ended manually."
|
|
211
|
-
- **User** (with an **Open user** link to the Content Manager), **Session** (Signed in, Last active, Ended at, End reason), **Device** (type, browser, operating system, IP address), **Location and security** (country, city, time zone, security score "{score}/100", VPN and proxy).
|
|
214
|
+
- **User** (with an **Open user** link to the Content Manager), **Session** (Signed in, Last active, Ended at, End reason), **Device** (type, browser, operating system, IP address), **Location and security** (country, city, time zone, and security score "{score}/100", VPN and proxy when the sign-in had [risk data](#risk-data-vpn-proxy-tor); otherwise one "Not available" row with a link to set up risk data. Sessions recorded before 4.15 show "Not available", because their stored score of 100 was never a real check).
|
|
212
215
|
- **Look up location** for sessions without a stored location. The lookup runs only when you click it, because it can send the IP address to ipapi.co.
|
|
213
216
|
- **Technical details** (collapsed): record ID with a copy button and the raw user agent.
|
|
214
217
|
- Footer: **End session** with confirmation on open sessions; ended sessions show "This session has already ended."
|
|
@@ -231,15 +234,16 @@ Part of every supported Strapi version (the widgets API exists since Strapi 5.13
|
|
|
231
234
|
|
|
232
235
|
Two links: **Configuration** and **Analytics**.
|
|
233
236
|
|
|
234
|
-
**Configuration** has five tabs, deep-linkable with `?tab=sessions|login-protection|location-data|alerts|data-retention
|
|
237
|
+
**Configuration** has five tabs, deep-linkable with `?tab=sessions|login-protection|location-data|alerts|data-retention`, and a sixth, `admin-activity`, for roles with "View admin activity":
|
|
235
238
|
|
|
236
239
|
| Tab | Question | Contents |
|
|
237
240
|
| ---------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
238
241
|
| **Sessions** | How long does a session stay valid? | Inactivity timeout, maximum session age; Advanced: "Last active" update interval, idle check interval and method. Token check (Strict / Relaxed); Advanced: grace period after sign-in, token encryption key generator. A read-only card on what your app receives when a session is rejected. |
|
|
239
242
|
| **Login protection** | Which sign-ins are refused, and why? | Temporary IP lockout, Trust proxy headers, Reject suspicious sign-ins, If the location cannot be determined, Country rules (Allow only listed countries / Reject listed countries), a read-only card on why sign-ins are refused. |
|
|
240
|
-
| **Location data** | Where do IP location and risk data come from? | IP location lookup, Security scoring, Provider, GeoIP database status, MaxMind credentials, Update database / Force download.
|
|
243
|
+
| **Location data** | Where do IP location and risk data come from? | IP location lookup, Security scoring, Provider, GeoIP database status, MaxMind credentials, Update database / Force download, Risk data (GeoIP2 Anonymous IP, GeoLite2 ASN heuristic). |
|
|
241
244
|
| **Alerts** | Who is told about sign-ins? | Security emails to users (with email templates) and Team notifications to Discord or Slack. |
|
|
242
245
|
| **Data and retention** | How long is session history kept? | Keep ended sessions for, and **Delete ended sessions**. |
|
|
246
|
+
| **Admin activity** | What is recorded about admins, and how long? | Record admin sign-ins, Record Content Manager activity (with a note on informing employees and the works council), Store IP addresses, Anonymise the last part of IP addresses, Keep security events for. |
|
|
243
247
|
|
|
244
248
|
**Save** applies the whole form; **Discard changes** re-loads the stored values (it does not restore defaults). Leaving with unsaved changes asks first. Settings are saved in the database; other server processes apply them within 30 seconds.
|
|
245
249
|
|
|
@@ -369,41 +373,43 @@ export default () => ({
|
|
|
369
373
|
|
|
370
374
|
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.
|
|
371
375
|
|
|
372
|
-
| Key | Default | Admin unit and range | Configuration tab | Meaning
|
|
373
|
-
| ------------------------------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------- | ----------------------------- |
|
|
374
|
-
| `inactivityTimeout` | 15 min (`900000` ms) | min, 1 to 1440 | Sessions | Unused this long, a session becomes idle and then ends as "Timed out". Also decides who counts as online.
|
|
375
|
-
| `maxSessionAgeDays` | 30 | days, 1 to 365 | Sessions | Maximum age from sign-in, regardless of activity. Applied on the session's next request.
|
|
376
|
-
| `lastSeenRateLimit` | 30 s (`30000` ms) | s, 5 to 300 | Sessions › Advanced | Minimum interval between "Last active" updates.
|
|
377
|
-
| `cleanupInterval` | 30 min (`1800000` ms) | min, 5 to 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.
|
|
378
|
-
| `cleanupUseDbDirect` | `false` | boolean | Sessions › Advanced | Idle check with one SQL update instead of the Document Service (skips lifecycle hooks).
|
|
379
|
-
| `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.
|
|
380
|
-
| `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.
|
|
381
|
-
| `maxFailedLogins` | 5 | 0 to 100, 0 = off | Login protection | Temporary IP lockout threshold (failed sign-ins from one IP within 15 minutes).
|
|
382
|
-
| `trustedProxies` | off | boolean | Login protection | Read the client IP from proxy headers. Only behind a proxy you control.
|
|
383
|
-
| `blockSuspiciousSessions` | `false` | boolean | Login protection | Reject suspicious sign-ins.
|
|
384
|
-
| `geoLookupFailureMode` | `'auto'` | auto, allow, block | Login protection | What happens when the location cannot be determined.
|
|
385
|
-
| `enableGeofencing` | `false` | boolean | Login protection | Use country rules.
|
|
386
|
-
| `allowedCountries` / `blockedCountries` | `[]` | ISO 3166-1 alpha-2 codes | Login protection | Allow only listed countries / Reject listed countries.
|
|
387
|
-
| `enableGeolocation` | `true` | boolean | Location data | IP location lookup at sign-in. Required by country rules, suspicious-sign-in checks and alerts.
|
|
388
|
-
| `enableSecurityScoring` | `true` | boolean | Location data | Apply the security score thresholds (below 70: suspicious-sign-in email, below 50: rejection if enabled).
|
|
389
|
-
| `geoIpProvider` | `'auto'` | auto, local-mmdb, ipapi, disabled | Location data | Where location data comes from.
|
|
390
|
-
| `geoIpDatabasePath` | `MAGIC_SESSIONMANAGER_GEOIP_DATABASE` or `''` | file name | Location data › Advanced | Local MaxMind-compatible database.
|
|
391
|
-
| `enableEmailAlerts` | `false` | boolean | Alerts | Security emails to users.
|
|
392
|
-
| `alertOnSuspiciousLogin` / `alertOnNewLocation` / `alertOnVpnProxy` | `true` | boolean | Alerts | Which events send an email.
|
|
393
|
-
| `enableWebhooks` | `false` | boolean | Alerts | Team notifications.
|
|
394
|
-
| `discordWebhookUrl` / `slackWebhookUrl` | `''` | https URL on discord.com / discordapp.com, or hooks.slack.com | Alerts | Any other host is rejected.
|
|
395
|
-
| `retentionDays` | 90 | days, 1 to 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.
|
|
396
|
-
| `rateLimitWriteMax` / `rateLimitReadMax` / `rateLimitWindowSeconds` | 10 / 120 / 60 | 1 to 1000 / 1 to 10000 / 10 to 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.
|
|
397
|
-
| `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.
|
|
376
|
+
| Key | Default | Admin unit and range | Configuration tab | Meaning |
|
|
377
|
+
| ------------------------------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
378
|
+
| `inactivityTimeout` | 15 min (`900000` ms) | min, 1 to 1440 | Sessions | Unused this long, a session becomes idle and then ends as "Timed out". Also decides who counts as online. |
|
|
379
|
+
| `maxSessionAgeDays` | 30 | days, 1 to 365 | Sessions | Maximum age from sign-in, regardless of activity. Applied on the session's next request. |
|
|
380
|
+
| `lastSeenRateLimit` | 30 s (`30000` ms) | s, 5 to 300 | Sessions › Advanced | Minimum interval between "Last active" updates. |
|
|
381
|
+
| `cleanupInterval` | 30 min (`1800000` ms) | min, 5 to 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. |
|
|
382
|
+
| `cleanupUseDbDirect` | `false` | boolean | Sessions › Advanced | Idle check with one SQL update instead of the Document Service (skips lifecycle hooks). |
|
|
383
|
+
| `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. |
|
|
384
|
+
| `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. |
|
|
385
|
+
| `maxFailedLogins` | 5 | 0 to 100, 0 = off | Login protection | Temporary IP lockout threshold (failed sign-ins from one IP within 15 minutes). |
|
|
386
|
+
| `trustedProxies` | off | boolean | Login protection | Read the client IP from proxy headers. Only behind a proxy you control. |
|
|
387
|
+
| `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. |
|
|
388
|
+
| `geoLookupFailureMode` | `'auto'` | auto, allow, block | Login protection | What happens when the location cannot be determined. |
|
|
389
|
+
| `enableGeofencing` | `false` | boolean | Login protection | Use country rules. |
|
|
390
|
+
| `allowedCountries` / `blockedCountries` | `[]` | ISO 3166-1 alpha-2 codes | Login protection | Allow only listed countries / Reject listed countries. |
|
|
391
|
+
| `enableGeolocation` | `true` | boolean | Location data | IP location lookup at sign-in. Required by country rules, suspicious-sign-in checks and alerts. |
|
|
392
|
+
| `enableSecurityScoring` | `true` | boolean | Location data | Apply the security score thresholds (below 70: suspicious-sign-in email, below 50: rejection if enabled). Needs a [risk data source](#risk-data-vpn-proxy-tor). |
|
|
393
|
+
| `geoIpProvider` | `'auto'` | auto, local-mmdb, ipapi, disabled | Location data | Where location data comes from. |
|
|
394
|
+
| `geoIpDatabasePath` | `MAGIC_SESSIONMANAGER_GEOIP_DATABASE` or `''` | file name | Location data › Advanced | Local MaxMind-compatible database. A file name is read from `data/magic-sessionmanager/geoip/` (where downloads write it), then from the Strapi folder for older setups; an absolute path is used as it is. Names with `..` or folders are refused with a field error. A file name is read from `data/magic-sessionmanager/geoip/` (where downloads write it), then from the Strapi folder for older setups; an absolute path is used as it is. Names with `..` or folders are refused with a field error. |
|
|
395
|
+
| `enableEmailAlerts` | `false` | boolean | Alerts | Security emails to users. |
|
|
396
|
+
| `alertOnSuspiciousLogin` / `alertOnNewLocation` / `alertOnVpnProxy` | `true` | boolean | Alerts | Which events send an email. Suspicious sign-in and VPN or proxy need a [risk data source](#risk-data-vpn-proxy-tor). |
|
|
397
|
+
| `enableWebhooks` | `false` | boolean | Alerts | Team notifications. |
|
|
398
|
+
| `discordWebhookUrl` / `slackWebhookUrl` | `''` | https URL on discord.com / discordapp.com, or hooks.slack.com | Alerts | Any other host is rejected. |
|
|
399
|
+
| `retentionDays` | 90 | days, 1 to 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. |
|
|
400
|
+
| `rateLimitWriteMax` / `rateLimitReadMax` / `rateLimitWindowSeconds` | 10 / 120 / 60 | 1 to 1000 / 1 to 10000 / 10 to 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. |
|
|
401
|
+
| `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. |
|
|
398
402
|
|
|
399
403
|
### Environment variables
|
|
400
404
|
|
|
401
|
-
| Variable
|
|
402
|
-
|
|
|
403
|
-
| `SESSION_ENCRYPTION_KEY`
|
|
404
|
-
| `MAGIC_SESSIONMANAGER_GEOIP_DATABASE`
|
|
405
|
-
| `MAXMIND_ACCOUNT_ID`, `MAXMIND_LICENSE_KEY`
|
|
406
|
-
| `
|
|
405
|
+
| Variable | Purpose |
|
|
406
|
+
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
407
|
+
| `SESSION_ENCRYPTION_KEY` | Key for AES-256-GCM encryption of stored tokens. Required when `NODE_ENV=production` (startup fails without it). Keep it stable. |
|
|
408
|
+
| `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`). |
|
|
409
|
+
| `MAXMIND_ACCOUNT_ID`, `MAXMIND_LICENSE_KEY` | MaxMind credentials for database updates. They take precedence over credentials stored in the admin. |
|
|
410
|
+
| `MAGIC_SESSIONMANAGER_ANONYMOUS_IP_DATABASE` | Path of a GeoIP2 Anonymous IP database (risk data). Default: `data/magic-sessionmanager/geoip/GeoIP2-Anonymous-IP.mmdb`. |
|
|
411
|
+
| `MAGIC_SESSIONMANAGER_ASN_DATABASE` | Path of a GeoLite2 ASN database (hosting heuristic). Default: `data/magic-sessionmanager/geoip/GeoLite2-ASN.mmdb`. |
|
|
412
|
+
| `MAXMIND_EDITION_ID` | Edition for the CLI updater, for example `GeoLite2-City`. |
|
|
407
413
|
|
|
408
414
|
---
|
|
409
415
|
|
|
@@ -426,7 +432,7 @@ The MaxMind database download is a separate authenticated network request; the M
|
|
|
426
432
|
|
|
427
433
|
### Local MaxMind database (recommended)
|
|
428
434
|
|
|
429
|
-
A local GeoLite2 City database avoids remote lookups in the sign-in path and gives country, city, region, time zone and coordinates. GeoLite2 Country databases are supported as a country-only fallback.
|
|
435
|
+
A local GeoLite2 City database avoids remote lookups in the sign-in path and gives country, city, region, time zone and coordinates. GeoLite2 Country databases are supported as a country-only fallback. Location databases (GeoLite2 and GeoIP2 City or Country) carry no VPN, proxy or Tor data, so they give no security score; see [Risk data](#risk-data-vpn-proxy-tor).
|
|
430
436
|
|
|
431
437
|
1. Create a free MaxMind account: https://dev.maxmind.com/geoip/geolite2-free-geolocation-data/
|
|
432
438
|
2. In **Configuration › Location data**, choose the provider **Local database**, enter the MaxMind account ID and license key, and click **Update database**. The license key is stored in the plugin store and never returned to the browser.
|
|
@@ -443,6 +449,51 @@ npm run geoip:update # in the plugin repository
|
|
|
443
449
|
|
|
444
450
|
The updater checks MaxMind's `Last-Modified` header and skips the download when the local copy is current; add `--force` to download anyway. Schedule it weekly or twice weekly. MaxMind requires GeoLite databases to stay current and limits GeoLite users to 30 downloads per day.
|
|
445
451
|
|
|
452
|
+
### Risk data (VPN, proxy, Tor)
|
|
453
|
+
|
|
454
|
+
Location data answers "where is this address?", not "is it a VPN, proxy or Tor exit?". Neither location provider supplies risk data:
|
|
455
|
+
|
|
456
|
+
- ipapi.co's documented JSON response has no VPN, proxy or threat fields ([ipapi.co API](https://ipapi.co/api/)).
|
|
457
|
+
- GeoLite2 and GeoIP2 City or Country databases carry no anonymiser flags.
|
|
458
|
+
|
|
459
|
+
Up to 4.14, the plugin read a `threat` object that ipapi.co never sends and scored every local result 100. Every check below was therefore inactive, although this README described it as working. Since 4.15, these features need a **risk data source** and say so in the admin when none is set up:
|
|
460
|
+
|
|
461
|
+
| Feature | Without a risk data source |
|
|
462
|
+
| -------------------------------------------- | ------------------------------------------------------------------ |
|
|
463
|
+
| Reject suspicious sign-ins | Off and disabled; refuses nothing as suspicious. |
|
|
464
|
+
| Security scoring | Off and disabled; sessions store no score (`securityScore: null`). |
|
|
465
|
+
| Suspicious sign-in email, VPN or proxy email | Off and disabled; never sent. |
|
|
466
|
+
| `login.suspicious` team notification | Never sent; sign-ins post `login.new_location` or `login.success`. |
|
|
467
|
+
| Session details | One "Not available" row instead of score, VPN and proxy. |
|
|
468
|
+
|
|
469
|
+
#### Set up a risk data source
|
|
470
|
+
|
|
471
|
+
Configuration › Location data › **Risk data (VPN, proxy, Tor)** downloads one of two local MaxMind databases with the MaxMind credentials of the Provider and database card. The license key never reaches the browser, and lookups stay on your server: no IP address is sent anywhere.
|
|
472
|
+
|
|
473
|
+
| Database | MaxMind edition | Cost | What it detects |
|
|
474
|
+
| ------------------- | --------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
475
|
+
| GeoIP2 Anonymous IP | `GeoIP2-Anonymous-IP` | Paid; the download fails with "MaxMind refused the download…" if your account does not include it | VPN (`isAnonymousVpn`), public and residential proxies, Tor exit nodes, hosting providers ([MaxMind docs](https://dev.maxmind.com/geoip/docs/databases/anonymous-ip/)). An address that is not in the database is a real "clean" answer. |
|
|
476
|
+
| GeoLite2 ASN | `GeoLite2-ASN` | Free | Only a **heuristic**: a sign-in from a short list of large hosting and cloud networks (AWS, Google Cloud, Azure, DigitalOcean, Hetzner, OVHcloud, Linode, Vultr, Contabo, Oracle Cloud, Alibaba, Scaleway, Leaseweb, IONOS, Hostinger, M247) counts as a hosting network. It does not detect VPNs, proxies or Tor. Used only without the Anonymous IP database; with both, ASN adds the network name. |
|
|
477
|
+
|
|
478
|
+
The CLI updater downloads them too: `MAXMIND_EDITION_ID=GeoIP2-Anonymous-IP npx strapi-magic-sessionmanager-geoip` or `MAXMIND_EDITION_ID=GeoLite2-ASN …`. Each instance reads its own files, like the location database.
|
|
479
|
+
|
|
480
|
+
What the risk data does:
|
|
481
|
+
|
|
482
|
+
| Signal | Score effect | Reject suspicious sign-ins | Suspicious-sign-in email and `login.suspicious` | VPN or proxy email |
|
|
483
|
+
| ---------------------------------------------------- | ------------ | -------------------------------------------------------------- | ----------------------------------------------- | ------------------ |
|
|
484
|
+
| Tor exit node | −50 | Refused (`tor_exit_node`) | Yes | No |
|
|
485
|
+
| VPN | −20 | Refused (`vpn_detected`) | Yes | Yes |
|
|
486
|
+
| Public or residential proxy | −15 | Refused (`proxy_detected`) | Yes | Yes |
|
|
487
|
+
| Hosting network (Anonymous IP or ASN heuristic) | −20 | Not refused, because servers and CI jobs sign in from them too | Yes | No |
|
|
488
|
+
| Any anonymiser (`isAnonymous`) | −10 | Through the score only | Through the score | No |
|
|
489
|
+
| Score below 50 / below 70 (with Security scoring on) | | Refused below 50 | Yes below 70 | |
|
|
490
|
+
|
|
491
|
+
Lookup results keep the field names of earlier versions (`isVpn`, `isProxy`, `isThreat`, `securityScore`, `riskLevel`) and add `isTor`, `isHosting`, `isAnonymous`, `isPublicProxy`, `isResidentialProxy` and `riskSource` (`'anonymous-ip'`, `'asn-heuristic'` or `null`). `isThreat` stays `false`: MaxMind's Anonymous IP data has no threat category.
|
|
492
|
+
|
|
493
|
+
#### Upgrading from 4.14 or earlier
|
|
494
|
+
|
|
495
|
+
Saved settings are not changed: a switch that was on stays stored and applies once a source exists. Check the switches before you download a risk database: a saved "Reject suspicious sign-ins" starts refusing VPN, proxy and Tor sign-ins as soon as the file is present. One rule still depends on the saved "Reject suspicious sign-ins" value: with `geoLookupFailureMode: 'auto'`, a sign-in whose location cannot be determined is rejected while that value is on, exactly as before. The Login protection tab says so; choose **Allow sign-in** under **If the location cannot be determined** to change it.
|
|
496
|
+
|
|
446
497
|
---
|
|
447
498
|
|
|
448
499
|
## Login protection
|
|
@@ -452,7 +503,7 @@ Configuration › Login protection checks **new sign-ins only**. Existing sessio
|
|
|
452
503
|
| Rule | Response | Notes |
|
|
453
504
|
| ----------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
454
505
|
| 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. |
|
|
455
|
-
| Reject suspicious sign-ins | 403 | VPN, proxy or
|
|
506
|
+
| Reject suspicious sign-ins | 403 | VPN, proxy or Tor address, or, with security scoring on, a score below 50. Needs a [risk data source](#risk-data-vpn-proxy-tor); without one this rule refuses nothing. |
|
|
456
507
|
| Country rules | 403 | Allow only listed countries, or reject listed countries. With "Allow only listed countries", an empty list allows every country. |
|
|
457
508
|
| Location cannot be determined | 403 "Login temporarily unavailable" | When `geoLookupFailureMode` says reject (`auto` rejects only when "Reject suspicious sign-ins" is on). |
|
|
458
509
|
|
|
@@ -464,8 +515,8 @@ Requests with an ended session get **401** with the header `X-Session-Terminated
|
|
|
464
515
|
|
|
465
516
|
Configuration › Alerts. Both kinds are sent only when location data is available for the sign-in.
|
|
466
517
|
|
|
467
|
-
- **Security emails to users** go to the end user's own email address, not to administrators: suspicious sign-in, sign-in from a new country (differs from the user's last 50 sessions), VPN or proxy. They use Strapi's Email plugin, so configure an email provider first (for example `@strapi/provider-email-nodemailer`).
|
|
468
|
-
- **Team notifications** post every sign-in to Discord or Slack as `login.suspicious`, otherwise `login.new_location`, otherwise `login.success`. Only `https://discord.com`, `https://discordapp.com` and `https://hooks.slack.com` URLs are accepted; Save rejects any other URL with a field error, and an empty field clears the URL.
|
|
518
|
+
- **Security emails to users** go to the end user's own email address, not to administrators: suspicious sign-in, sign-in from a new country (differs from the user's last 50 sessions), VPN or proxy. Suspicious sign-in and VPN or proxy need a [risk data source](#risk-data-vpn-proxy-tor); the new-country email needs location data only. They use Strapi's Email plugin, so configure an email provider first (for example `@strapi/provider-email-nodemailer`).
|
|
519
|
+
- **Team notifications** post every sign-in to Discord or Slack as `login.suspicious`, otherwise `login.new_location`, otherwise `login.success`. Without a [risk data source](#risk-data-vpn-proxy-tor), `login.suspicious` is never sent. Only `https://discord.com`, `https://discordapp.com` and `https://hooks.slack.com` URLs are accepted; Save rejects any other URL with a field error, and an empty field clears the URL.
|
|
469
520
|
|
|
470
521
|
Example email provider configuration:
|
|
471
522
|
|
|
@@ -633,37 +684,42 @@ Prefix `/magic-sessionmanager` (Strapi admin API). Every route requires an authe
|
|
|
633
684
|
|
|
634
685
|
The **Admin panel sessions** routes need two more permissions, which only the Super Admin role has by default (Settings › Administration Panel › Roles › Plugins › Session Manager › Admin panel):
|
|
635
686
|
|
|
636
|
-
| Permission | Name in the role editor | Allows
|
|
637
|
-
| ---------------------------------------------------- | ------------------------- |
|
|
638
|
-
| `plugin::magic-sessionmanager.admin-sessions.read` | Read admin panel sessions | The Admin panel view and its two GET routes
|
|
639
|
-
| `plugin::magic-sessionmanager.admin-sessions.revoke` | Sign out admins | **Sign out** and **Sign out everywhere** (also needs read)
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
|
643
|
-
|
|
|
644
|
-
| GET | `/sessions
|
|
645
|
-
| GET | `/sessions/
|
|
646
|
-
| GET | `/sessions/
|
|
647
|
-
|
|
|
648
|
-
|
|
|
649
|
-
| GET | `/sessions/
|
|
650
|
-
| GET | `/
|
|
651
|
-
|
|
|
652
|
-
|
|
|
653
|
-
|
|
|
654
|
-
| POST | `/
|
|
655
|
-
| POST | `/user/:userId/
|
|
656
|
-
|
|
|
657
|
-
| GET | `/
|
|
658
|
-
| GET | `/
|
|
659
|
-
|
|
|
660
|
-
|
|
|
661
|
-
|
|
|
662
|
-
|
|
|
663
|
-
|
|
|
664
|
-
| GET | `/admin-sessions/admins
|
|
665
|
-
|
|
|
666
|
-
| POST | `/admin-sessions/admins/:adminId/sign-out
|
|
687
|
+
| Permission | Name in the role editor | Allows |
|
|
688
|
+
| ---------------------------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
689
|
+
| `plugin::magic-sessionmanager.admin-sessions.read` | Read admin panel sessions | The Admin panel view and its two GET routes |
|
|
690
|
+
| `plugin::magic-sessionmanager.admin-sessions.revoke` | Sign out admins | **Sign out** and **Sign out everywhere** (also needs read) |
|
|
691
|
+
| `plugin::magic-sessionmanager.admin-activity.read` | View admin activity | Sign-in history, Activity, Recent sign-in activity, CSV exports and changing the Admin activity settings (also needs read) |
|
|
692
|
+
|
|
693
|
+
| Method | Path | Admin UI action |
|
|
694
|
+
| -------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
695
|
+
| GET | `/sessions` | Sessions dashboard: `?page=&pageSize=` (1-100), `status`, `reason`, `search`, `sort`; see below |
|
|
696
|
+
| GET | `/sessions/active` | Active sessions only; same paging parameters |
|
|
697
|
+
| GET | `/sessions/stats` | Dashboard cards and widget: counts only, cached 5 seconds per process |
|
|
698
|
+
| GET | `/sessions/native-only/summary` | **Why?** on the untracked-session notice: counts only, no query parameters (400 otherwise) |
|
|
699
|
+
| POST | `/sessions/native-only/end` | **End these sessions**: empty body; signed-in administrators only (admin API tokens get 403); 5 per minute |
|
|
700
|
+
| GET | `/sessions/analytics` | Analytics page: counts and grouped counts over every session, cached 30 seconds |
|
|
701
|
+
| GET | `/sessions/export` | Export batches of up to 1,000 rows, newest first; follow `meta.nextCursor` |
|
|
702
|
+
| GET | `/user/:userId/sessions` | Sessions panel |
|
|
703
|
+
| POST | `/sessions/:sessionId/terminate` | **End session** (reason `manual`; in refresh mode the Strapi session is revoked first; the record stays) |
|
|
704
|
+
| DELETE | `/sessions/:sessionId` | **Delete record** (record removed, token stays revoked; an open session also ends) |
|
|
705
|
+
| POST | `/sessions/clean-inactive` | **Delete ended sessions** (all users; open and idle sessions are not affected; does not run the idle check) |
|
|
706
|
+
| POST | `/user/:userId/terminate-all` | **End all sessions** (reason `manual`) |
|
|
707
|
+
| POST | `/user/:userId/toggle-block` | **Block user** / **Unblock user** |
|
|
708
|
+
| GET | `/users/stats` | Widget totals (`totalUsers`, `blockedUsers`) |
|
|
709
|
+
| GET | `/geolocation/:ipAddress` | **Look up location** |
|
|
710
|
+
| GET | `/geoip/status` | GeoIP database status, plus `risk` (`available`, `source`, and per risk database `editionId`, `exists`, `usable`, `fromEnvironment`, `metadata`) |
|
|
711
|
+
| PUT | `/geoip/credentials` | Save or remove (`{ "clear": true }`) MaxMind credentials |
|
|
712
|
+
| POST | `/geoip/update` | Update database / Force download. Body `{ "force"?: boolean, "database"?: "location" \| "anonymous-ip" \| "asn" }` (default `location`; anything else is 400). A 401/403 from MaxMind answers 502 "MaxMind refused the download…" |
|
|
713
|
+
| GET, PUT | `/settings` | Configuration (PUT validates every field and returns `error.details.errors` on invalid input) |
|
|
714
|
+
| POST | `/sessions/:sessionId/simulate-timeout` | Development only; removed when `NODE_ENV` is `production` or `staging` |
|
|
715
|
+
| GET | `/admin-sessions/admins` | Admin panel view: `?page=&pageSize=` (1-100), `search` (up to 100 characters, name or email), `filter` (`all`, `signed-in`, `not-signed-in`); needs `admin-sessions.read` |
|
|
716
|
+
| GET | `/admin-sessions/admins/:adminId/sessions` | **View sessions**: one entry per signed-in browser; needs `admin-sessions.read` |
|
|
717
|
+
| POST | `/admin-sessions/admins/:adminId/sessions/:sessionId/sign-out` | **Sign out** one browser; needs `admin-sessions.revoke`; signed-in administrators only; 10 per minute |
|
|
718
|
+
| POST | `/admin-sessions/admins/:adminId/sign-out-everywhere` | **Sign out everywhere**; needs `admin-sessions.revoke`; signed-in administrators only; 10 per minute |
|
|
719
|
+
| GET | `/admin-activity/sign-ins` | **Sign-in history** and **Recent sign-in activity**: `adminId`, `event` (`all`, `succeeded`, `failed`, `signed-out`), `from`, `to` (ISO dates), `page`, `pageSize` (1-100); needs `admin-activity.read` |
|
|
720
|
+
| GET | `/admin-activity/sign-ins/export` | CSV export batches of 500 rows, newest first; same filters plus `cursor`; follow `meta.nextCursor` |
|
|
721
|
+
| GET | `/admin-activity/content` | **Activity**: `adminId`, `action` (`all`, `view`, `create`, `update`, `publish`, `unpublish`, `discard`, `delete`, `clone`), `contentType` (uid), `from`, `to`, `page`, `pageSize`; needs `admin-activity.read` |
|
|
722
|
+
| GET | `/admin-activity/content/export` | CSV export batches of 500 rows; same filters plus `cursor` |
|
|
667
723
|
|
|
668
724
|
**Session list parameters.** `page` (from 1), `pageSize` (1-100), `status` (`all`, `open`, `active`, `idle`, `ended`), `reason` (with `status=ended`: `logout`, `idle`, `expired`, `manual`, `blocked`, `unrecorded`), `search` (up to 100 characters; matches email, username, IP address, browser, operating system and device type) and `sort` (`loginTime:desc`, `loginTime:asc`, `lastActive:desc`, `lastActive:asc`). The response is `{ data, meta: { pagination: { page, pageSize, total, pageCount } } }` with exact totals. Unknown or out-of-range parameters return 400. Pages that start after the first 50,000 matching sessions return 400; narrow the filter or use the export, which walks every row with a cursor. Without `page` and `pageSize`, `GET /sessions` keeps the 4.x response (latest 1,000 rows, `meta.truncated`) for existing scripts.
|
|
669
725
|
|
|
@@ -681,6 +737,75 @@ Errors use Strapi's `{ data: null, error }` envelope: 400 for invalid input, 404
|
|
|
681
737
|
|
|
682
738
|
---
|
|
683
739
|
|
|
740
|
+
## Admin activity and sign-in history
|
|
741
|
+
|
|
742
|
+
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:
|
|
743
|
+
|
|
744
|
+
| Recorded | Events | Default |
|
|
745
|
+
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
746
|
+
| **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 |
|
|
747
|
+
| **Content Manager activity** | `admin.content.view` (opening an entry), `.create`, `.update`, `.publish`, `.unpublish`, `.discard`, `.delete`, `.clone`, with content type, document id, locale and title | **Off** |
|
|
748
|
+
|
|
749
|
+
**Who can see it.** The new permission **View admin activity** (`plugin::magic-sessionmanager.admin-activity.read`, together with `access` and `admin-sessions.read`). Only the Super Admin role has it until you grant it in Settings › Administration Panel › Roles › Plugins › Session Manager › Admin panel. The same permission is needed to change the settings below; other admins can still save the Configuration page, but not change these values (403).
|
|
750
|
+
|
|
751
|
+
### How events are captured (Strapi 5.63)
|
|
752
|
+
|
|
753
|
+
- **Sign-ins and failures** come from Strapi's own event hub events `admin.auth.success` and `admin.auth.error`, the events behind the documented `admin.auth.events.onConnectionSuccess` / `onConnectionError` callbacks ([Admin panel configuration](https://docs.strapi.io/cms/configurations/admin-panel)). They cover local and SSO sign-ins. For a failed attempt Strapi itself resolves the account; the plugin stores that admin id only when the typed email belongs to an existing admin, and never the typed email, the password or the request body.
|
|
754
|
+
- **Sign-outs** come from `admin.logout`; **"Sign out" / "Sign out everywhere"** in this plugin record `admin.session.revoked` with the acting admin and the target admin.
|
|
755
|
+
- **Lockouts** are Strapi's `admin::rateLimit` answering 429 on `POST /admin/login` (by default 5 attempts per 5 minutes per email and address, `admin.rateLimit`). Repeated 429s within 5 minutes are one event.
|
|
756
|
+
- **Registration and password reset** create a session without an event; a small server middleware records them as sign-ins.
|
|
757
|
+
- **Content Manager activity** is recorded by the same middleware after the Content Manager has answered: only successful calls of a signed-in admin to the entry routes (`collection-types` findOne, create, update, publish, unpublish, discard, delete, clone and bulk actions, and the single-type routes). List views, counts, relations and configuration calls are not activity. Opening the same entry (same admin, content type, document and locale) again within 10 minutes, or right after editing it, is one event.
|
|
758
|
+
- The request behind an event is read from Strapi's request context (`strapi.requestContext`), which is how the IP address and user agent reach the event hub listeners.
|
|
759
|
+
- Nothing is written on the request path. Events go to a bounded in-memory queue and are written in batches about once a second; GeoIP lookups also happen there. The settings are read when the batch is written, so a switched-off recording drops queued events.
|
|
760
|
+
|
|
761
|
+
### Client IP address and reverse proxies
|
|
762
|
+
|
|
763
|
+
The stored address is Strapi's client IP, `ctx.request.ip`. Koa takes it from the socket unless you trust your proxy; the plugin never reads `X-Forwarded-For` itself. Behind a reverse proxy or load balancer set, in `config/server.js`:
|
|
764
|
+
|
|
765
|
+
```js
|
|
766
|
+
module.exports = ({ env }) => ({
|
|
767
|
+
// ...
|
|
768
|
+
proxy: {
|
|
769
|
+
koa: true, // trust X-Forwarded-* from your proxy
|
|
770
|
+
maxIpsCount: 1, // number of proxies in front of Strapi (5.52+); 0 means unlimited and lets clients spoof
|
|
771
|
+
// ipHeader: 'CF-Connecting-IP', // only if your proxy sends another header (5.52+)
|
|
772
|
+
},
|
|
773
|
+
});
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
Without `proxy.koa` every event shows the proxy's address. The integration suite runs once without and once with a trusted proxy (`ADMIN_ACTIVITY_PROXY=1`) and checks both.
|
|
777
|
+
|
|
778
|
+
### Settings (Configuration › Admin activity)
|
|
779
|
+
|
|
780
|
+
| Setting | Key | Default | Notes |
|
|
781
|
+
| --------------------------------------- | -------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
782
|
+
| Record admin sign-ins | `adminSignInHistory` | On | Sign-ins, failures, lockouts, sign-outs, who signed out whom. |
|
|
783
|
+
| Record Content Manager activity | `adminContentActivity` | **Off** | Records how people work; read the notes below before you turn it on. |
|
|
784
|
+
| Store IP addresses | `securityLogStoreIp` | On | Applies to the whole security log. Location uses the IP location lookup under Location data (local MaxMind database or ipapi.co). |
|
|
785
|
+
| Anonymise the last part of IP addresses | `securityLogAnonymizeIp` | Off | Stores `203.0.113.0` instead of `203.0.113.42`; IPv6 keeps the first 48 bits. The location is looked up from the anonymised address. |
|
|
786
|
+
| Keep security events for | `securityLogRetentionDays` | 90 days | 1-730. A daily job (03:17 server time, one process per cluster) deletes older events. |
|
|
787
|
+
|
|
788
|
+
When an admin account is deleted, the plugin deletes the events of that admin (sign-ins, failures, activity). Where that admin had signed someone else out, the event stays with the other admin and only the actor reference is cleared. The same clean-up runs daily for accounts deleted while the plugin was not running.
|
|
789
|
+
|
|
790
|
+
### Legal notes (information, not legal advice)
|
|
791
|
+
|
|
792
|
+
These notes describe what the feature does so you can check it with your data protection officer; they are not legal advice.
|
|
793
|
+
|
|
794
|
+
- **GDPR.** Sign-in history with IP addresses is personal data of your admins. A typical basis is a legitimate interest in securing the admin panel (Art. 6(1)(f) GDPR) or, for employees, the national employment rules. Tell your admins about it in your privacy information (Art. 13), keep the retention as short as your security needs allow, and consider **Anonymise the last part of IP addresses**. An admin's events can be exported as CSV for an access request (Art. 15) and are deleted with the account.
|
|
795
|
+
- **Content Manager activity.** This records what each person works on and when. In Germany, a technical system that can monitor the behaviour or performance of employees is subject to the works council's co-determination (Section 87(1) no. 6 BetrVG), and comparable rules exist in other countries. That is why it is off by default; inform the people concerned and, where there is one, agree it with the works council before you turn it on. Check whether a data protection impact assessment (Art. 35 GDPR) is needed.
|
|
796
|
+
- **Third parties.** With the `auto` or `ipapi` location provider, IP addresses can be sent to ipapi.co. Use a local MaxMind database or turn off the IP location lookup to keep them on your server.
|
|
797
|
+
|
|
798
|
+
### Performance
|
|
799
|
+
|
|
800
|
+
Measured with `scripts/bench-admin-activity.cjs` (Strapi 5.63, SQLite, Node 22, Apple silicon, one process): 1,000 Content Manager requests per run (500 opens of 100 entries, 500 edits), three runs each, alternating.
|
|
801
|
+
|
|
802
|
+
| Content Manager activity | Mean | p50 | p95 | p99 | Events stored per run |
|
|
803
|
+
| ------------------------ | ------------ | ------------ | ------------ | ------------ | --------------------- |
|
|
804
|
+
| Off | 4.65-5.22 ms | 4.66-5.20 ms | 6.17-7.14 ms | 8.06-8.41 ms | 0 |
|
|
805
|
+
| On | 4.65-4.82 ms | 4.69-4.85 ms | 6.16-6.35 ms | 8.06-8.58 ms | 500-575 |
|
|
806
|
+
|
|
807
|
+
The difference is within the run-to-run noise: recording adds no measurable latency, because the request only pushes an object onto the queue.
|
|
808
|
+
|
|
684
809
|
## Running several instances (Railway replicas, pm2 cluster)
|
|
685
810
|
|
|
686
811
|
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.
|
|
@@ -848,6 +973,7 @@ The plugin sits in the request path of every authenticated Content API call, so
|
|
|
848
973
|
| Admin lists | Only the visible page (25-100 rows) is loaded and enriched. Counts for the cards and the widget are cached 5 seconds per process, Analytics 30 seconds. `GET /my-sessions` returns at most 200. |
|
|
849
974
|
| Idle cleanup | Runs on one process per interval (job lease). In `legacy-support` mode, `cleanupUseDbDirect: true` ends idle sessions with a single SQL update instead of one Document Service call per session. |
|
|
850
975
|
| Old history | Retention deletes ended sessions older than `retentionDays` (90 by default) once a day, so the table does not grow without bound. |
|
|
976
|
+
| Security log | Events are queued in memory and written in batches about once a second; nothing on the request path waits for the database or a GeoIP lookup. Indexes on actor, target, event and time; a daily job deletes events older than the retention. |
|
|
851
977
|
|
|
852
978
|
---
|
|
853
979
|
|
|
@@ -866,7 +992,8 @@ The plugin sits in the request path of every authenticated Content API call, so
|
|
|
866
992
|
- **What leaves your server.** Only what you turn on: IP lookups at ipapi.co (provider `auto` without a local database, or `ipapi`), Discord or Slack webhooks (Team notifications), emails through your own Email provider (Security emails) and the MaxMind database download when you click **Update database** or run the updater. There is no telemetry, no install ping and no license check.
|
|
867
993
|
- **Reporting a vulnerability.** Please do not post exploit details in a public issue. Open an issue that asks for a private contact, or use the email address on the maintainer's GitHub profile, and you will get a reply before anything is published.
|
|
868
994
|
- **Secrets.** MaxMind license keys are never returned to the browser. Webhook URLs grant posting rights to your channel; treat them as secrets. Exports never contain tokens.
|
|
869
|
-
- **Admin panel sessions.** The Admin panel view reads Strapi's own `admin::session` records (origin `admin`)
|
|
995
|
+
- **Admin panel sessions.** The Admin panel view reads Strapi's own `admin::session` records (origin `admin`). Only Super Admin can see or sign out admins until another role is granted `admin-sessions.read` / `admin-sessions.revoke`; a delegated role cannot sign out a Super Admin. Sign-outs need a signed-in administrator (not an admin API token), are rate limited and logged with admin ids and counts only.
|
|
996
|
+
- **Admin activity and sign-in history.** The plugin's security log stores admin sign-ins with IP address and user agent (on by default; IP anonymisation and retention configurable) and, only when you turn it on, Content Manager activity. Only Super Admin sees it until another role gets `admin-activity.read`. Typed emails of failed sign-ins, passwords and request bodies are never stored. Details and legal notes: [Admin activity and sign-in history](#admin-activity-and-sign-in-history).
|
|
870
997
|
|
|
871
998
|
---
|
|
872
999
|
|
|
@@ -921,6 +1048,10 @@ Session history lives in the content-type tables `magic_sessions` and `magic_ses
|
|
|
921
1048
|
|
|
922
1049
|
## Migration and upgrading
|
|
923
1050
|
|
|
1051
|
+
### To the release with the security log (from 4.14.x)
|
|
1052
|
+
|
|
1053
|
+
Nothing to do. On the first start Strapi creates the table `magic_sessions_security_events` with its indexes, and the plugin starts recording admin sign-ins (with IP addresses) right away; Content Manager activity stays off until you turn it on. Existing routes, responses and settings are unchanged; the new routes and the permission **View admin activity** are additions, and only Super Admin has the permission at first. Behind a reverse proxy, check [Client IP address and reverse proxies](#client-ip-address-and-reverse-proxies) so the stored addresses are your users' and not your proxy's. To keep the previous behaviour (no sign-in history), turn off **Record admin sign-ins** in Configuration › Admin activity.
|
|
1054
|
+
|
|
924
1055
|
### Strapi older than 5.50
|
|
925
1056
|
|
|
926
1057
|
Earlier releases said "Strapi 5.0+" (`^5.0.0`) without testing older versions. The real floor is **Strapi 5.50.0**: the plugin calls `listSessions` and `revokeSessionById` on Strapi's session manager and reads the device label in `admin::session` metadata, which Strapi added in 5.50.0 ([strapi/strapi#26628](https://github.com/strapi/strapi/pull/26628)). Measured with this repository's real-HTTP suites:
|
|
@@ -7,7 +7,7 @@ import styled from "styled-components";
|
|
|
7
7
|
import { Typography, Flex, LinkButton, Button, EmptyStateLayout, VisuallyHidden } from "@strapi/design-system";
|
|
8
8
|
import { ArrowClockwise, ChartBubble, User, Clock, Calendar } from "@strapi/icons";
|
|
9
9
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
10
|
-
import { K as normalizeDeviceType, u as useSessionFormatters, l as pluginId, s as isCancelledRequest, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, w as PageShell, x as StatGrid, y as StatCard, G as EqualGrid, b as getTranslation, L as getDeviceTypeMessage } from "./index-
|
|
10
|
+
import { K as normalizeDeviceType, u as useSessionFormatters, l as pluginId, s as isCancelledRequest, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, w as PageShell, x as StatGrid, y as StatCard, G as EqualGrid, b as getTranslation, L as getDeviceTypeMessage } from "./index-DUESEUaO.mjs";
|
|
11
11
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
12
12
|
const ANALYTICS_UNKNOWN_KEY = "unknown";
|
|
13
13
|
const VERSION_TOKEN = /^v?\d[\w.]*$/i;
|
|
@@ -9,7 +9,7 @@ const styled = require("styled-components");
|
|
|
9
9
|
const designSystem = require("@strapi/design-system");
|
|
10
10
|
const icons = require("@strapi/icons");
|
|
11
11
|
const symbols = require("@strapi/icons/symbols");
|
|
12
|
-
const index = require("./index-
|
|
12
|
+
const index = require("./index-CgZiLcJ1.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);
|