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
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
2
  import { useState, useCallback, createContext, useContext, useMemo, useId, Fragment, useRef, useEffect, useLayoutEffect } from "react";
3
3
  import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSelect, SingleSelectOption, Accordion, Alert, Badge, Radio, Dialog, Tag, Combobox, ComboboxOption, NumberInput, Divider, Tabs, Textarea, Checkbox } from "@strapi/design-system";
4
- import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
4
+ import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, useRBAC, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
5
5
  import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Download, Check } from "@strapi/icons";
6
6
  import styled from "styled-components";
7
- import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, w as PageShell } from "./index-lnZBc5n0.mjs";
7
+ import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, o as pluginPermissions, w as PageShell } from "./index-tt61o2VH.mjs";
8
8
  import { useIntl } from "react-intl";
9
9
  import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
10
10
  import { g as getRiskAvailability, r as riskDependentControl } from "./riskData-CI1gm2yI.mjs";
@@ -13,15 +13,18 @@ const SETTINGS_TAB_IDS = Object.freeze([
13
13
  "login-protection",
14
14
  "location-data",
15
15
  "alerts",
16
- "data-retention"
16
+ "data-retention",
17
+ "admin-activity"
17
18
  ]);
19
+ const PERMISSION_GATED_TABS = Object.freeze(["admin-activity"]);
18
20
  const DEFAULT_SETTINGS_TAB = "sessions";
19
21
  const SETTINGS_TAB_LABELS = Object.freeze({
20
22
  sessions: ["settings.config.tab.sessions", "Sessions"],
21
23
  "login-protection": ["settings.config.tab.loginProtection", "Login protection"],
22
24
  "location-data": ["settings.config.tab.locationData", "Location data"],
23
25
  alerts: ["settings.config.tab.alerts", "Alerts"],
24
- "data-retention": ["settings.config.tab.dataRetention", "Data and retention"]
26
+ "data-retention": ["settings.config.tab.dataRetention", "Data and retention"],
27
+ "admin-activity": ["settings.config.tab.adminActivity", "Admin activity"]
25
28
  });
26
29
  const SETTINGS_TAB_FIELDS = Object.freeze({
27
30
  sessions: [
@@ -58,7 +61,15 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
58
61
  "discordWebhookUrl",
59
62
  "slackWebhookUrl"
60
63
  ],
61
- "data-retention": ["retentionDays"]
64
+ "data-retention": ["retentionDays"],
65
+ "admin-activity": [
66
+ "adminSignInHistory",
67
+ "adminContentActivity",
68
+ "securityLogStoreIp",
69
+ "securityLogAnonymizeIp",
70
+ "securityLogGeoLookup",
71
+ "securityLogRetentionDays"
72
+ ]
62
73
  });
63
74
  const PRESERVED_SETTINGS_KEYS = Object.freeze([
64
75
  "rateLimitWriteMax",
@@ -101,7 +112,25 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
101
112
  enableWebhooks: ["settings.config.webhooks.enable.label", "Send team notifications"],
102
113
  discordWebhookUrl: ["settings.config.webhooks.discord.label", "Discord webhook URL"],
103
114
  slackWebhookUrl: ["settings.config.webhooks.slack.label", "Slack webhook URL"],
104
- retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"]
115
+ retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"],
116
+ adminSignInHistory: ["settings.config.adminActivity.signIns.label", "Record admin sign-ins"],
117
+ adminContentActivity: [
118
+ "settings.config.adminActivity.content.label",
119
+ "Record Content Manager activity"
120
+ ],
121
+ securityLogStoreIp: ["settings.config.adminActivity.storeIp.label", "Store IP addresses"],
122
+ securityLogAnonymizeIp: [
123
+ "settings.config.adminActivity.anonymize.label",
124
+ "Anonymise the last part of IP addresses"
125
+ ],
126
+ securityLogGeoLookup: [
127
+ "settings.config.adminActivity.geoLookup.label",
128
+ "Look up the location of security events"
129
+ ],
130
+ securityLogRetentionDays: [
131
+ "settings.config.adminActivity.retention.label",
132
+ "Keep security events for"
133
+ ]
105
134
  });
106
135
  const SELECT_PRESETS = Object.freeze({
107
136
  inactivityTimeout: Object.freeze([5, 10, 15, 30, 60, 120]),
@@ -109,11 +138,17 @@ const SELECT_PRESETS = Object.freeze({
109
138
  lastSeenRateLimit: Object.freeze([10, 30, 60, 120, 300]),
110
139
  cleanupInterval: Object.freeze([15, 30, 60, 120]),
111
140
  sessionCreationGraceMs: Object.freeze([0, 2e3, 5e3, 1e4, 3e4]),
112
- retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1])
141
+ retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1]),
142
+ securityLogRetentionDays: Object.freeze([7, 30, 90, 180, 365])
113
143
  });
114
- function resolveSettingsTab(value) {
144
+ function resolveSettingsTab(value, tabs = SETTINGS_TAB_IDS) {
115
145
  const candidate = Array.isArray(value) ? value[0] : value;
116
- return SETTINGS_TAB_IDS.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
146
+ return tabs.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
147
+ }
148
+ function getVisibleSettingsTabs(canViewAdminActivity) {
149
+ return SETTINGS_TAB_IDS.filter(
150
+ (tab) => canViewAdminActivity || !PERMISSION_GATED_TABS.includes(tab)
151
+ );
117
152
  }
118
153
  function buildTabSearch(search, tab) {
119
154
  const params = new URLSearchParams(typeof search === "string" ? search : "");
@@ -586,6 +621,13 @@ function useOptionLabels() {
586
621
  }
587
622
  const IntroText = ({ children }) => /* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral600", tag: "p", children });
588
623
  const RequiresNotice = ({ tab, children }) => /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", "data-requires": "", children: tab ? /* @__PURE__ */ jsx(SettingsTabLink, { tab, children }) : children });
624
+ const ProtectedNotice = () => {
625
+ const { t } = useSettingsTranslate();
626
+ return /* @__PURE__ */ jsx(RequiresNotice, { children: t(
627
+ "settings.config.protected.notice",
628
+ "Read-only for your role: changing this needs the “Change protected settings” permission."
629
+ ) });
630
+ };
589
631
  const RequiresGeolocation = () => {
590
632
  const { t } = useSettingsTranslate();
591
633
  return /* @__PURE__ */ jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
@@ -1368,15 +1410,27 @@ const SETTINGS_DEFAULTS = Object.freeze({
1368
1410
  alertOnNewLocation: true,
1369
1411
  alertOnVpnProxy: true,
1370
1412
  enableWebhooks: false,
1371
- discordWebhookUrl: "",
1372
- slackWebhookUrl: "",
1413
+ // Webhook URLs are never returned (4.17): the API sends hasDiscordWebhook /
1414
+ // hasSlackWebhook and a hint; a URL key exists in the draft only while the
1415
+ // admin replaces (text) or removes ('') it.
1416
+ hasDiscordWebhook: false,
1417
+ hasSlackWebhook: false,
1418
+ discordWebhookHint: null,
1419
+ slackWebhookHint: null,
1373
1420
  enableGeofencing: false,
1374
1421
  allowedCountries: [],
1375
1422
  blockedCountries: [],
1376
1423
  geoIpProvider: "auto",
1377
1424
  geoIpDatabasePath: "",
1378
- geoLookupFailureMode: "auto"
1425
+ geoLookupFailureMode: "auto",
1426
+ adminSignInHistory: true,
1427
+ adminContentActivity: false,
1428
+ securityLogStoreIp: true,
1429
+ securityLogAnonymizeIp: false,
1430
+ securityLogGeoLookup: false,
1431
+ securityLogRetentionDays: 90
1379
1432
  });
1433
+ const WRITE_ONLY_SETTINGS_KEYS = Object.freeze(["discordWebhookUrl", "slackWebhookUrl"]);
1380
1434
  const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
1381
1435
  const WEBHOOK_HOSTS = Object.freeze({
1382
1436
  discordWebhookUrl: ["discord.com", "discordapp.com"],
@@ -1486,7 +1540,7 @@ function validateSettings(settings) {
1486
1540
  function getAdjustedFields(submitted, stored, previous) {
1487
1541
  const source = submitted || {};
1488
1542
  return Object.keys(source).filter(
1489
- (key) => !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
1543
+ (key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
1490
1544
  );
1491
1545
  }
1492
1546
  const COUNTRIES = [
@@ -1890,6 +1944,7 @@ const LoginProtectionTab = ({ form }) => {
1890
1944
  const maxFailedError = tError(errors.maxFailedLogins);
1891
1945
  const maxFailedValue = Number(settings.maxFailedLogins);
1892
1946
  const lookupOff = !settings.enableGeolocation;
1947
+ const locked = form.canChangeProtected === false;
1893
1948
  const risk = getRiskAvailability(form.geoIp.status);
1894
1949
  const reject = riskDependentControl(settings.blockSuspiciousSessions, risk.state);
1895
1950
  const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
@@ -2042,7 +2097,7 @@ const LoginProtectionTab = ({ form }) => {
2042
2097
  SingleSelect,
2043
2098
  {
2044
2099
  value: settings.geoLookupFailureMode || "auto",
2045
- disabled: lookupOff,
2100
+ disabled: lookupOff || locked,
2046
2101
  onChange: (value) => handleChange("geoLookupFailureMode", value),
2047
2102
  children: [
2048
2103
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
@@ -2150,6 +2205,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2150
2205
  );
2151
2206
  };
2152
2207
  const lookupOff = !settings.enableGeolocation;
2208
+ const locked = form.canChangeProtected === false;
2153
2209
  const localDatabase = usesLocalDatabase(settings.geoIpProvider);
2154
2210
  const databaseDisabled = lookupOff || !localDatabase;
2155
2211
  const credentialSource = geoIpStatus?.credentialSource;
@@ -2187,7 +2243,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2187
2243
  SingleSelect,
2188
2244
  {
2189
2245
  value: settings.geoIpProvider || "auto",
2190
- disabled: lookupOff,
2246
+ disabled: lookupOff || locked,
2191
2247
  onChange: (value) => handleChange("geoIpProvider", value),
2192
2248
  children: [
2193
2249
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.config.provider.auto", "Automatic") }),
@@ -2383,7 +2439,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2383
2439
  {
2384
2440
  name: "geoIpDatabasePath",
2385
2441
  value: settings.geoIpDatabasePath || "",
2386
- disabled: databaseDisabled && !errors.geoIpDatabasePath,
2442
+ disabled: (databaseDisabled || locked) && !errors.geoIpDatabasePath,
2387
2443
  onChange: (event) => handleChange("geoIpDatabasePath", event.target.value),
2388
2444
  placeholder: "GeoLite2-City.mmdb",
2389
2445
  autoComplete: "off",
@@ -2539,6 +2595,7 @@ const LocationDataTab = ({ form }) => {
2539
2595
  const { settings, handleChange } = form;
2540
2596
  const risk = getRiskAvailability(form.geoIp.status);
2541
2597
  const scoring = riskDependentControl(settings.enableSecurityScoring, risk.state);
2598
+ const locked = form.canChangeProtected === false;
2542
2599
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
2543
2600
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2544
2601
  /* @__PURE__ */ jsx(IntroText, { children: t(
@@ -2551,7 +2608,7 @@ const LocationDataTab = ({ form }) => {
2551
2608
  ) })
2552
2609
  ] }),
2553
2610
  /* @__PURE__ */ jsxs(SectionCard, { title: t("settings.config.lookup.title", "IP location lookup"), children: [
2554
- /* @__PURE__ */ jsx(
2611
+ /* @__PURE__ */ jsxs(
2555
2612
  SettingsToggleRow,
2556
2613
  {
2557
2614
  id: "enable-ip-geolocation",
@@ -2561,11 +2618,15 @@ const LocationDataTab = ({ form }) => {
2561
2618
  "Looks up country and city at every sign-in and for listed sessions without a location."
2562
2619
  ),
2563
2620
  checked: settings.enableGeolocation,
2621
+ disabled: locked,
2564
2622
  onChange: (checked) => handleChange("enableGeolocation", checked),
2565
- children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
2566
- "settings.config.lookup.enable.privacy",
2567
- "With the Automatic or ipapi.co provider, IP addresses can be sent to ipapi.co."
2568
- ) })
2623
+ children: [
2624
+ locked ? /* @__PURE__ */ jsx(ProtectedNotice, {}) : null,
2625
+ /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
2626
+ "settings.config.lookup.enable.privacy",
2627
+ "With the Automatic or ipapi.co provider, IP addresses can be sent to ipapi.co."
2628
+ ) })
2629
+ ]
2569
2630
  }
2570
2631
  ),
2571
2632
  /* @__PURE__ */ jsx(
@@ -2934,6 +2995,84 @@ const EmailTemplatesCard = ({ form }) => {
2934
2995
  ] })
2935
2996
  ] });
2936
2997
  };
2998
+ const WebhookUrlField = ({
2999
+ form,
3000
+ id,
3001
+ field,
3002
+ hasKey,
3003
+ hintKey,
3004
+ label,
3005
+ description,
3006
+ placeholder,
3007
+ error,
3008
+ disabled = false
3009
+ }) => {
3010
+ const { t } = useSettingsTranslate();
3011
+ const { settings, handleChange } = form;
3012
+ const stored = settings[hasKey] === true;
3013
+ const draft = settings[field];
3014
+ const [replacing, setReplacing] = useState(false);
3015
+ const removing = stored && draft === "";
3016
+ const showInput = !stored || replacing || typeof draft === "string" && draft !== "";
3017
+ const onInput = (value) => handleChange(field, value ? value : void 0);
3018
+ const cancel = () => {
3019
+ handleChange(field, void 0);
3020
+ setReplacing(false);
3021
+ };
3022
+ if (!showInput) {
3023
+ return /* @__PURE__ */ jsx(FormField, { id, name: field, label, description, error, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-webhook-saved": field, children: [
3024
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
3025
+ /* @__PURE__ */ jsx(
3026
+ Badge,
3027
+ {
3028
+ backgroundColor: removing ? "danger100" : "success100",
3029
+ textColor: removing ? "danger700" : "success700",
3030
+ children: removing ? t("settings.webhooks.removing", "Removed on save") : t("settings.webhooks.saved", "Saved")
3031
+ }
3032
+ ),
3033
+ settings[hintKey] ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: settings[hintKey] }) : null
3034
+ ] }),
3035
+ /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", children: removing ? /* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "S", disabled, onClick: cancel, children: t("settings.webhooks.undo", "Keep URL") }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
3036
+ /* @__PURE__ */ jsx(
3037
+ Button,
3038
+ {
3039
+ variant: "secondary",
3040
+ size: "S",
3041
+ disabled,
3042
+ onClick: () => setReplacing(true),
3043
+ children: t("settings.webhooks.replace", "Replace")
3044
+ }
3045
+ ),
3046
+ /* @__PURE__ */ jsx(
3047
+ Button,
3048
+ {
3049
+ variant: "danger-light",
3050
+ size: "S",
3051
+ disabled,
3052
+ onClick: () => handleChange(field, ""),
3053
+ children: t("settings.webhooks.remove", "Remove")
3054
+ }
3055
+ )
3056
+ ] }) })
3057
+ ] }) });
3058
+ }
3059
+ return /* @__PURE__ */ jsx(FormField, { id, name: field, label, description, error, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3060
+ /* @__PURE__ */ jsx(
3061
+ SecretTextInput,
3062
+ {
3063
+ name: field,
3064
+ revealedType: "url",
3065
+ value: typeof draft === "string" ? draft : "",
3066
+ disabled: disabled && !error,
3067
+ onChange: onInput,
3068
+ placeholder,
3069
+ showLabel: t("settings.webhooks.show", "Show URL"),
3070
+ hideLabel: t("settings.webhooks.hide", "Hide URL")
3071
+ }
3072
+ ),
3073
+ stored ? /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "S", onClick: cancel, children: t("settings.webhooks.cancelReplace", "Keep the saved URL") }) }) : null
3074
+ ] }) });
3075
+ };
2937
3076
  const WEBHOOK_EVENTS = Object.freeze({
2938
3077
  suspicious: "login.suspicious",
2939
3078
  newLocation: "login.new_location",
@@ -2973,6 +3112,7 @@ const AlertsTab = ({ form }) => {
2973
3112
  const lookupOff = !settings.enableGeolocation;
2974
3113
  const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
2975
3114
  const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
3115
+ const locked = form.canChangeProtected === false;
2976
3116
  const templateErrors = fieldHasError(errors, "emailTemplates");
2977
3117
  const risk = getRiskAvailability(form.geoIp.status);
2978
3118
  const emailTypes = [
@@ -3098,7 +3238,7 @@ const AlertsTab = ({ form }) => {
3098
3238
  WEBHOOK_EVENTS
3099
3239
  ),
3100
3240
  checked: settings.enableWebhooks,
3101
- disabled: lookupOff,
3241
+ disabled: lookupOff || locked,
3102
3242
  onChange: (checked) => handleChange("enableWebhooks", checked)
3103
3243
  }
3104
3244
  ),
@@ -3108,64 +3248,51 @@ const AlertsTab = ({ form }) => {
3108
3248
  "Without a risk data source, {suspicious} is never sent.",
3109
3249
  WEBHOOK_EVENTS
3110
3250
  ) }) : null,
3251
+ locked ? /* @__PURE__ */ jsx(ProtectedNotice, {}) : null,
3111
3252
  /* @__PURE__ */ jsxs(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
3112
3253
  /* @__PURE__ */ jsx(
3113
- FormField,
3254
+ WebhookUrlField,
3114
3255
  {
3256
+ form,
3115
3257
  id: "discord-webhook-url",
3116
- name: "discordWebhookUrl",
3258
+ field: "discordWebhookUrl",
3259
+ hasKey: "hasDiscordWebhook",
3260
+ hintKey: "discordWebhookHint",
3117
3261
  label: t("settings.config.webhooks.discord.label", "Discord webhook URL"),
3118
3262
  description: t(
3119
3263
  "settings.config.webhooks.discord.hint",
3120
3264
  "Must start with https://discord.com or https://discordapp.com. Anyone with this URL can post to your channel."
3121
3265
  ),
3122
3266
  error: tError(errors.discordWebhookUrl),
3123
- children: /* @__PURE__ */ jsx(
3124
- SecretTextInput,
3125
- {
3126
- name: "discordWebhookUrl",
3127
- revealedType: "url",
3128
- value: settings.discordWebhookUrl || "",
3129
- disabled: webhookFieldsDisabled && !errors.discordWebhookUrl,
3130
- onChange: (value) => handleChange("discordWebhookUrl", value),
3131
- placeholder: t(
3132
- "settings.webhooks.discord.placeholder",
3133
- "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."
3134
- ),
3135
- showLabel: t("settings.webhooks.show", "Show URL"),
3136
- hideLabel: t("settings.webhooks.hide", "Hide URL")
3137
- }
3267
+ disabled: webhookFieldsDisabled || locked,
3268
+ placeholder: t(
3269
+ "settings.webhooks.discord.placeholder",
3270
+ "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."
3138
3271
  )
3139
- }
3272
+ },
3273
+ `discord-${form.draftVersion}`
3140
3274
  ),
3141
3275
  /* @__PURE__ */ jsx(
3142
- FormField,
3276
+ WebhookUrlField,
3143
3277
  {
3278
+ form,
3144
3279
  id: "slack-webhook-url",
3145
- name: "slackWebhookUrl",
3280
+ field: "slackWebhookUrl",
3281
+ hasKey: "hasSlackWebhook",
3282
+ hintKey: "slackWebhookHint",
3146
3283
  label: t("settings.config.webhooks.slack.label", "Slack webhook URL"),
3147
3284
  description: t(
3148
3285
  "settings.config.webhooks.slack.hint",
3149
3286
  "Must start with https://hooks.slack.com. Anyone with this URL can post to your channel."
3150
3287
  ),
3151
3288
  error: tError(errors.slackWebhookUrl),
3152
- children: /* @__PURE__ */ jsx(
3153
- SecretTextInput,
3154
- {
3155
- name: "slackWebhookUrl",
3156
- revealedType: "url",
3157
- value: settings.slackWebhookUrl || "",
3158
- disabled: webhookFieldsDisabled && !errors.slackWebhookUrl,
3159
- onChange: (value) => handleChange("slackWebhookUrl", value),
3160
- placeholder: t(
3161
- "settings.webhooks.slack.placeholder",
3162
- "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
3163
- ),
3164
- showLabel: t("settings.webhooks.show", "Show URL"),
3165
- hideLabel: t("settings.webhooks.hide", "Hide URL")
3166
- }
3289
+ disabled: webhookFieldsDisabled || locked,
3290
+ placeholder: t(
3291
+ "settings.webhooks.slack.placeholder",
3292
+ "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
3167
3293
  )
3168
- }
3294
+ },
3295
+ `slack-${form.draftVersion}`
3169
3296
  )
3170
3297
  ] })
3171
3298
  ]
@@ -3247,6 +3374,135 @@ const DataRetentionTab = ({ form }) => {
3247
3374
  )
3248
3375
  ] });
3249
3376
  };
3377
+ const AdminActivityTab = ({ form }) => {
3378
+ const { t } = useSettingsTranslate();
3379
+ const units = useOptionLabels();
3380
+ const { settings, handleChange } = form;
3381
+ const locked = form.canChangeProtected === false;
3382
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3383
+ /* @__PURE__ */ jsx(IntroText, { children: t(
3384
+ "settings.config.adminActivity.intro",
3385
+ "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."
3386
+ ) }),
3387
+ locked ? /* @__PURE__ */ jsx(ProtectedNotice, {}) : null,
3388
+ /* @__PURE__ */ jsxs(SectionCard, { title: t("settings.config.adminActivity.recording.title", "What is recorded"), children: [
3389
+ /* @__PURE__ */ jsx(
3390
+ SettingsToggleRow,
3391
+ {
3392
+ id: "admin-sign-in-history",
3393
+ title: t("settings.config.adminActivity.signIns.label", "Record admin sign-ins"),
3394
+ description: t(
3395
+ "settings.config.adminActivity.signIns.hint",
3396
+ "Every sign-in, failed attempt, lockout and sign-out, and who signed out whom, with time, browser and operating system."
3397
+ ),
3398
+ checked: settings.adminSignInHistory,
3399
+ disabled: locked,
3400
+ onChange: (checked) => handleChange("adminSignInHistory", checked)
3401
+ }
3402
+ ),
3403
+ /* @__PURE__ */ jsx(
3404
+ SettingsToggleRow,
3405
+ {
3406
+ id: "admin-content-activity",
3407
+ title: t(
3408
+ "settings.config.adminActivity.content.label",
3409
+ "Record Content Manager activity"
3410
+ ),
3411
+ description: t(
3412
+ "settings.config.adminActivity.content.hint",
3413
+ "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."
3414
+ ),
3415
+ checked: settings.adminContentActivity,
3416
+ disabled: locked,
3417
+ onChange: (checked) => handleChange("adminContentActivity", checked),
3418
+ children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
3419
+ "settings.config.adminActivity.content.notice",
3420
+ "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."
3421
+ ) })
3422
+ }
3423
+ )
3424
+ ] }),
3425
+ /* @__PURE__ */ jsxs(
3426
+ SectionCard,
3427
+ {
3428
+ title: t("settings.config.adminActivity.privacy.title", "IP addresses and retention"),
3429
+ subtitle: t(
3430
+ "settings.config.adminActivity.privacy.subtitle",
3431
+ "These options apply to every event in the security log."
3432
+ ),
3433
+ children: [
3434
+ /* @__PURE__ */ jsx(
3435
+ SettingsToggleRow,
3436
+ {
3437
+ id: "security-log-store-ip",
3438
+ title: t("settings.config.adminActivity.storeIp.label", "Store IP addresses"),
3439
+ description: t(
3440
+ "settings.config.adminActivity.storeIp.hint",
3441
+ "The address comes from Strapi’s client IP (server.proxy settings). The location uses the IP location lookup under Location data."
3442
+ ),
3443
+ checked: settings.securityLogStoreIp,
3444
+ disabled: locked,
3445
+ onChange: (checked) => handleChange("securityLogStoreIp", checked)
3446
+ }
3447
+ ),
3448
+ /* @__PURE__ */ jsx(
3449
+ SettingsToggleRow,
3450
+ {
3451
+ id: "security-log-anonymize-ip",
3452
+ title: t(
3453
+ "settings.config.adminActivity.anonymize.label",
3454
+ "Anonymise the last part of IP addresses"
3455
+ ),
3456
+ description: t(
3457
+ "settings.config.adminActivity.anonymize.hint",
3458
+ "Stores 203.0.113.0 instead of 203.0.113.42 (IPv6: the first 48 bits only)."
3459
+ ),
3460
+ checked: settings.securityLogAnonymizeIp,
3461
+ disabled: locked || !settings.securityLogStoreIp,
3462
+ onChange: (checked) => handleChange("securityLogAnonymizeIp", checked),
3463
+ children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
3464
+ }
3465
+ ),
3466
+ /* @__PURE__ */ jsx(
3467
+ SettingsToggleRow,
3468
+ {
3469
+ id: "security-log-geo-lookup",
3470
+ title: t(
3471
+ "settings.config.adminActivity.geoLookup.label",
3472
+ "Look up the location of security events"
3473
+ ),
3474
+ description: t(
3475
+ "settings.config.adminActivity.geoLookup.hint",
3476
+ "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."
3477
+ ),
3478
+ checked: settings.securityLogGeoLookup,
3479
+ disabled: locked || !settings.securityLogStoreIp,
3480
+ onChange: (checked) => handleChange("securityLogGeoLookup", checked),
3481
+ children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
3482
+ }
3483
+ ),
3484
+ /* @__PURE__ */ jsx(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsx(
3485
+ PresetSelect,
3486
+ {
3487
+ id: "security-log-retention",
3488
+ name: "securityLogRetentionDays",
3489
+ label: t("settings.config.adminActivity.retention.label", "Keep security events for"),
3490
+ description: t(
3491
+ "settings.config.adminActivity.retention.hint",
3492
+ "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."
3493
+ ),
3494
+ value: settings.securityLogRetentionDays,
3495
+ presets: SELECT_PRESETS.securityLogRetentionDays,
3496
+ format: units.days,
3497
+ disabled: locked,
3498
+ onChange: (value) => handleChange("securityLogRetentionDays", value)
3499
+ }
3500
+ ) })
3501
+ ]
3502
+ }
3503
+ )
3504
+ ] });
3505
+ };
3250
3506
  async function copyText(value, clipboard = globalThis.navigator?.clipboard) {
3251
3507
  if (typeof value !== "string") {
3252
3508
  throw new TypeError("clipboard_value_must_be_text");
@@ -3373,7 +3629,14 @@ function useSettingsForm() {
3373
3629
  if (key === "strictSessionEnforcement") {
3374
3630
  setRelaxedWarningDismissed(false);
3375
3631
  }
3376
- setSettings((previousSettings) => ({ ...previousSettings, [key]: value }));
3632
+ setSettings((previousSettings) => {
3633
+ if (value === void 0) {
3634
+ const next = { ...previousSettings };
3635
+ delete next[key];
3636
+ return next;
3637
+ }
3638
+ return { ...previousSettings, [key]: value };
3639
+ });
3377
3640
  }, []);
3378
3641
  const handleSave = useCallback(async () => {
3379
3642
  const submitted = buildSavePayload(settingsRef.current, savedSettingsRef.current);
@@ -3619,7 +3882,8 @@ const TAB_COMPONENTS = {
3619
3882
  "login-protection": LoginProtectionTab,
3620
3883
  "location-data": LocationDataTab,
3621
3884
  alerts: AlertsTab,
3622
- "data-retention": DataRetentionTab
3885
+ "data-retention": DataRetentionTab,
3886
+ "admin-activity": AdminActivityTab
3623
3887
  };
3624
3888
  const DraftSync = ({ values }) => {
3625
3889
  const setValues = useForm("DraftSync", (state) => state.setValues);
@@ -3639,7 +3903,17 @@ const SettingsPage = () => {
3639
3903
  const { t } = useSettingsTranslate();
3640
3904
  const form = useSettingsForm();
3641
3905
  const [{ query }] = useQueryParams();
3642
- const requestedTab = resolveSettingsTab(query?.tab);
3906
+ const {
3907
+ allowedActions: { canRead: canViewAdminActivity }
3908
+ } = useRBAC(pluginPermissions.adminActivityRead);
3909
+ const {
3910
+ allowedActions: { canUpdate: canChangeProtected }
3911
+ } = useRBAC(pluginPermissions.settingsUpdate);
3912
+ const visibleTabs = useMemo(
3913
+ () => getVisibleSettingsTabs(Boolean(canViewAdminActivity)),
3914
+ [canViewAdminActivity]
3915
+ );
3916
+ const requestedTab = resolveSettingsTab(query?.tab, visibleTabs);
3643
3917
  const [activeTab, setActiveTab] = useState(requestedTab);
3644
3918
  const [followedTab, setFollowedTab] = useState(requestedTab);
3645
3919
  const tabsRef = useRef(null);
@@ -3666,11 +3940,14 @@ const SettingsPage = () => {
3666
3940
  const handleSaveClick = useCallback(async () => {
3667
3941
  if (await handleSave()) focusActiveTab();
3668
3942
  }, [handleSave, focusActiveTab]);
3669
- const changeTab = useCallback((tab) => {
3670
- const next = resolveSettingsTab(tab);
3671
- setActiveTab(next);
3672
- writeTabToAddressBar(next);
3673
- }, []);
3943
+ const changeTab = useCallback(
3944
+ (tab) => {
3945
+ const next = resolveSettingsTab(tab, visibleTabs);
3946
+ setActiveTab(next);
3947
+ writeTabToAddressBar(next);
3948
+ },
3949
+ [visibleTabs]
3950
+ );
3674
3951
  const navigation = useMemo(
3675
3952
  () => ({
3676
3953
  selectTab: (tab) => {
@@ -3755,12 +4032,17 @@ const SettingsPage = () => {
3755
4032
  SettingsTabsList,
3756
4033
  {
3757
4034
  "aria-label": t("settings.config.tabs.label", "Configuration sections"),
3758
- children: SETTINGS_TAB_IDS.map((tab) => /* @__PURE__ */ jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsx(SettingsTabLabel, { children: t(SETTINGS_TAB_LABELS[tab][0], SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
4035
+ children: visibleTabs.map((tab) => /* @__PURE__ */ jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsx(SettingsTabLabel, { children: t(SETTINGS_TAB_LABELS[tab][0], SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
3759
4036
  }
3760
4037
  ),
3761
- SETTINGS_TAB_IDS.map((tab) => {
4038
+ visibleTabs.map((tab) => {
3762
4039
  const TabPanel = TAB_COMPONENTS[tab];
3763
- return /* @__PURE__ */ jsx(Tabs.Content, { value: tab, forceMount: true, hidden: activeTab !== tab, children: /* @__PURE__ */ jsx(TabPanelFrame, { "data-settings-tab-panel": "", children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", paddingTop: 6, children: /* @__PURE__ */ jsx(TabPanel, { form }) }) }) }, tab);
4040
+ return /* @__PURE__ */ jsx(Tabs.Content, { value: tab, forceMount: true, hidden: activeTab !== tab, children: /* @__PURE__ */ jsx(TabPanelFrame, { "data-settings-tab-panel": "", children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", paddingTop: 6, children: /* @__PURE__ */ jsx(
4041
+ TabPanel,
4042
+ {
4043
+ form: { ...form, canChangeProtected: Boolean(canChangeProtected) }
4044
+ }
4045
+ ) }) }) }, tab);
3764
4046
  }),
3765
4047
  /* @__PURE__ */ jsxs(Form, { method: "PUT", initialValues: form.savedSettings, children: [
3766
4048
  /* @__PURE__ */ jsx(DraftSync, { values: form.settings }),