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.
Files changed (30) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +216 -85
  3. package/dist/admin/{Analytics-CFEgpg-G.mjs → Analytics-D4gsVwL0.mjs} +1 -1
  4. package/dist/admin/{Analytics-DSpn7W5A.js → Analytics-me4qzS0I.js} +1 -1
  5. package/dist/admin/{App-BBne8xI6.mjs → App-BJwtFWxl.mjs} +921 -106
  6. package/dist/admin/{App-UlRrLKcx.js → App-BTG-2Q26.js} +920 -105
  7. package/dist/admin/{OnlineUsersWidget-GFcYyZ9L.js → OnlineUsersWidget-DYS3Vy1Q.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-C3YMTEGD.mjs → OnlineUsersWidget-Yd283YDy.mjs} +1 -1
  9. package/dist/admin/{Settings-BbUNvjno.mjs → Settings-DIlvfdjZ.mjs} +427 -83
  10. package/dist/admin/{Settings-DVhW9XHB.js → Settings-TPZ9_75s.js} +425 -81
  11. package/dist/admin/{de-B0CBR1Dw.js → de-BuMw1gBJ.js} +130 -8
  12. package/dist/admin/{de-BlKn1pSD.mjs → de-DB9ldYwN.mjs} +130 -8
  13. package/dist/admin/{en-IT0YTY8f.mjs → en-BbLMPQB3.mjs} +130 -8
  14. package/dist/admin/{en-D0ZGIIjz.js → en-BqGhOJDy.js} +130 -8
  15. package/dist/admin/{es-CWee-XCR.js → es-BaIeckl9.js} +130 -8
  16. package/dist/admin/{es-BCGzaaCh.mjs → es-C5iaiE9G.mjs} +130 -8
  17. package/dist/admin/{fr-xBIH4Byq.mjs → fr-BEvBUCwI.mjs} +130 -8
  18. package/dist/admin/{fr-rQS1M7jE.js → fr-D1YKyTex.js} +130 -8
  19. package/dist/admin/{index-1KmiZSfy.js → index-CgZiLcJ1.js} +13 -10
  20. package/dist/admin/{index-MOJkFXcZ.mjs → index-DUESEUaO.mjs} +13 -10
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/{pt-DWDeIDVa.mjs → pt-DeDih9cR.mjs} +130 -8
  24. package/dist/admin/{pt-C-yTLhnS.js → pt-DtnW-s0V.js} +130 -8
  25. package/dist/admin/riskData-BVs9GpgD.js +26 -0
  26. package/dist/admin/riskData-CI1gm2yI.mjs +27 -0
  27. package/dist/server/index.js +2500 -299
  28. package/dist/server/index.mjs +2500 -299
  29. package/package.json +1 -1
  30. package/scripts/geoip-updater.cjs +58 -15
package/CHANGELOG.md CHANGED
@@ -1,3 +1,90 @@
1
+ # [4.16.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.15.0...v4.16.0) (2026-11-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * admin sign-in history with IP, Content Manager activity and a security event log ([#34](https://github.com/Schero94/Magic-Sessionmanager/issues/34)) ([ca53128](https://github.com/Schero94/Magic-Sessionmanager/commit/ca53128efb31b9293d9c45ddcb03ac041242ca56))
7
+
8
+
9
+ Release type: minor (`feat`). Additive: a new content type, four new GET routes, one new permission and new settings keys; no existing route, response or setting changes.
10
+
11
+ ### Added
12
+
13
+ * **Security log** (`plugin::magic-sessionmanager.security-event`, table `magic_sessions_security_events`, hidden from the Content Manager and the Content-Type Builder). One row per event with `actorType`/`actorId`, `targetType`/`targetId`, `event`, `ip`, `userAgent`, `geo`, a bounded `meta` (at most 16 plain values, 2 KB) and `createdAt`, indexed on actor, target, event and time. Event names are an extendable registry (`admin.sign-in`, `admin.sign-in.failed`, `admin.lockout`, `admin.sign-out`, `admin.session.revoked`, `admin.content.*`), so later app-user events can use the same log.
14
+ * **Admin sign-in history** (on by default): every admin sign-in (local and SSO, from Strapi's `admin.auth.success` event), failed attempt with Strapi's reason (`admin.auth.error`; linked to an admin only when the typed email belongs to one, the typed email itself is never stored), lockout (Strapi's login rate limit, 429), sign-out (`admin.logout`), first sign-in after registration and after a password reset, and every **Sign out** / **Sign out everywhere** in this plugin with the admin who did it. Stored with IP address (`ctx.request.ip`), user agent and, when IP location lookup is on, country and city.
15
+ * **Content Manager activity** (off by default): which entries each admin opened, created, edited, published, unpublished, discarded, duplicated or deleted, with content type, document id, locale and title. Opening the same entry again within 10 minutes is one event; list views and polling are not recorded.
16
+ * **Admin panel view:** the admin details dialog has the tabs **Sessions**, **Sign-in history** and **Activity**, with filters (event or action, content type, period), **Show more** and **Export CSV**. A **Recent sign-in activity** card under the table lists the latest five events of all admins. Shown to roles with the new permission **View admin activity** (`plugin::magic-sessionmanager.admin-activity.read`); only Super Admin has it at first.
17
+ * **Configuration › Admin activity** (with the same permission): 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 (IPv4 /24, IPv6 /48) and Keep security events for (1-730 days, default 90). IP storage, anonymisation and retention apply to the whole log.
18
+ * Admin routes `GET /admin-activity/sign-ins`, `/admin-activity/sign-ins/export`, `/admin-activity/content`, `/admin-activity/content/export` (need `access`, `admin-sessions.read` and `admin-activity.read`; read rate limit). `GET /admin-sessions/admins` adds `meta.recording`.
19
+ * A daily retention job (`strapi.cron`, one process per cluster) deletes older events; deleting an admin account deletes that admin's events.
20
+ * README: how events are captured, the reverse-proxy setup for correct client IPs (`server.proxy.koa`, `maxIpsCount`, `ipHeader`), the privacy defaults and legal notes (GDPR, German works council; information, not legal advice), and a latency bench (`scripts/bench-admin-activity.cjs`): no measurable difference with recording on.
21
+
22
+ ### Changed
23
+
24
+ * The "How signing out works" note no longer says that admin sessions record no IP address; it says what the sign-in history records with the current settings.
25
+
26
+ ### Fixed
27
+
28
+ * Enter and Space on the row buttons of the Admin panel table (View sessions, Sign out everywhere) did nothing: the Design System grid table handled the keys. They now open the dialog and the confirmation, as in the App users table.
29
+ * A settings load that started before a settings change could cache the old values in that process until the next revision check (up to 2 seconds).
30
+
31
+ ### Migration
32
+
33
+ * Nothing to do. Strapi creates the new table and indexes on the first start. Admin sign-ins are recorded from then on (with IP addresses); to keep the previous behaviour, turn off **Record admin sign-ins** in Configuration › Admin activity. Behind a reverse proxy set `server.proxy.koa: true` and `maxIpsCount`, otherwise the proxy's address is stored.
34
+
35
+ ### Tests
36
+
37
+ * `tests/isolated-admin-activity-http.test.js` boots Strapi from this checkout and covers sign-in, failed sign-in, lockout, sign-out and sign-out by another admin, session states, IP with and without a trusted proxy (`ADMIN_ACTIVITY_PROXY=1`), view de-duplication, every write action, RBAC (401/403/200), settings permission and validation, anonymisation, switches off, retention and deletion with the admin. CI runs it in both proxy modes and on the Strapi 5.50 floor.
38
+ * Unit tests for the event model, the queue and flush, IP anonymisation, bounded meta and the settings cache race; StrictMode tests for the new dialog tabs, recent list and settings tab; a keyboard test for the table row buttons.
39
+
40
+ # [4.15.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.14.3...v4.15.0) (2026-11-24)
41
+
42
+
43
+ ### Features
44
+
45
+ * honest risk data and VPN, proxy, Tor and hosting detection with local MaxMind databases ([#33](https://github.com/Schero94/Magic-Sessionmanager/issues/33)) ([80e1e7e](https://github.com/Schero94/Magic-Sessionmanager/commit/80e1e7e988f048b4716dfd0dc8487cef4cec37cd))
46
+
47
+
48
+ Release type: minor (`feat` for the new risk data source, `fix` for the honest UI). No breaking change for the HTTP API or stored settings; see the upgrade note for `securityScore: null`.
49
+
50
+ ### Added
51
+
52
+ * **Real risk data from a local MaxMind database.** Configuration › Location data › **Risk data (VPN, proxy, Tor)** downloads, with the existing MaxMind credentials, either the **GeoIP2 Anonymous IP** database (paid: VPN, public and residential proxies, Tor exit nodes, hosting providers) or the free **GeoLite2 ASN** database, used as a clearly labelled **heuristic** for large hosting and cloud networks only. Lookups are local through the installed `@maxmind/geoip2-node` (`anonymousIP()`, `asn()`); no IP address leaves the server and the license key never reaches the browser.
53
+ * With a risk source, "Reject suspicious sign-ins" refuses Tor exit nodes (`tor_exit_node`), VPNs and proxies, and scores below 50; hosting networks raise the suspicious-sign-in email and `login.suspicious` but are never refused. The VPN or proxy email fires for VPNs and proxies. Risk data is evaluated even when the location lookup itself failed.
54
+ * Lookup results add `isTor`, `isHosting`, `isAnonymous`, `isPublicProxy`, `isResidentialProxy` and `riskSource`; the existing names (`isVpn`, `isProxy`, `isThreat`, `securityScore`, `riskLevel`) keep their meaning. With the ASN database, `asn` and `org` are filled when the location provider gave none.
55
+ * `GET /magic-sessionmanager/geoip/status` reports `risk` (`available`, `source`, and per database `editionId`, `exists`, `usable`, `fromEnvironment`, `metadata`). `POST /magic-sessionmanager/geoip/update` accepts `database: 'location' | 'anonymous-ip' | 'asn'` (default `location`, anything else 400). A 401 or 403 from MaxMind answers 502 with "MaxMind refused the download. Check the credentials and that your account includes this database."
56
+ * The CLI updater accepts `MAXMIND_EDITION_ID=GeoIP2-Anonymous-IP` and `GeoLite2-ASN`; risk databases always go to their own file in `data/magic-sessionmanager/geoip/` and cannot be selected as the location database. New environment variables `MAGIC_SESSIONMANAGER_ANONYMOUS_IP_DATABASE` and `MAGIC_SESSIONMANAGER_ASN_DATABASE` point at existing files instead.
57
+ * Session details show "Hosting network" for live lookups, "Not available" for VPN and proxy when only the ASN heuristic answered, and a note on heuristic scores.
58
+ * MaxMind database readers watch their file without keeping the Node.js process alive.
59
+
60
+ ### Fixed
61
+
62
+ * **Suspicious sign-in detection was never active, and the admin and README said it was.** The plugin read VPN, proxy and threat flags from a `threat` object that ipapi.co does not send ([ipapi.co API](https://ipapi.co/api/) documents no such field), and it scored every local GeoLite2 result 100. So every flag was `false` and every score 100: "Reject suspicious sign-ins", the suspicious-sign-in email, the VPN or proxy email and the `login.suspicious` team notification could never fire. The dead parsing is removed. ipapi.co and GeoLite2 still provide location data; they no longer pretend to provide risk data.
63
+ * Without a risk data source, lookups report no risk data: the flags stay `false` (same field names), `securityScore` is `null` instead of a fake 100 (or 50 for failed and disabled lookups), `riskLevel` is `'Unknown'` and the new field `riskSource` is `null`. New sessions store `securityScore: null`; a session's `geoLocation` stores `riskSource` when risk data existed.
64
+ * Risk rules and alerts run only on results with a `riskSource`. Flags without one never refuse a sign-in, never send the suspicious-sign-in or VPN or proxy email, and never turn a team notification into `login.suspicious`.
65
+ * **Admin, Configuration:** while no risk data source is set up, "Reject suspicious sign-ins", "Security scoring" and the email types "Suspicious sign-in" and "VPN or proxy" are shown off and disabled with "Needs a risk data source" and a link to Location data. Login protection shows a "No risk data source" notice; Alerts says that `login.suspicious` is never sent. The hints no longer claim ipapi.co detects VPNs or that local results score 100.
66
+ * **Admin, Session details:** without risk data, one "Not available" row with "Set up risk data" replaces the security score, VPN and proxy rows. Sessions recorded before this release show "Not available", because their stored 100 was never a real check.
67
+ * Discord and Slack messages list risk findings only when the sign-in had risk data, and now also name Tor and hosting networks. The `{{reason.securityScore}}` email variable renders `N/A` instead of `0` when there is no score.
68
+ * README: the features table, Session details, the settings table, Location data, Login protection and Alerts describe what needs a risk data source; a new "Risk data (VPN, proxy, Tor)" section explains the previous behaviour.
69
+
70
+ * **A custom "Database file name" was never found.** The reader resolved `geoIpDatabasePath` (for example `GeoLite2-Country.mmdb`) against the Strapi folder, while the admin and CLI downloads write it to `data/magic-sessionmanager/geoip/`. A file name is now read from that folder first; a file in the Strapi folder is still found for older setups, and absolute paths are unchanged. The settings API keeps refusing `..` and folder names with a field error on `geoIpDatabasePath`.
71
+
72
+ ### Upgrade note
73
+
74
+ * Saved settings are kept as they are. A risk switch that was on stays stored, has no effect while no risk data source exists, and applies again once one is set up. The admin says "Saved as on. It takes effect once a risk data source is set up."
75
+ * Nothing changes until you add a risk database. **Check your switches before you download one:** a "Reject suspicious sign-ins" saved as on starts refusing VPN, proxy and Tor sign-ins as soon as the database is present, and the suspicious-sign-in and VPN or proxy emails (on by default once "Send security emails" is on) start to be sent.
76
+ * One rule keeps its previous behaviour: with `geoLookupFailureMode: 'auto'` and "Reject suspicious sign-ins" saved as on, a sign-in whose location cannot be determined is still rejected. Choose **Allow sign-in** under Login protection › Advanced › "If the location cannot be determined" to change that.
77
+ * Code that reads `securityScore` must accept `null`. Code that relied on `securityScore: 100` for local results, or on `isVpn`/`isProxy` from ipapi.co, never received real data; check `riskSource` instead.
78
+ * Stored sessions are not rewritten. Their old scores of 100 stay in the database; the admin ignores them because they carry no `riskSource`.
79
+
80
+ ### Tests
81
+
82
+ * `tests/geolocation-database-path.test.js` (regression, fails before the fix): a custom file name is read from the GeoIP folder, the Strapi-folder fallback and absolute paths still work, a missing file is reported for the GeoIP folder, and `..` or folder names are refused with a `geoIpDatabasePath` field error.
83
+ * `tests/risk-databases.test.js` reads synthetic MMDB fixtures (written by `tests/helpers/mmdb-writer.js`; no MaxMind data is shipped) with the real `@maxmind/geoip2-node` reader: VPN, Tor, hosting, public and residential proxy and a clean address; the ASN heuristic; both databases; a wrong database type; the status report; and full sign-ins where the reject rule, the VPN and suspicious emails (through the real notification service) and the `login.suspicious` Discord post actually fire. Also the download routing, the fixed refusal message and that a location setting cannot select a risk file.
84
+ * `tests/risk-honesty.test.js`: ipapi.co answers (even with a made-up `threat` object), failed and private lookups carry no score; without a source nothing is suspicious, no risk email or `login.suspicious` webhook is sent, and the new-country alert still works.
85
+ * `tests/admin/risk-honesty.test.jsx` renders the Configuration page and the session details: without a source the risk controls are off, disabled and explained, saved values are kept and nothing is saved; with a source they are live.
86
+ * `tests/geo-firewall.test.js`: flags without a source refuse nothing; the saved reject switch keeps the Automatic fail-closed rule.
87
+
1
88
  ## [4.14.3](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.14.2...v4.14.3) (2026-11-24)
2
89
 
3
90