strapi-plugin-magic-sessionmanager 4.15.0 → 4.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +112 -14
  3. package/dist/admin/{Analytics-Dbs5QXLb.js → Analytics-CMR62DiD.js} +1 -1
  4. package/dist/admin/{Analytics-HK6_TEmk.mjs → Analytics-FcRt0X62.mjs} +1 -1
  5. package/dist/admin/{App-7SxOBJP5.js → App-CmytGbze.js} +935 -88
  6. package/dist/admin/{App-BOFzZ5d8.mjs → App-DBieSWB0.mjs} +936 -89
  7. package/dist/admin/{OnlineUsersWidget-Dns_74xJ.js → OnlineUsersWidget-Lzx9XB74.js} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-CoCxnww-.mjs → OnlineUsersWidget-zP9Hl_it.mjs} +1 -1
  9. package/dist/admin/{Settings-B6CrR-07.js → Settings-1v--SXC0.js} +350 -68
  10. package/dist/admin/{Settings-DYRShQ8W.mjs → Settings-CZOPusQK.mjs} +351 -69
  11. package/dist/admin/{de-B3mPtxsW.mjs → de-D3TSA066.mjs} +106 -2
  12. package/dist/admin/{de-bkkCvSxX.js → de-y_9mdVT7.js} +106 -2
  13. package/dist/admin/{en-BnU8BNkN.mjs → en-B60I97bK.mjs} +106 -2
  14. package/dist/admin/{en-DMICyIow.js → en-CIQB8nfI.js} +106 -2
  15. package/dist/admin/{es-BxMgfJ1Y.mjs → es-CJEL_iGC.mjs} +106 -2
  16. package/dist/admin/{es-OSzHGRIu.js → es-DHhHzlRY.js} +106 -2
  17. package/dist/admin/{fr-WPrbtx8k.mjs → fr-BfBK_iuV.mjs} +106 -2
  18. package/dist/admin/{fr-Bu_8miJ4.js → fr-D86FTt1w.js} +106 -2
  19. package/dist/admin/{index-CNSJITRX.js → index-CSJJn4qy.js} +18 -10
  20. package/dist/admin/{index-lnZBc5n0.mjs → index-tt61o2VH.mjs} +18 -10
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/{pt-B08xnb0K.js → pt-BE-FT-L8.js} +106 -2
  24. package/dist/admin/{pt-C41KyEDN.mjs → pt-C3PSvC7z.mjs} +106 -2
  25. package/dist/server/index.js +3114 -457
  26. package/dist/server/index.mjs +3114 -457
  27. package/package.json +1 -1
@@ -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-CNSJITRX.js");
10
+ const index = require("./index-CSJJn4qy.js");
11
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule) return e;
@@ -6,7 +6,7 @@ import { Flex, Loader, Button, Box, Typography } from "@strapi/design-system";
6
6
  import { User, Lightning, Clock, Lock, WarningCircle } from "@strapi/icons";
7
7
  import * as StrapiAdmin from "@strapi/strapi/admin";
8
8
  import { useFetchClient } from "@strapi/strapi/admin";
9
- import { m as logSafeAdminError, s as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-lnZBc5n0.mjs";
9
+ import { m as logSafeAdminError, s as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-tt61o2VH.mjs";
10
10
  function normalizeUserCounts(response) {
11
11
  const totalUsers = response?.data?.totalUsers;
12
12
  const blockedUsers = response?.data?.blockedUsers;
@@ -6,7 +6,7 @@ const designSystem = require("@strapi/design-system");
6
6
  const StrapiAdmin = require("@strapi/strapi/admin");
7
7
  const icons = require("@strapi/icons");
8
8
  const styled = require("styled-components");
9
- const index = require("./index-CNSJITRX.js");
9
+ const index = require("./index-CSJJn4qy.js");
10
10
  const reactIntl = require("react-intl");
11
11
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
12
12
  const riskData = require("./riskData-BVs9GpgD.js");
@@ -17,15 +17,18 @@ const SETTINGS_TAB_IDS = Object.freeze([
17
17
  "login-protection",
18
18
  "location-data",
19
19
  "alerts",
20
- "data-retention"
20
+ "data-retention",
21
+ "admin-activity"
21
22
  ]);
23
+ const PERMISSION_GATED_TABS = Object.freeze(["admin-activity"]);
22
24
  const DEFAULT_SETTINGS_TAB = "sessions";
23
25
  const SETTINGS_TAB_LABELS = Object.freeze({
24
26
  sessions: ["settings.config.tab.sessions", "Sessions"],
25
27
  "login-protection": ["settings.config.tab.loginProtection", "Login protection"],
26
28
  "location-data": ["settings.config.tab.locationData", "Location data"],
27
29
  alerts: ["settings.config.tab.alerts", "Alerts"],
28
- "data-retention": ["settings.config.tab.dataRetention", "Data and retention"]
30
+ "data-retention": ["settings.config.tab.dataRetention", "Data and retention"],
31
+ "admin-activity": ["settings.config.tab.adminActivity", "Admin activity"]
29
32
  });
30
33
  const SETTINGS_TAB_FIELDS = Object.freeze({
31
34
  sessions: [
@@ -62,7 +65,15 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
62
65
  "discordWebhookUrl",
63
66
  "slackWebhookUrl"
64
67
  ],
65
- "data-retention": ["retentionDays"]
68
+ "data-retention": ["retentionDays"],
69
+ "admin-activity": [
70
+ "adminSignInHistory",
71
+ "adminContentActivity",
72
+ "securityLogStoreIp",
73
+ "securityLogAnonymizeIp",
74
+ "securityLogGeoLookup",
75
+ "securityLogRetentionDays"
76
+ ]
66
77
  });
67
78
  const PRESERVED_SETTINGS_KEYS = Object.freeze([
68
79
  "rateLimitWriteMax",
@@ -105,7 +116,25 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
105
116
  enableWebhooks: ["settings.config.webhooks.enable.label", "Send team notifications"],
106
117
  discordWebhookUrl: ["settings.config.webhooks.discord.label", "Discord webhook URL"],
107
118
  slackWebhookUrl: ["settings.config.webhooks.slack.label", "Slack webhook URL"],
108
- retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"]
119
+ retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"],
120
+ adminSignInHistory: ["settings.config.adminActivity.signIns.label", "Record admin sign-ins"],
121
+ adminContentActivity: [
122
+ "settings.config.adminActivity.content.label",
123
+ "Record Content Manager activity"
124
+ ],
125
+ securityLogStoreIp: ["settings.config.adminActivity.storeIp.label", "Store IP addresses"],
126
+ securityLogAnonymizeIp: [
127
+ "settings.config.adminActivity.anonymize.label",
128
+ "Anonymise the last part of IP addresses"
129
+ ],
130
+ securityLogGeoLookup: [
131
+ "settings.config.adminActivity.geoLookup.label",
132
+ "Look up the location of security events"
133
+ ],
134
+ securityLogRetentionDays: [
135
+ "settings.config.adminActivity.retention.label",
136
+ "Keep security events for"
137
+ ]
109
138
  });
110
139
  const SELECT_PRESETS = Object.freeze({
111
140
  inactivityTimeout: Object.freeze([5, 10, 15, 30, 60, 120]),
@@ -113,11 +142,17 @@ const SELECT_PRESETS = Object.freeze({
113
142
  lastSeenRateLimit: Object.freeze([10, 30, 60, 120, 300]),
114
143
  cleanupInterval: Object.freeze([15, 30, 60, 120]),
115
144
  sessionCreationGraceMs: Object.freeze([0, 2e3, 5e3, 1e4, 3e4]),
116
- retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1])
145
+ retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1]),
146
+ securityLogRetentionDays: Object.freeze([7, 30, 90, 180, 365])
117
147
  });
118
- function resolveSettingsTab(value) {
148
+ function resolveSettingsTab(value, tabs = SETTINGS_TAB_IDS) {
119
149
  const candidate = Array.isArray(value) ? value[0] : value;
120
- return SETTINGS_TAB_IDS.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
150
+ return tabs.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
151
+ }
152
+ function getVisibleSettingsTabs(canViewAdminActivity) {
153
+ return SETTINGS_TAB_IDS.filter(
154
+ (tab) => canViewAdminActivity || !PERMISSION_GATED_TABS.includes(tab)
155
+ );
121
156
  }
122
157
  function buildTabSearch(search, tab) {
123
158
  const params = new URLSearchParams(typeof search === "string" ? search : "");
@@ -590,6 +625,13 @@ function useOptionLabels() {
590
625
  }
591
626
  const IntroText = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral600", tag: "p", children });
592
627
  const RequiresNotice = ({ tab, children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", "data-requires": "", children: tab ? /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLink, { tab, children }) : children });
628
+ const ProtectedNotice = () => {
629
+ const { t } = useSettingsTranslate();
630
+ return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t(
631
+ "settings.config.protected.notice",
632
+ "Read-only for your role: changing this needs the “Change protected settings” permission."
633
+ ) });
634
+ };
593
635
  const RequiresGeolocation = () => {
594
636
  const { t } = useSettingsTranslate();
595
637
  return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
@@ -1372,15 +1414,27 @@ const SETTINGS_DEFAULTS = Object.freeze({
1372
1414
  alertOnNewLocation: true,
1373
1415
  alertOnVpnProxy: true,
1374
1416
  enableWebhooks: false,
1375
- discordWebhookUrl: "",
1376
- slackWebhookUrl: "",
1417
+ // Webhook URLs are never returned (4.17): the API sends hasDiscordWebhook /
1418
+ // hasSlackWebhook and a hint; a URL key exists in the draft only while the
1419
+ // admin replaces (text) or removes ('') it.
1420
+ hasDiscordWebhook: false,
1421
+ hasSlackWebhook: false,
1422
+ discordWebhookHint: null,
1423
+ slackWebhookHint: null,
1377
1424
  enableGeofencing: false,
1378
1425
  allowedCountries: [],
1379
1426
  blockedCountries: [],
1380
1427
  geoIpProvider: "auto",
1381
1428
  geoIpDatabasePath: "",
1382
- geoLookupFailureMode: "auto"
1429
+ geoLookupFailureMode: "auto",
1430
+ adminSignInHistory: true,
1431
+ adminContentActivity: false,
1432
+ securityLogStoreIp: true,
1433
+ securityLogAnonymizeIp: false,
1434
+ securityLogGeoLookup: false,
1435
+ securityLogRetentionDays: 90
1383
1436
  });
1437
+ const WRITE_ONLY_SETTINGS_KEYS = Object.freeze(["discordWebhookUrl", "slackWebhookUrl"]);
1384
1438
  const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
1385
1439
  const WEBHOOK_HOSTS = Object.freeze({
1386
1440
  discordWebhookUrl: ["discord.com", "discordapp.com"],
@@ -1490,7 +1544,7 @@ function validateSettings(settings) {
1490
1544
  function getAdjustedFields(submitted, stored, previous) {
1491
1545
  const source = submitted || {};
1492
1546
  return Object.keys(source).filter(
1493
- (key) => !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
1547
+ (key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
1494
1548
  );
1495
1549
  }
1496
1550
  const COUNTRIES = [
@@ -1894,6 +1948,7 @@ const LoginProtectionTab = ({ form }) => {
1894
1948
  const maxFailedError = tError(errors.maxFailedLogins);
1895
1949
  const maxFailedValue = Number(settings.maxFailedLogins);
1896
1950
  const lookupOff = !settings.enableGeolocation;
1951
+ const locked = form.canChangeProtected === false;
1897
1952
  const risk = riskData.getRiskAvailability(form.geoIp.status);
1898
1953
  const reject = riskData.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
1899
1954
  const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
@@ -2046,7 +2101,7 @@ const LoginProtectionTab = ({ form }) => {
2046
2101
  designSystem.SingleSelect,
2047
2102
  {
2048
2103
  value: settings.geoLookupFailureMode || "auto",
2049
- disabled: lookupOff,
2104
+ disabled: lookupOff || locked,
2050
2105
  onChange: (value) => handleChange("geoLookupFailureMode", value),
2051
2106
  children: [
2052
2107
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
@@ -2154,6 +2209,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2154
2209
  );
2155
2210
  };
2156
2211
  const lookupOff = !settings.enableGeolocation;
2212
+ const locked = form.canChangeProtected === false;
2157
2213
  const localDatabase = usesLocalDatabase(settings.geoIpProvider);
2158
2214
  const databaseDisabled = lookupOff || !localDatabase;
2159
2215
  const credentialSource = geoIpStatus?.credentialSource;
@@ -2191,7 +2247,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2191
2247
  designSystem.SingleSelect,
2192
2248
  {
2193
2249
  value: settings.geoIpProvider || "auto",
2194
- disabled: lookupOff,
2250
+ disabled: lookupOff || locked,
2195
2251
  onChange: (value) => handleChange("geoIpProvider", value),
2196
2252
  children: [
2197
2253
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.config.provider.auto", "Automatic") }),
@@ -2387,7 +2443,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2387
2443
  {
2388
2444
  name: "geoIpDatabasePath",
2389
2445
  value: settings.geoIpDatabasePath || "",
2390
- disabled: databaseDisabled && !errors.geoIpDatabasePath,
2446
+ disabled: (databaseDisabled || locked) && !errors.geoIpDatabasePath,
2391
2447
  onChange: (event) => handleChange("geoIpDatabasePath", event.target.value),
2392
2448
  placeholder: "GeoLite2-City.mmdb",
2393
2449
  autoComplete: "off",
@@ -2543,6 +2599,7 @@ const LocationDataTab = ({ form }) => {
2543
2599
  const { settings, handleChange } = form;
2544
2600
  const risk = riskData.getRiskAvailability(form.geoIp.status);
2545
2601
  const scoring = riskData.riskDependentControl(settings.enableSecurityScoring, risk.state);
2602
+ const locked = form.canChangeProtected === false;
2546
2603
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
2547
2604
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2548
2605
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
@@ -2555,7 +2612,7 @@ const LocationDataTab = ({ form }) => {
2555
2612
  ) })
2556
2613
  ] }),
2557
2614
  /* @__PURE__ */ jsxRuntime.jsxs(SectionCard.SectionCard, { title: t("settings.config.lookup.title", "IP location lookup"), children: [
2558
- /* @__PURE__ */ jsxRuntime.jsx(
2615
+ /* @__PURE__ */ jsxRuntime.jsxs(
2559
2616
  SettingsToggleRow,
2560
2617
  {
2561
2618
  id: "enable-ip-geolocation",
@@ -2565,11 +2622,15 @@ const LocationDataTab = ({ form }) => {
2565
2622
  "Looks up country and city at every sign-in and for listed sessions without a location."
2566
2623
  ),
2567
2624
  checked: settings.enableGeolocation,
2625
+ disabled: locked,
2568
2626
  onChange: (checked) => handleChange("enableGeolocation", checked),
2569
- children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
2570
- "settings.config.lookup.enable.privacy",
2571
- "With the Automatic or ipapi.co provider, IP addresses can be sent to ipapi.co."
2572
- ) })
2627
+ children: [
2628
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
2629
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
2630
+ "settings.config.lookup.enable.privacy",
2631
+ "With the Automatic or ipapi.co provider, IP addresses can be sent to ipapi.co."
2632
+ ) })
2633
+ ]
2573
2634
  }
2574
2635
  ),
2575
2636
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2938,6 +2999,84 @@ const EmailTemplatesCard = ({ form }) => {
2938
2999
  ] })
2939
3000
  ] });
2940
3001
  };
3002
+ const WebhookUrlField = ({
3003
+ form,
3004
+ id,
3005
+ field,
3006
+ hasKey,
3007
+ hintKey,
3008
+ label,
3009
+ description,
3010
+ placeholder,
3011
+ error,
3012
+ disabled = false
3013
+ }) => {
3014
+ const { t } = useSettingsTranslate();
3015
+ const { settings, handleChange } = form;
3016
+ const stored = settings[hasKey] === true;
3017
+ const draft = settings[field];
3018
+ const [replacing, setReplacing] = react.useState(false);
3019
+ const removing = stored && draft === "";
3020
+ const showInput = !stored || replacing || typeof draft === "string" && draft !== "";
3021
+ const onInput = (value) => handleChange(field, value ? value : void 0);
3022
+ const cancel = () => {
3023
+ handleChange(field, void 0);
3024
+ setReplacing(false);
3025
+ };
3026
+ if (!showInput) {
3027
+ return /* @__PURE__ */ jsxRuntime.jsx(FormField, { id, name: field, label, description, error, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-webhook-saved": field, children: [
3028
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3029
+ /* @__PURE__ */ jsxRuntime.jsx(
3030
+ designSystem.Badge,
3031
+ {
3032
+ backgroundColor: removing ? "danger100" : "success100",
3033
+ textColor: removing ? "danger700" : "success700",
3034
+ children: removing ? t("settings.webhooks.removing", "Removed on save") : t("settings.webhooks.saved", "Saved")
3035
+ }
3036
+ ),
3037
+ settings[hintKey] ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: settings[hintKey] }) : null
3038
+ ] }),
3039
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", children: removing ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", size: "S", disabled, onClick: cancel, children: t("settings.webhooks.undo", "Keep URL") }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3040
+ /* @__PURE__ */ jsxRuntime.jsx(
3041
+ designSystem.Button,
3042
+ {
3043
+ variant: "secondary",
3044
+ size: "S",
3045
+ disabled,
3046
+ onClick: () => setReplacing(true),
3047
+ children: t("settings.webhooks.replace", "Replace")
3048
+ }
3049
+ ),
3050
+ /* @__PURE__ */ jsxRuntime.jsx(
3051
+ designSystem.Button,
3052
+ {
3053
+ variant: "danger-light",
3054
+ size: "S",
3055
+ disabled,
3056
+ onClick: () => handleChange(field, ""),
3057
+ children: t("settings.webhooks.remove", "Remove")
3058
+ }
3059
+ )
3060
+ ] }) })
3061
+ ] }) });
3062
+ }
3063
+ return /* @__PURE__ */ jsxRuntime.jsx(FormField, { id, name: field, label, description, error, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3064
+ /* @__PURE__ */ jsxRuntime.jsx(
3065
+ SecretTextInput,
3066
+ {
3067
+ name: field,
3068
+ revealedType: "url",
3069
+ value: typeof draft === "string" ? draft : "",
3070
+ disabled: disabled && !error,
3071
+ onChange: onInput,
3072
+ placeholder,
3073
+ showLabel: t("settings.webhooks.show", "Show URL"),
3074
+ hideLabel: t("settings.webhooks.hide", "Hide URL")
3075
+ }
3076
+ ),
3077
+ stored ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", size: "S", onClick: cancel, children: t("settings.webhooks.cancelReplace", "Keep the saved URL") }) }) : null
3078
+ ] }) });
3079
+ };
2941
3080
  const WEBHOOK_EVENTS = Object.freeze({
2942
3081
  suspicious: "login.suspicious",
2943
3082
  newLocation: "login.new_location",
@@ -2977,6 +3116,7 @@ const AlertsTab = ({ form }) => {
2977
3116
  const lookupOff = !settings.enableGeolocation;
2978
3117
  const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
2979
3118
  const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
3119
+ const locked = form.canChangeProtected === false;
2980
3120
  const templateErrors = fieldHasError(errors, "emailTemplates");
2981
3121
  const risk = riskData.getRiskAvailability(form.geoIp.status);
2982
3122
  const emailTypes = [
@@ -3102,7 +3242,7 @@ const AlertsTab = ({ form }) => {
3102
3242
  WEBHOOK_EVENTS
3103
3243
  ),
3104
3244
  checked: settings.enableWebhooks,
3105
- disabled: lookupOff,
3245
+ disabled: lookupOff || locked,
3106
3246
  onChange: (checked) => handleChange("enableWebhooks", checked)
3107
3247
  }
3108
3248
  ),
@@ -3112,64 +3252,51 @@ const AlertsTab = ({ form }) => {
3112
3252
  "Without a risk data source, {suspicious} is never sent.",
3113
3253
  WEBHOOK_EVENTS
3114
3254
  ) }) : null,
3255
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
3115
3256
  /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
3116
3257
  /* @__PURE__ */ jsxRuntime.jsx(
3117
- FormField,
3258
+ WebhookUrlField,
3118
3259
  {
3260
+ form,
3119
3261
  id: "discord-webhook-url",
3120
- name: "discordWebhookUrl",
3262
+ field: "discordWebhookUrl",
3263
+ hasKey: "hasDiscordWebhook",
3264
+ hintKey: "discordWebhookHint",
3121
3265
  label: t("settings.config.webhooks.discord.label", "Discord webhook URL"),
3122
3266
  description: t(
3123
3267
  "settings.config.webhooks.discord.hint",
3124
3268
  "Must start with https://discord.com or https://discordapp.com. Anyone with this URL can post to your channel."
3125
3269
  ),
3126
3270
  error: tError(errors.discordWebhookUrl),
3127
- children: /* @__PURE__ */ jsxRuntime.jsx(
3128
- SecretTextInput,
3129
- {
3130
- name: "discordWebhookUrl",
3131
- revealedType: "url",
3132
- value: settings.discordWebhookUrl || "",
3133
- disabled: webhookFieldsDisabled && !errors.discordWebhookUrl,
3134
- onChange: (value) => handleChange("discordWebhookUrl", value),
3135
- placeholder: t(
3136
- "settings.webhooks.discord.placeholder",
3137
- "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."
3138
- ),
3139
- showLabel: t("settings.webhooks.show", "Show URL"),
3140
- hideLabel: t("settings.webhooks.hide", "Hide URL")
3141
- }
3271
+ disabled: webhookFieldsDisabled || locked,
3272
+ placeholder: t(
3273
+ "settings.webhooks.discord.placeholder",
3274
+ "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."
3142
3275
  )
3143
- }
3276
+ },
3277
+ `discord-${form.draftVersion}`
3144
3278
  ),
3145
3279
  /* @__PURE__ */ jsxRuntime.jsx(
3146
- FormField,
3280
+ WebhookUrlField,
3147
3281
  {
3282
+ form,
3148
3283
  id: "slack-webhook-url",
3149
- name: "slackWebhookUrl",
3284
+ field: "slackWebhookUrl",
3285
+ hasKey: "hasSlackWebhook",
3286
+ hintKey: "slackWebhookHint",
3150
3287
  label: t("settings.config.webhooks.slack.label", "Slack webhook URL"),
3151
3288
  description: t(
3152
3289
  "settings.config.webhooks.slack.hint",
3153
3290
  "Must start with https://hooks.slack.com. Anyone with this URL can post to your channel."
3154
3291
  ),
3155
3292
  error: tError(errors.slackWebhookUrl),
3156
- children: /* @__PURE__ */ jsxRuntime.jsx(
3157
- SecretTextInput,
3158
- {
3159
- name: "slackWebhookUrl",
3160
- revealedType: "url",
3161
- value: settings.slackWebhookUrl || "",
3162
- disabled: webhookFieldsDisabled && !errors.slackWebhookUrl,
3163
- onChange: (value) => handleChange("slackWebhookUrl", value),
3164
- placeholder: t(
3165
- "settings.webhooks.slack.placeholder",
3166
- "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
3167
- ),
3168
- showLabel: t("settings.webhooks.show", "Show URL"),
3169
- hideLabel: t("settings.webhooks.hide", "Hide URL")
3170
- }
3293
+ disabled: webhookFieldsDisabled || locked,
3294
+ placeholder: t(
3295
+ "settings.webhooks.slack.placeholder",
3296
+ "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
3171
3297
  )
3172
- }
3298
+ },
3299
+ `slack-${form.draftVersion}`
3173
3300
  )
3174
3301
  ] })
3175
3302
  ]
@@ -3251,6 +3378,135 @@ const DataRetentionTab = ({ form }) => {
3251
3378
  )
3252
3379
  ] });
3253
3380
  };
3381
+ const AdminActivityTab = ({ form }) => {
3382
+ const { t } = useSettingsTranslate();
3383
+ const units = useOptionLabels();
3384
+ const { settings, handleChange } = form;
3385
+ const locked = form.canChangeProtected === false;
3386
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3387
+ /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
3388
+ "settings.config.adminActivity.intro",
3389
+ "The security log records sign-ins and work in this admin panel. Each admin’s history is under Session Manager > Admin panel; only admins with “View admin activity” can open it."
3390
+ ) }),
3391
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
3392
+ /* @__PURE__ */ jsxRuntime.jsxs(SectionCard.SectionCard, { title: t("settings.config.adminActivity.recording.title", "What is recorded"), children: [
3393
+ /* @__PURE__ */ jsxRuntime.jsx(
3394
+ SettingsToggleRow,
3395
+ {
3396
+ id: "admin-sign-in-history",
3397
+ title: t("settings.config.adminActivity.signIns.label", "Record admin sign-ins"),
3398
+ description: t(
3399
+ "settings.config.adminActivity.signIns.hint",
3400
+ "Every sign-in, failed attempt, lockout and sign-out, and who signed out whom, with time, browser and operating system."
3401
+ ),
3402
+ checked: settings.adminSignInHistory,
3403
+ disabled: locked,
3404
+ onChange: (checked) => handleChange("adminSignInHistory", checked)
3405
+ }
3406
+ ),
3407
+ /* @__PURE__ */ jsxRuntime.jsx(
3408
+ SettingsToggleRow,
3409
+ {
3410
+ id: "admin-content-activity",
3411
+ title: t(
3412
+ "settings.config.adminActivity.content.label",
3413
+ "Record Content Manager activity"
3414
+ ),
3415
+ description: t(
3416
+ "settings.config.adminActivity.content.hint",
3417
+ "Which entries each admin opens, creates, edits, publishes, unpublishes or deletes, with content type, locale and time. Entry titles are not stored; the list shows them only to admins who may open the entry."
3418
+ ),
3419
+ checked: settings.adminContentActivity,
3420
+ disabled: locked,
3421
+ onChange: (checked) => handleChange("adminContentActivity", checked),
3422
+ children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
3423
+ "settings.config.adminActivity.content.notice",
3424
+ "This records how people work. In many countries employees must be told first, and in Germany the works council usually has a say. Check this before you turn it on."
3425
+ ) })
3426
+ }
3427
+ )
3428
+ ] }),
3429
+ /* @__PURE__ */ jsxRuntime.jsxs(
3430
+ SectionCard.SectionCard,
3431
+ {
3432
+ title: t("settings.config.adminActivity.privacy.title", "IP addresses and retention"),
3433
+ subtitle: t(
3434
+ "settings.config.adminActivity.privacy.subtitle",
3435
+ "These options apply to every event in the security log."
3436
+ ),
3437
+ children: [
3438
+ /* @__PURE__ */ jsxRuntime.jsx(
3439
+ SettingsToggleRow,
3440
+ {
3441
+ id: "security-log-store-ip",
3442
+ title: t("settings.config.adminActivity.storeIp.label", "Store IP addresses"),
3443
+ description: t(
3444
+ "settings.config.adminActivity.storeIp.hint",
3445
+ "The address comes from Strapi’s client IP (server.proxy settings). The location uses the IP location lookup under Location data."
3446
+ ),
3447
+ checked: settings.securityLogStoreIp,
3448
+ disabled: locked,
3449
+ onChange: (checked) => handleChange("securityLogStoreIp", checked)
3450
+ }
3451
+ ),
3452
+ /* @__PURE__ */ jsxRuntime.jsx(
3453
+ SettingsToggleRow,
3454
+ {
3455
+ id: "security-log-anonymize-ip",
3456
+ title: t(
3457
+ "settings.config.adminActivity.anonymize.label",
3458
+ "Anonymise the last part of IP addresses"
3459
+ ),
3460
+ description: t(
3461
+ "settings.config.adminActivity.anonymize.hint",
3462
+ "Stores 203.0.113.0 instead of 203.0.113.42 (IPv6: the first 48 bits only)."
3463
+ ),
3464
+ checked: settings.securityLogAnonymizeIp,
3465
+ disabled: locked || !settings.securityLogStoreIp,
3466
+ onChange: (checked) => handleChange("securityLogAnonymizeIp", checked),
3467
+ children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
3468
+ }
3469
+ ),
3470
+ /* @__PURE__ */ jsxRuntime.jsx(
3471
+ SettingsToggleRow,
3472
+ {
3473
+ id: "security-log-geo-lookup",
3474
+ title: t(
3475
+ "settings.config.adminActivity.geoLookup.label",
3476
+ "Look up the location of security events"
3477
+ ),
3478
+ description: t(
3479
+ "settings.config.adminActivity.geoLookup.hint",
3480
+ "Shows country and city next to each sign-in. Only the anonymised address is looked up, in the local GeoIP database; it goes to ipapi.co only if you chose ipapi.co as provider under Location data."
3481
+ ),
3482
+ checked: settings.securityLogGeoLookup,
3483
+ disabled: locked || !settings.securityLogStoreIp,
3484
+ onChange: (checked) => handleChange("securityLogGeoLookup", checked),
3485
+ children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
3486
+ }
3487
+ ),
3488
+ /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
3489
+ PresetSelect,
3490
+ {
3491
+ id: "security-log-retention",
3492
+ name: "securityLogRetentionDays",
3493
+ label: t("settings.config.adminActivity.retention.label", "Keep security events for"),
3494
+ description: t(
3495
+ "settings.config.adminActivity.retention.hint",
3496
+ "At least 7 days. Older events are deleted once a day; each deletion is itself recorded. Events of a deleted admin are deleted with the account."
3497
+ ),
3498
+ value: settings.securityLogRetentionDays,
3499
+ presets: SELECT_PRESETS.securityLogRetentionDays,
3500
+ format: units.days,
3501
+ disabled: locked,
3502
+ onChange: (value) => handleChange("securityLogRetentionDays", value)
3503
+ }
3504
+ ) })
3505
+ ]
3506
+ }
3507
+ )
3508
+ ] });
3509
+ };
3254
3510
  async function copyText(value, clipboard = globalThis.navigator?.clipboard) {
3255
3511
  if (typeof value !== "string") {
3256
3512
  throw new TypeError("clipboard_value_must_be_text");
@@ -3377,7 +3633,14 @@ function useSettingsForm() {
3377
3633
  if (key === "strictSessionEnforcement") {
3378
3634
  setRelaxedWarningDismissed(false);
3379
3635
  }
3380
- setSettings((previousSettings) => ({ ...previousSettings, [key]: value }));
3636
+ setSettings((previousSettings) => {
3637
+ if (value === void 0) {
3638
+ const next = { ...previousSettings };
3639
+ delete next[key];
3640
+ return next;
3641
+ }
3642
+ return { ...previousSettings, [key]: value };
3643
+ });
3381
3644
  }, []);
3382
3645
  const handleSave = react.useCallback(async () => {
3383
3646
  const submitted = buildSavePayload(settingsRef.current, savedSettingsRef.current);
@@ -3623,7 +3886,8 @@ const TAB_COMPONENTS = {
3623
3886
  "login-protection": LoginProtectionTab,
3624
3887
  "location-data": LocationDataTab,
3625
3888
  alerts: AlertsTab,
3626
- "data-retention": DataRetentionTab
3889
+ "data-retention": DataRetentionTab,
3890
+ "admin-activity": AdminActivityTab
3627
3891
  };
3628
3892
  const DraftSync = ({ values }) => {
3629
3893
  const setValues = StrapiAdmin.useForm("DraftSync", (state) => state.setValues);
@@ -3643,7 +3907,17 @@ const SettingsPage = () => {
3643
3907
  const { t } = useSettingsTranslate();
3644
3908
  const form = useSettingsForm();
3645
3909
  const [{ query }] = StrapiAdmin.useQueryParams();
3646
- const requestedTab = resolveSettingsTab(query?.tab);
3910
+ const {
3911
+ allowedActions: { canRead: canViewAdminActivity }
3912
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.adminActivityRead);
3913
+ const {
3914
+ allowedActions: { canUpdate: canChangeProtected }
3915
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.settingsUpdate);
3916
+ const visibleTabs = react.useMemo(
3917
+ () => getVisibleSettingsTabs(Boolean(canViewAdminActivity)),
3918
+ [canViewAdminActivity]
3919
+ );
3920
+ const requestedTab = resolveSettingsTab(query?.tab, visibleTabs);
3647
3921
  const [activeTab, setActiveTab] = react.useState(requestedTab);
3648
3922
  const [followedTab, setFollowedTab] = react.useState(requestedTab);
3649
3923
  const tabsRef = react.useRef(null);
@@ -3670,11 +3944,14 @@ const SettingsPage = () => {
3670
3944
  const handleSaveClick = react.useCallback(async () => {
3671
3945
  if (await handleSave()) focusActiveTab();
3672
3946
  }, [handleSave, focusActiveTab]);
3673
- const changeTab = react.useCallback((tab) => {
3674
- const next = resolveSettingsTab(tab);
3675
- setActiveTab(next);
3676
- writeTabToAddressBar(next);
3677
- }, []);
3947
+ const changeTab = react.useCallback(
3948
+ (tab) => {
3949
+ const next = resolveSettingsTab(tab, visibleTabs);
3950
+ setActiveTab(next);
3951
+ writeTabToAddressBar(next);
3952
+ },
3953
+ [visibleTabs]
3954
+ );
3678
3955
  const navigation = react.useMemo(
3679
3956
  () => ({
3680
3957
  selectTab: (tab) => {
@@ -3759,12 +4036,17 @@ const SettingsPage = () => {
3759
4036
  SettingsTabsList,
3760
4037
  {
3761
4038
  "aria-label": t("settings.config.tabs.label", "Configuration sections"),
3762
- children: SETTINGS_TAB_IDS.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLabel, { children: t(SETTINGS_TAB_LABELS[tab][0], SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
4039
+ children: visibleTabs.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLabel, { children: t(SETTINGS_TAB_LABELS[tab][0], SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
3763
4040
  }
3764
4041
  ),
3765
- SETTINGS_TAB_IDS.map((tab) => {
4042
+ visibleTabs.map((tab) => {
3766
4043
  const TabPanel = TAB_COMPONENTS[tab];
3767
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: tab, forceMount: true, hidden: activeTab !== tab, children: /* @__PURE__ */ jsxRuntime.jsx(TabPanelFrame, { "data-settings-tab-panel": "", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", paddingTop: 6, children: /* @__PURE__ */ jsxRuntime.jsx(TabPanel, { form }) }) }) }, tab);
4044
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: tab, forceMount: true, hidden: activeTab !== tab, children: /* @__PURE__ */ jsxRuntime.jsx(TabPanelFrame, { "data-settings-tab-panel": "", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", paddingTop: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
4045
+ TabPanel,
4046
+ {
4047
+ form: { ...form, canChangeProtected: Boolean(canChangeProtected) }
4048
+ }
4049
+ ) }) }) }, tab);
3768
4050
  }),
3769
4051
  /* @__PURE__ */ jsxRuntime.jsxs(StrapiAdmin.Form, { method: "PUT", initialValues: form.savedSettings, children: [
3770
4052
  /* @__PURE__ */ jsxRuntime.jsx(DraftSync, { values: form.settings }),