strapi-plugin-magic-sessionmanager 4.16.0 → 4.17.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 (31) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +84 -36
  3. package/dist/admin/{Analytics-D4gsVwL0.mjs → Analytics-B-p2Q7th.mjs} +1 -1
  4. package/dist/admin/{Analytics-me4qzS0I.js → Analytics-BTIByTUY.js} +1 -1
  5. package/dist/admin/{App-BTG-2Q26.js → App-CH6635JB.js} +112 -184
  6. package/dist/admin/{App-BJwtFWxl.mjs → App-DmesuM2g.mjs} +82 -154
  7. package/dist/admin/{OnlineUsersWidget-Yd283YDy.mjs → OnlineUsersWidget-CuqeQ0tb.mjs} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-DYS3Vy1Q.js → OnlineUsersWidget-TlOp8nie.js} +1 -1
  9. package/dist/admin/{Settings-DIlvfdjZ.mjs → Settings-C4IgGBjQ.mjs} +1347 -109
  10. package/dist/admin/{Settings-TPZ9_75s.js → Settings-DtP_H4JS.js} +1351 -113
  11. package/dist/admin/dashboardModel-0ROcWcB1.mjs +189 -0
  12. package/dist/admin/dashboardModel-BSJhZdXI.js +188 -0
  13. package/dist/admin/{de-DB9ldYwN.mjs → de-BoahnYIP.mjs} +126 -11
  14. package/dist/admin/{de-BuMw1gBJ.js → de-C_ooq6EF.js} +126 -11
  15. package/dist/admin/{en-BqGhOJDy.js → en-CuUVE2K0.js} +126 -11
  16. package/dist/admin/{en-BbLMPQB3.mjs → en-DHme92L-.mjs} +126 -11
  17. package/dist/admin/{es-C5iaiE9G.mjs → es-CjcTgS9Z.mjs} +126 -11
  18. package/dist/admin/{es-BaIeckl9.js → es-lbDNXcQi.js} +126 -11
  19. package/dist/admin/{fr-BEvBUCwI.mjs → fr-BPwnrSaC.mjs} +126 -11
  20. package/dist/admin/{fr-D1YKyTex.js → fr-RtypjgGp.js} +126 -11
  21. package/dist/admin/{index-DUESEUaO.mjs → index-B102RF2H.mjs} +45 -38
  22. package/dist/admin/{index-CgZiLcJ1.js → index-w0OuPYFm.js} +17 -10
  23. package/dist/admin/index.js +1 -1
  24. package/dist/admin/index.mjs +1 -1
  25. package/dist/admin/{pt-DtnW-s0V.js → pt-BMCAKRQ4.js} +126 -11
  26. package/dist/admin/{pt-DeDih9cR.mjs → pt-D5FHSP2y.mjs} +126 -11
  27. package/dist/server/index.js +3577 -1293
  28. package/dist/server/index.mjs +3577 -1293
  29. package/package.json +1 -1
  30. package/dist/admin/riskData-BVs9GpgD.js +0 -26
  31. package/dist/admin/riskData-CI1gm2yI.mjs +0 -27
@@ -6,10 +6,11 @@ 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-CgZiLcJ1.js");
9
+ const index = require("./index-w0OuPYFm.js");
10
10
  const reactIntl = require("react-intl");
11
11
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
12
- const riskData = require("./riskData-BVs9GpgD.js");
12
+ const dashboardModel = require("./dashboardModel-BSJhZdXI.js");
13
+ const symbols = require("@strapi/icons/symbols");
13
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
15
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
16
  const SETTINGS_TAB_IDS = Object.freeze([
@@ -38,10 +39,20 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
38
39
  "cleanupInterval",
39
40
  "cleanupUseDbDirect",
40
41
  "strictSessionEnforcement",
41
- "sessionCreationGraceMs"
42
+ "sessionCreationGraceMs",
43
+ "maxSessionsPerUser",
44
+ "sessionLimitPolicy",
45
+ "endOtherSessionsOnPasswordChange",
46
+ "roleRules"
42
47
  ],
43
48
  "login-protection": [
44
49
  "maxFailedLogins",
50
+ "maxFailedLoginsPerAccount",
51
+ "lockoutWindowMinutes",
52
+ "lockoutDurationMinutes",
53
+ "lockoutTrustedAddresses",
54
+ "lockoutNotifyUser",
55
+ "recordUserSignInEvents",
45
56
  "trustedProxies",
46
57
  "blockSuspiciousSessions",
47
58
  "geoLookupFailureMode",
@@ -71,6 +82,7 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
71
82
  "adminContentActivity",
72
83
  "securityLogStoreIp",
73
84
  "securityLogAnonymizeIp",
85
+ "securityLogGeoLookup",
74
86
  "securityLogRetentionDays"
75
87
  ]
76
88
  });
@@ -90,7 +102,26 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
90
102
  cleanupUseDbDirect: ["settings.config.sessions.idleMethod.label", "Idle check method"],
91
103
  strictSessionEnforcement: ["settings.config.token.check.label", "Strict token check"],
92
104
  sessionCreationGraceMs: ["settings.config.token.grace.label", "Grace period after sign-in"],
93
- maxFailedLogins: ["settings.config.failed.lockout.label", "Temporary IP lockout after"],
105
+ maxFailedLogins: ["settings.config.failed.lockout.label", "Lock an IP address after"],
106
+ maxFailedLoginsPerAccount: ["settings.config.failed.account.label", "Lock an account after"],
107
+ lockoutWindowMinutes: ["settings.config.failed.window.label", "Count failed sign-ins within"],
108
+ lockoutDurationMinutes: ["settings.config.failed.duration.label", "Lock for"],
109
+ lockoutTrustedAddresses: ["settings.config.failed.trusted.label", "Trusted addresses"],
110
+ lockoutNotifyUser: [
111
+ "settings.config.failed.notify.label",
112
+ "Email the user when their account is locked"
113
+ ],
114
+ recordUserSignInEvents: [
115
+ "settings.config.failed.record.label",
116
+ "Record failed and refused sign-ins"
117
+ ],
118
+ maxSessionsPerUser: ["settings.config.sessionLimit.max.label", "Open sessions per user"],
119
+ sessionLimitPolicy: ["settings.config.sessionLimit.policy.label", "When the limit is reached"],
120
+ endOtherSessionsOnPasswordChange: [
121
+ "settings.config.passwordChange.label",
122
+ "End other sessions after a password change"
123
+ ],
124
+ roleRules: ["settings.roleRules.title", "Different rules for some roles"],
94
125
  trustedProxies: ["settings.config.clientIp.trustProxy.label", "Trust proxy headers"],
95
126
  blockSuspiciousSessions: [
96
127
  "settings.config.suspicious.reject.label",
@@ -126,6 +157,10 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
126
157
  "settings.config.adminActivity.anonymize.label",
127
158
  "Anonymise the last part of IP addresses"
128
159
  ],
160
+ securityLogGeoLookup: [
161
+ "settings.config.adminActivity.geoLookup.label",
162
+ "Look up the location of security events"
163
+ ],
129
164
  securityLogRetentionDays: [
130
165
  "settings.config.adminActivity.retention.label",
131
166
  "Keep security events for"
@@ -620,6 +655,13 @@ function useOptionLabels() {
620
655
  }
621
656
  const IntroText = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral600", tag: "p", children });
622
657
  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 });
658
+ const ProtectedNotice = () => {
659
+ const { t } = useSettingsTranslate();
660
+ return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t(
661
+ "settings.config.protected.notice",
662
+ "Read-only for your role: changing this needs the “Change protected settings” permission."
663
+ ) });
664
+ };
623
665
  const RequiresGeolocation = () => {
624
666
  const { t } = useSettingsTranslate();
625
667
  return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
@@ -725,6 +767,441 @@ const TermList = ({ items, label, code = false }) => /* @__PURE__ */ jsxRuntime.
725
767
  ) }),
726
768
  /* @__PURE__ */ jsxRuntime.jsx("dd", { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral700", children: item.description }) })
727
769
  ] }, item.id)) });
770
+ const POLICY_FORM_DEFAULTS = Object.freeze({
771
+ maxFailedLoginsPerAccount: 0,
772
+ lockoutWindowMinutes: 15,
773
+ lockoutDurationMinutes: 15,
774
+ lockoutTrustedAddresses: Object.freeze([]),
775
+ lockoutNotifyUser: false,
776
+ recordUserSignInEvents: true,
777
+ maxSessionsPerUser: 0,
778
+ sessionLimitPolicy: "end-oldest",
779
+ endOtherSessionsOnPasswordChange: true,
780
+ roleRules: Object.freeze([])
781
+ });
782
+ const POLICY_RANGES = Object.freeze({
783
+ maxFailedLoginsPerAccount: Object.freeze({ min: 0, max: 100 }),
784
+ lockoutWindowMinutes: Object.freeze({ min: 1, max: 1440 }),
785
+ lockoutDurationMinutes: Object.freeze({ min: 1, max: 10080 }),
786
+ maxSessionsPerUser: Object.freeze({ min: 0, max: 100 })
787
+ });
788
+ const ROLE_RULE_RANGES = Object.freeze({
789
+ maxSessionsPerUser: Object.freeze({ min: 0, max: 100 }),
790
+ inactivityTimeout: Object.freeze({ min: 1, max: 1440 }),
791
+ maxFailedLoginsPerAccount: Object.freeze({ min: 0, max: 100 })
792
+ });
793
+ const ROLE_RULE_FIELDS = Object.freeze(Object.keys(ROLE_RULE_RANGES));
794
+ const MAX_TRUSTED_ADDRESSES = 100;
795
+ const message$1 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
796
+ function validateWholeNumber(value, { min, max }) {
797
+ if (value === void 0 || value === null || value === "") {
798
+ return message$1("settings.validation.required", "Enter a value.");
799
+ }
800
+ const number = Number(value);
801
+ if (!Number.isInteger(number) || number < min || number > max) {
802
+ return message$1("settings.validation.range", "Enter a whole number from {min} to {max}.", {
803
+ min,
804
+ max
805
+ });
806
+ }
807
+ return null;
808
+ }
809
+ const IPV4 = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
810
+ const IPV6_CHARS = /^[0-9a-f:.]{2,45}$/i;
811
+ function isTrustedAddressLine(line) {
812
+ const value = String(line || "").trim();
813
+ if (!value || value.length > 64) return false;
814
+ const [address, prefix, extra] = value.split("/");
815
+ if (extra !== void 0) return false;
816
+ const v4 = IPV4.test(address);
817
+ const v6 = !v4 && address.includes(":") && IPV6_CHARS.test(address) && !address.includes(":::");
818
+ if (!v4 && !v6) return false;
819
+ if (prefix === void 0) return true;
820
+ if (!/^\d{1,3}$/.test(prefix)) return false;
821
+ return Number(prefix) <= (v4 ? 32 : 128);
822
+ }
823
+ function parseTrustedAddressText(text) {
824
+ return String(text || "").split(/[\n,]/).map((line) => line.trim()).filter(Boolean);
825
+ }
826
+ function formatTrustedAddressText(list) {
827
+ return Array.isArray(list) ? list.join("\n") : "";
828
+ }
829
+ function validatePolicyFields(settings) {
830
+ const source = settings || {};
831
+ const errors = {};
832
+ for (const [key, range] of Object.entries(POLICY_RANGES)) {
833
+ if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
834
+ const error = validateWholeNumber(source[key], range);
835
+ if (error) errors[key] = error;
836
+ }
837
+ const entries = Array.isArray(source.lockoutTrustedAddresses) ? source.lockoutTrustedAddresses : [];
838
+ if (entries.length > MAX_TRUSTED_ADDRESSES) {
839
+ errors.lockoutTrustedAddresses = message$1(
840
+ "settings.validation.trustedTooMany",
841
+ "Enter at most {max} addresses.",
842
+ { max: MAX_TRUSTED_ADDRESSES }
843
+ );
844
+ } else {
845
+ const invalid = entries.find((entry) => !isTrustedAddressLine(entry));
846
+ if (invalid !== void 0) {
847
+ errors.lockoutTrustedAddresses = message$1(
848
+ "settings.validation.trustedAddress",
849
+ '"{value}" is not an IP address or CIDR range. Use for example 192.0.2.10 or 192.0.2.0/24.',
850
+ { value: String(invalid).slice(0, 64) }
851
+ );
852
+ }
853
+ }
854
+ return errors;
855
+ }
856
+ function validateRoleRule(draft, takenRoles = []) {
857
+ const errors = {};
858
+ if (!draft?.role) {
859
+ errors.role = message$1("settings.roleRules.validation.role", "Choose a role.");
860
+ } else if (takenRoles.includes(draft.role)) {
861
+ errors.role = message$1(
862
+ "settings.roleRules.validation.duplicate",
863
+ "This role already has a rule."
864
+ );
865
+ }
866
+ let values = 0;
867
+ for (const field of ROLE_RULE_FIELDS) {
868
+ const value = draft?.[field];
869
+ if (value === void 0 || value === null || value === "") continue;
870
+ const error = validateWholeNumber(value, ROLE_RULE_RANGES[field]);
871
+ if (error) errors[field] = error;
872
+ else values += 1;
873
+ }
874
+ if (values === 0 && !ROLE_RULE_FIELDS.some((field) => errors[field])) {
875
+ errors.form = message$1(
876
+ "settings.roleRules.validation.empty",
877
+ "Set at least one value. Empty fields use the general setting."
878
+ );
879
+ }
880
+ return errors;
881
+ }
882
+ function toRoleRule(draft) {
883
+ const rule = { role: draft.role };
884
+ for (const field of ROLE_RULE_FIELDS) {
885
+ const value = draft[field];
886
+ rule[field] = value === void 0 || value === null || value === "" ? null : Number(value);
887
+ }
888
+ return rule;
889
+ }
890
+ function upsertRoleRule(rules, rule, previousRole = null) {
891
+ const list = Array.isArray(rules) ? rules : [];
892
+ const key = previousRole || rule.role;
893
+ const index2 = list.findIndex((candidate) => candidate.role === key);
894
+ if (index2 === -1) return [...list, rule];
895
+ return list.map((candidate, position) => position === index2 ? rule : candidate);
896
+ }
897
+ function removeRoleRule(rules, role) {
898
+ return (Array.isArray(rules) ? rules : []).filter((rule) => rule.role !== role);
899
+ }
900
+ function sortLocks(locks) {
901
+ return (Array.isArray(locks) ? locks : []).slice().sort((a, b) => {
902
+ const until = Date.parse(b.until) - Date.parse(a.until);
903
+ return Number.isFinite(until) && until !== 0 ? until : String(a.id).localeCompare(b.id);
904
+ });
905
+ }
906
+ const TABLE_MIN_WIDTH$1 = 640;
907
+ const keepActionKeys$1 = (event) => {
908
+ if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
909
+ };
910
+ const EMPTY_DRAFT = Object.freeze({
911
+ role: "",
912
+ maxSessionsPerUser: void 0,
913
+ inactivityTimeout: void 0,
914
+ maxFailedLoginsPerAccount: void 0
915
+ });
916
+ const RuleValue = ({ value, format }) => {
917
+ const { t } = useSettingsTranslate();
918
+ if (value === null || value === void 0) {
919
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.roleRules.general", "General setting") });
920
+ }
921
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: format(value) });
922
+ };
923
+ const RoleRulesSection = ({ form }) => {
924
+ const { t, tError } = useSettingsTranslate();
925
+ const { get } = StrapiAdmin.useFetchClient();
926
+ const { settings, handleChange } = form;
927
+ const locked = form.canChangeProtected === false;
928
+ const rules = Array.isArray(settings.roleRules) ? settings.roleRules : [];
929
+ const [roles, setRoles] = react.useState(null);
930
+ const [rolesError, setRolesError] = react.useState(false);
931
+ const [dialog, setDialog] = react.useState(null);
932
+ const [draft, setDraft] = react.useState(EMPTY_DRAFT);
933
+ const [showErrors, setShowErrors] = react.useState(false);
934
+ const addRef = react.useRef(null);
935
+ const returnFocusRef = react.useRef(null);
936
+ const [widthRef, width] = dashboardModel.useElementWidth();
937
+ react.useEffect(() => {
938
+ let active = true;
939
+ get(`/${index.pluginId}/roles`).then(({ data }) => {
940
+ if (!active) return;
941
+ if (!Array.isArray(data?.data)) throw new Error("Invalid role list");
942
+ setRoles(data.data);
943
+ }).catch((err) => {
944
+ if (!active || index.isCancelledRequest(err)) return;
945
+ index.logSafeAdminError("roles", err);
946
+ setRolesError(true);
947
+ });
948
+ return () => {
949
+ active = false;
950
+ };
951
+ }, [get]);
952
+ const roleName = (documentId) => roles?.find((role) => role.documentId === documentId)?.name || t("settings.roleRules.unknownRole", "Removed role");
953
+ const minutes = (value) => t("settings.roleRules.minutes", "{count, plural, one {# minute} other {# minutes}}", {
954
+ count: value
955
+ });
956
+ const sessions = (value) => value === 0 ? t("settings.roleRules.noLimit", "No limit") : t("settings.roleRules.sessions", "{count, plural, one {# session} other {# sessions}}", {
957
+ count: value
958
+ });
959
+ const failures = (value) => value === 0 ? t("settings.roleRules.noAccountLock", "Off") : t("settings.roleRules.failures", "{count, plural, one {# failure} other {# failures}}", {
960
+ count: value
961
+ });
962
+ const open = (rule, trigger) => {
963
+ returnFocusRef.current = trigger || addRef.current;
964
+ setShowErrors(false);
965
+ setDraft(
966
+ rule ? {
967
+ role: rule.role,
968
+ maxSessionsPerUser: rule.maxSessionsPerUser ?? void 0,
969
+ inactivityTimeout: rule.inactivityTimeout ?? void 0,
970
+ maxFailedLoginsPerAccount: rule.maxFailedLoginsPerAccount ?? void 0
971
+ } : EMPTY_DRAFT
972
+ );
973
+ setDialog({ editing: rule ? rule.role : null });
974
+ };
975
+ const close = () => {
976
+ setDialog(null);
977
+ window.requestAnimationFrame?.(() => {
978
+ const target = returnFocusRef.current?.isConnected ? returnFocusRef.current : addRef.current;
979
+ target?.focus?.();
980
+ });
981
+ };
982
+ const taken = rules.map((rule) => rule.role).filter((role) => role !== dialog?.editing);
983
+ const draftErrors = validateRoleRule(draft, taken);
984
+ const submit = () => {
985
+ if (Object.keys(draftErrors).length > 0) {
986
+ setShowErrors(true);
987
+ return;
988
+ }
989
+ handleChange("roleRules", upsertRoleRule(rules, toRoleRule(draft), dialog?.editing));
990
+ close();
991
+ };
992
+ const fieldError = (key) => showErrors ? tError(draftErrors[key]) : void 0;
993
+ const availableRoles = (roles || []).filter((role) => !taken.includes(role.documentId));
994
+ const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
995
+ const actions = (rule) => {
996
+ const name = roleName(rule.role);
997
+ return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys$1, children: [
998
+ /* @__PURE__ */ jsxRuntime.jsx(
999
+ designSystem.IconButton,
1000
+ {
1001
+ variant: "ghost",
1002
+ disabled: locked,
1003
+ label: t("settings.roleRules.edit", "Edit the rule for {role}", { role: name }),
1004
+ onClick: (event) => open(rule, event.currentTarget),
1005
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
1006
+ }
1007
+ ),
1008
+ /* @__PURE__ */ jsxRuntime.jsx(
1009
+ designSystem.IconButton,
1010
+ {
1011
+ variant: "ghost",
1012
+ disabled: locked,
1013
+ label: t("settings.roleRules.remove", "Remove the rule for {role}", { role: name }),
1014
+ onClick: () => {
1015
+ handleChange("roleRules", removeRoleRule(rules, rule.role));
1016
+ window.requestAnimationFrame?.(() => addRef.current?.focus?.());
1017
+ },
1018
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
1019
+ }
1020
+ )
1021
+ ] });
1022
+ };
1023
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1024
+ AdvancedSection,
1025
+ {
1026
+ label: t("settings.roleRules.title", "Different rules for some roles"),
1027
+ hasError: Object.keys(form.errors || {}).some((key) => key.startsWith("roleRules")),
1028
+ children: [
1029
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
1030
+ "settings.roleRules.intro",
1031
+ "Give a Users & Permissions role its own session limit, inactivity timeout or account lockout. Empty values use the general setting. The overview still counts sessions as idle by the general timeout."
1032
+ ) }),
1033
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
1034
+ rolesError ? /* @__PURE__ */ jsxRuntime.jsx(
1035
+ index.PersistentAlert,
1036
+ {
1037
+ variant: "warning",
1038
+ closeLabel: t("common.close", "Close"),
1039
+ title: t("settings.roleRules.rolesError", "Roles could not be loaded."),
1040
+ children: t(
1041
+ "settings.roleRules.rolesErrorBody",
1042
+ "Existing rules still apply. Reload the page to add or edit rules."
1043
+ )
1044
+ }
1045
+ ) : null,
1046
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: widthRef, children: rules.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", tag: "p", children: t(
1047
+ "settings.roleRules.empty",
1048
+ "No role has its own rules. Every role uses the general settings."
1049
+ ) }) : asTable ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", "data-role-rules-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: rules.length + 1, children: [
1050
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
1051
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.role", "Role") }) }),
1052
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.sessions", "Session limit") }) }),
1053
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.idle", "Inactivity timeout") }) }),
1054
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.lockout", "Account lockout") }) }),
1055
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("settings.roleRules.col.actions", "Actions") }) })
1056
+ ] }) }),
1057
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-role-rule": rule.role, children: [
1058
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: roleName(rule.role) }) }),
1059
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.maxSessionsPerUser, format: sessions }) }),
1060
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.inactivityTimeout, format: minutes }) }),
1061
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.maxFailedLoginsPerAccount, format: failures }) }),
1062
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: actions(rule) })
1063
+ ] }, rule.role)) })
1064
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", children: rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsx(
1065
+ designSystem.Box,
1066
+ {
1067
+ tag: "li",
1068
+ padding: 4,
1069
+ hasRadius: true,
1070
+ borderColor: "neutral150",
1071
+ "data-role-rule": rule.role,
1072
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
1073
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
1074
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: roleName(rule.role) }),
1075
+ [
1076
+ [
1077
+ "settings.roleRules.col.sessions",
1078
+ "Session limit",
1079
+ rule.maxSessionsPerUser,
1080
+ sessions
1081
+ ],
1082
+ [
1083
+ "settings.roleRules.col.idle",
1084
+ "Inactivity timeout",
1085
+ rule.inactivityTimeout,
1086
+ minutes
1087
+ ],
1088
+ [
1089
+ "settings.roleRules.col.lockout",
1090
+ "Account lockout",
1091
+ rule.maxFailedLoginsPerAccount,
1092
+ failures
1093
+ ]
1094
+ ].map(([id, label, value, format]) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.roleRules.line", "{label}: {value}", {
1095
+ label: t(id, label),
1096
+ value: value === null || value === void 0 ? t("settings.roleRules.general", "General setting") : format(value)
1097
+ }) }, id))
1098
+ ] }),
1099
+ actions(rule)
1100
+ ] })
1101
+ },
1102
+ rule.role
1103
+ )) }) }),
1104
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, wrap: "wrap", alignItems: "center", children: [
1105
+ /* @__PURE__ */ jsxRuntime.jsx(
1106
+ designSystem.Button,
1107
+ {
1108
+ ref: addRef,
1109
+ variant: "secondary",
1110
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
1111
+ disabled: locked || roles !== null && availableRoles.length === 0 && !dialog,
1112
+ onClick: () => open(null, addRef.current),
1113
+ children: t("settings.roleRules.add", "Add rule")
1114
+ }
1115
+ ),
1116
+ roles !== null && roles.length > 0 && availableRoles.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", "data-role-rules-full": "", children: t(
1117
+ "settings.roleRules.allRoles",
1118
+ "Every role already has a rule. Edit a rule to change it."
1119
+ ) }) : null
1120
+ ] }),
1121
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: Boolean(dialog), onOpenChange: (next) => next ? null : close(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { "aria-describedby": void 0, children: [
1122
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: dialog?.editing ? t("settings.roleRules.dialog.editTitle", "Edit the rule for {role}", {
1123
+ role: roleName(dialog.editing)
1124
+ }) : t("settings.roleRules.dialog.addTitle", "Add a rule for a role") }) }),
1125
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 5, children: [
1126
+ /* @__PURE__ */ jsxRuntime.jsx(
1127
+ FormField,
1128
+ {
1129
+ id: "role-rule-role",
1130
+ name: "role",
1131
+ label: t("settings.roleRules.col.role", "Role"),
1132
+ error: fieldError("role"),
1133
+ required: true,
1134
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1135
+ designSystem.SingleSelect,
1136
+ {
1137
+ value: draft.role || void 0,
1138
+ placeholder: t("settings.roleRules.dialog.rolePlaceholder", "Choose a role"),
1139
+ onChange: (value) => setDraft((previous) => ({ ...previous, role: value })),
1140
+ children: (roles || []).filter(
1141
+ (role) => role.documentId === draft.role || !taken.includes(role.documentId)
1142
+ ).map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: role.documentId, children: role.name }, role.documentId))
1143
+ }
1144
+ )
1145
+ }
1146
+ ),
1147
+ [
1148
+ [
1149
+ "maxSessionsPerUser",
1150
+ "role-rule-sessions",
1151
+ t("settings.config.sessionLimit.max.label", "Open sessions per user"),
1152
+ t("settings.roleRules.dialog.sessionsHint", "0 means no limit for this role."),
1153
+ t("settings.roleRules.dialog.sessionsSuffix", "sessions")
1154
+ ],
1155
+ [
1156
+ "inactivityTimeout",
1157
+ "role-rule-idle",
1158
+ t("settings.config.sessions.inactivity.label", "Inactivity timeout"),
1159
+ t("settings.roleRules.dialog.idleHint", "From 1 to 1440 minutes."),
1160
+ t("settings.config.failed.minutes.suffix", "minutes")
1161
+ ],
1162
+ [
1163
+ "maxFailedLoginsPerAccount",
1164
+ "role-rule-lockout",
1165
+ t("settings.config.failed.account.label", "Lock an account after"),
1166
+ t(
1167
+ "settings.roleRules.dialog.lockoutHint",
1168
+ "0 turns the account lockout off for this role."
1169
+ ),
1170
+ t("settings.config.failed.lockout.suffix", "failed sign-ins")
1171
+ ]
1172
+ ].map(([key, id, label, hint, suffix]) => /* @__PURE__ */ jsxRuntime.jsx(
1173
+ FormField,
1174
+ {
1175
+ id,
1176
+ name: key,
1177
+ label,
1178
+ description: `${hint} ${t("settings.roleRules.dialog.emptyHint", "Leave empty to use the general setting.")}`,
1179
+ suffix,
1180
+ error: fieldError(key),
1181
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1182
+ designSystem.NumberInput,
1183
+ {
1184
+ value: draft[key],
1185
+ onValueChange: (value) => setDraft((previous) => ({ ...previous, [key]: value })),
1186
+ min: ROLE_RULE_RANGES[key].min,
1187
+ max: ROLE_RULE_RANGES[key].max,
1188
+ step: 1
1189
+ }
1190
+ )
1191
+ },
1192
+ key
1193
+ )),
1194
+ showErrors && draftErrors.form ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", tag: "p", role: "alert", children: tError(draftErrors.form) }) : null
1195
+ ] }) }),
1196
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
1197
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.cancel", "Cancel") }) }),
1198
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: submit, children: dialog?.editing ? t("settings.roleRules.dialog.apply", "Apply") : t("settings.roleRules.dialog.add", "Add rule") })
1199
+ ] })
1200
+ ] }) })
1201
+ ]
1202
+ }
1203
+ );
1204
+ };
728
1205
  const REJECTION_REASONS = [
729
1206
  ["logout", "settings.config.rejected.reason.logout", "The user signed out."],
730
1207
  [
@@ -755,10 +1232,12 @@ const formatReasonCodes = (locale) => {
755
1232
  }
756
1233
  };
757
1234
  const SessionsTab = ({ form }) => {
758
- const { t, locale } = useSettingsTranslate();
1235
+ const { t, tError, locale } = useSettingsTranslate();
759
1236
  const units = useOptionLabels();
760
1237
  const encryptionKeyDraft = useEncryptionKeyDraft();
761
- const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed } = form;
1238
+ const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed, errors } = form;
1239
+ const sessionLimit = Number(settings.maxSessionsPerUser) || 0;
1240
+ const locked = form.canChangeProtected === false;
762
1241
  const lastSeenTooSlow = Number(settings.lastSeenRateLimit) * 2 > Number(settings.inactivityTimeout) * 60;
763
1242
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
764
1243
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
@@ -949,6 +1428,127 @@ const SessionsTab = ({ form }) => {
949
1428
  ]
950
1429
  }
951
1430
  ),
1431
+ /* @__PURE__ */ jsxRuntime.jsxs(
1432
+ SectionCard.SectionCard,
1433
+ {
1434
+ id: "session-limit",
1435
+ title: t("settings.config.sessionLimit.title", "Concurrent sessions"),
1436
+ subtitle: t(
1437
+ "settings.config.sessionLimit.intro",
1438
+ "Limits how many sessions one user can have open at the same time."
1439
+ ),
1440
+ children: [
1441
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
1442
+ /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
1443
+ FormField,
1444
+ {
1445
+ id: "max-sessions-per-user",
1446
+ name: "maxSessionsPerUser",
1447
+ label: t("settings.config.sessionLimit.max.label", "Open sessions per user"),
1448
+ description: t(
1449
+ "settings.config.sessionLimit.max.hint",
1450
+ "0 means no limit. Sessions that are idle or past their maximum age do not count."
1451
+ ),
1452
+ suffix: t("settings.roleRules.dialog.sessionsSuffix", "sessions"),
1453
+ error: tError(errors.maxSessionsPerUser),
1454
+ required: true,
1455
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1456
+ designSystem.NumberInput,
1457
+ {
1458
+ value: settings.maxSessionsPerUser,
1459
+ onValueChange: (value) => handleChange("maxSessionsPerUser", value ?? ""),
1460
+ disabled: locked,
1461
+ min: POLICY_RANGES.maxSessionsPerUser.min,
1462
+ max: POLICY_RANGES.maxSessionsPerUser.max,
1463
+ step: 1
1464
+ },
1465
+ form.draftVersion
1466
+ )
1467
+ }
1468
+ ) }),
1469
+ sessionLimit > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-session-limit-policy": "", children: [
1470
+ /* @__PURE__ */ jsxRuntime.jsx(
1471
+ designSystem.Typography,
1472
+ {
1473
+ id: "session-limit-policy-label",
1474
+ variant: "pi",
1475
+ fontWeight: "bold",
1476
+ tag: "div",
1477
+ textColor: "neutral800",
1478
+ children: t("settings.config.sessionLimit.policy.label", "When the limit is reached")
1479
+ }
1480
+ ),
1481
+ /* @__PURE__ */ jsxRuntime.jsxs(
1482
+ designSystem.Radio.Group,
1483
+ {
1484
+ "aria-labelledby": "session-limit-policy-label",
1485
+ value: settings.sessionLimitPolicy || "end-oldest",
1486
+ disabled: locked,
1487
+ onValueChange: (value) => handleChange("sessionLimitPolicy", value),
1488
+ children: [
1489
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "end-oldest", children: t("settings.config.sessionLimit.policy.endOldest", "End the oldest session") }),
1490
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "refuse", children: t("settings.config.sessionLimit.policy.refuse", "Refuse the new sign-in") })
1491
+ ]
1492
+ }
1493
+ ),
1494
+ settings.sessionLimitPolicy === "refuse" ? /* @__PURE__ */ jsxRuntime.jsx(
1495
+ designSystem.Alert,
1496
+ {
1497
+ variant: "warning",
1498
+ closeLabel: t("common.close", "Close"),
1499
+ title: t(
1500
+ "settings.config.sessionLimit.refuse.title",
1501
+ "Users can lock themselves out"
1502
+ ),
1503
+ children: t(
1504
+ "settings.config.sessionLimit.refuse.body",
1505
+ "A user who reaches the limit cannot sign in on a new device until another session ends or times out. The app receives 403 with the code SESSION_LIMIT_REACHED."
1506
+ )
1507
+ }
1508
+ ) : null
1509
+ ] }) : null
1510
+ ]
1511
+ }
1512
+ ),
1513
+ /* @__PURE__ */ jsxRuntime.jsxs(
1514
+ SectionCard.SectionCard,
1515
+ {
1516
+ id: "password-change",
1517
+ title: t("settings.config.passwordChange.title", "Password change"),
1518
+ children: [
1519
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
1520
+ /* @__PURE__ */ jsxRuntime.jsx(
1521
+ SettingsToggleRow,
1522
+ {
1523
+ id: "end-other-sessions-on-password-change",
1524
+ title: t(
1525
+ "settings.config.passwordChange.label",
1526
+ "End other sessions after a password change"
1527
+ ),
1528
+ description: t(
1529
+ "settings.config.passwordChange.hint",
1530
+ "When a user changes their password, every other session of that user ends. The session that made the change stays. A password reset always ends the other sessions."
1531
+ ),
1532
+ checked: settings.endOtherSessionsOnPasswordChange === true,
1533
+ disabled: locked,
1534
+ onChange: (checked) => handleChange("endOtherSessionsOnPasswordChange", checked)
1535
+ }
1536
+ )
1537
+ ]
1538
+ }
1539
+ ),
1540
+ /* @__PURE__ */ jsxRuntime.jsx(
1541
+ SectionCard.SectionCard,
1542
+ {
1543
+ id: "role-rules",
1544
+ title: t("settings.roleRules.cardTitle", "Roles"),
1545
+ subtitle: t(
1546
+ "settings.roleRules.cardIntro",
1547
+ "Optional. Most installations need no role rules."
1548
+ ),
1549
+ children: /* @__PURE__ */ jsxRuntime.jsx(RoleRulesSection, { form })
1550
+ }
1551
+ ),
952
1552
  /* @__PURE__ */ jsxRuntime.jsxs(
953
1553
  SectionCard.SectionCard,
954
1554
  {
@@ -1002,7 +1602,12 @@ function areSettingsEqual(left, right) {
1002
1602
  (key, index2) => key === rightKeys[index2] && areSettingsEqual(left[key], right[key])
1003
1603
  );
1004
1604
  }
1005
- const TEMPLATE_KEYS = Object.freeze(["suspiciousLogin", "newLocation", "vpnProxy"]);
1605
+ const TEMPLATE_KEYS = Object.freeze([
1606
+ "suspiciousLogin",
1607
+ "newLocation",
1608
+ "vpnProxy",
1609
+ "accountLocked"
1610
+ ]);
1006
1611
  const TEMPLATE_LIMITS = Object.freeze({ subject: 200, html: 1e4, text: 5e3 });
1007
1612
  const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
1008
1613
  "{{user.email}}": {
@@ -1052,6 +1657,14 @@ const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
1052
1657
  "{{reason.securityScore}}": {
1053
1658
  messageId: "settings.email.templates.variable.securityScore",
1054
1659
  defaultMessage: "Security score (0 to 100)"
1660
+ },
1661
+ "{{lock.minutes}}": {
1662
+ messageId: "settings.email.templates.variable.lockMinutes",
1663
+ defaultMessage: "Lock duration in minutes"
1664
+ },
1665
+ "{{lock.until}}": {
1666
+ messageId: "settings.email.templates.variable.lockUntil",
1667
+ defaultMessage: "Time the lock ends (UTC)"
1055
1668
  }
1056
1669
  });
1057
1670
  const TEMPLATE_VARIABLES = Object.freeze({
@@ -1089,7 +1702,8 @@ const TEMPLATE_VARIABLES = Object.freeze({
1089
1702
  "{{session.userAgent}}",
1090
1703
  "{{reason.isVpn}}",
1091
1704
  "{{reason.isProxy}}"
1092
- ]
1705
+ ],
1706
+ accountLocked: ["{{user.email}}", "{{user.username}}", "{{lock.minutes}}", "{{lock.until}}"]
1093
1707
  });
1094
1708
  const TEMPLATE_PREVIEW_VALUES = Object.freeze({
1095
1709
  "{{user.email}}": "jane.doe@example.com",
@@ -1103,7 +1717,9 @@ const TEMPLATE_PREVIEW_VALUES = Object.freeze({
1103
1717
  "{{reason.isVpn}}": "true",
1104
1718
  "{{reason.isProxy}}": "false",
1105
1719
  "{{reason.isThreat}}": "false",
1106
- "{{reason.securityScore}}": "35"
1720
+ "{{reason.securityScore}}": "35",
1721
+ "{{lock.minutes}}": "15",
1722
+ "{{lock.until}}": "Fri, 06 Nov 2026 09:56:00 GMT"
1107
1723
  });
1108
1724
  function updateEmailTemplate(templates, templateKey, field, value) {
1109
1725
  return { ...templates, [templateKey]: { ...templates[templateKey], [field]: value } };
@@ -1364,6 +1980,28 @@ Login Details:
1364
1980
  - IP Address: {{session.ipAddress}}
1365
1981
  - Location: {{geo.city}}, {{geo.country}}
1366
1982
  - VPN: {{reason.isVpn}}, Proxy: {{reason.isProxy}}`
1983
+ },
1984
+ // Same default as server/src/services/notifications.js (4.17).
1985
+ accountLocked: {
1986
+ subject: "Your account was locked after failed sign-ins",
1987
+ html: `<html>
1988
+ <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
1989
+ <div style="max-width: 600px; margin: 0 auto; padding: 20px;">
1990
+ <h2>Your account was temporarily locked</h2>
1991
+ <p>Hello {{user.username}},</p>
1992
+ <p>There were several failed sign-in attempts for your account. To protect it, sign-in is locked for {{lock.minutes}} minutes, until {{lock.until}}.</p>
1993
+ <p>If these attempts were not yours, change your password after the lock ends.</p>
1994
+ <p style="color: #666; font-size: 12px;">This is an automated security notification.</p>
1995
+ </div>
1996
+ </body>
1997
+ </html>`,
1998
+ text: `Your account was temporarily locked
1999
+
2000
+ Hello {{user.username}},
2001
+
2002
+ There were several failed sign-in attempts for your account. To protect it, sign-in is locked for {{lock.minutes}} minutes, until {{lock.until}}.
2003
+
2004
+ If these attempts were not yours, change your password after the lock ends.`
1367
2005
  }
1368
2006
  });
1369
2007
  function fillMissingTemplates(templates) {
@@ -1402,8 +2040,13 @@ const SETTINGS_DEFAULTS = Object.freeze({
1402
2040
  alertOnNewLocation: true,
1403
2041
  alertOnVpnProxy: true,
1404
2042
  enableWebhooks: false,
1405
- discordWebhookUrl: "",
1406
- slackWebhookUrl: "",
2043
+ // Webhook URLs are never returned (4.17): the API sends hasDiscordWebhook /
2044
+ // hasSlackWebhook and a hint; a URL key exists in the draft only while the
2045
+ // admin replaces (text) or removes ('') it.
2046
+ hasDiscordWebhook: false,
2047
+ hasSlackWebhook: false,
2048
+ discordWebhookHint: null,
2049
+ slackWebhookHint: null,
1407
2050
  enableGeofencing: false,
1408
2051
  allowedCountries: [],
1409
2052
  blockedCountries: [],
@@ -1414,8 +2057,11 @@ const SETTINGS_DEFAULTS = Object.freeze({
1414
2057
  adminContentActivity: false,
1415
2058
  securityLogStoreIp: true,
1416
2059
  securityLogAnonymizeIp: false,
1417
- securityLogRetentionDays: 90
2060
+ securityLogGeoLookup: false,
2061
+ securityLogRetentionDays: 90,
2062
+ ...POLICY_FORM_DEFAULTS
1418
2063
  });
2064
+ const WRITE_ONLY_SETTINGS_KEYS = Object.freeze(["discordWebhookUrl", "slackWebhookUrl"]);
1419
2065
  const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
1420
2066
  const WEBHOOK_HOSTS = Object.freeze({
1421
2067
  discordWebhookUrl: ["discord.com", "discordapp.com"],
@@ -1436,6 +2082,8 @@ function normalizeSettings(loaded) {
1436
2082
  ...loaded,
1437
2083
  allowedCountries: Array.isArray(loaded.allowedCountries) ? loaded.allowedCountries : [],
1438
2084
  blockedCountries: Array.isArray(loaded.blockedCountries) ? loaded.blockedCountries : [],
2085
+ lockoutTrustedAddresses: Array.isArray(loaded.lockoutTrustedAddresses) ? loaded.lockoutTrustedAddresses : [],
2086
+ roleRules: Array.isArray(loaded.roleRules) ? loaded.roleRules : [],
1439
2087
  emailTemplates: fillMissingTemplates(loaded.emailTemplates)
1440
2088
  };
1441
2089
  }
@@ -1485,6 +2133,7 @@ function validateSettings(settings) {
1485
2133
  const source = settings || {};
1486
2134
  const maxFailed = validateMaxFailedLogins(source.maxFailedLogins);
1487
2135
  if (maxFailed) errors.maxFailedLogins = maxFailed;
2136
+ Object.assign(errors, validatePolicyFields(source));
1488
2137
  if (!isAllowedWebhookUrl(source.discordWebhookUrl, WEBHOOK_HOSTS.discordWebhookUrl)) {
1489
2138
  errors.discordWebhookUrl = message(
1490
2139
  "settings.validation.webhookDiscord",
@@ -1525,9 +2174,315 @@ function validateSettings(settings) {
1525
2174
  function getAdjustedFields(submitted, stored, previous) {
1526
2175
  const source = submitted || {};
1527
2176
  return Object.keys(source).filter(
1528
- (key) => !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
2177
+ (key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
1529
2178
  );
1530
2179
  }
2180
+ const TABLE_MIN_WIDTH = 640;
2181
+ const keepActionKeys = (event) => {
2182
+ if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2183
+ };
2184
+ const LockTarget = ({ lock }) => {
2185
+ const { t } = useSettingsTranslate();
2186
+ if (lock.kind === "ip") {
2187
+ return /* @__PURE__ */ jsxRuntime.jsx(
2188
+ designSystem.Typography,
2189
+ {
2190
+ variant: "omega",
2191
+ textColor: "neutral800",
2192
+ tag: "p",
2193
+ style: { overflowWrap: "anywhere" },
2194
+ children: lock.ip || t("settings.lockouts.ipHidden", "IP address not stored")
2195
+ }
2196
+ );
2197
+ }
2198
+ if (!lock.user) {
2199
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.lockouts.unknownAccount", "Account that does not exist") });
2200
+ }
2201
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, width: "100%", children: [
2202
+ /* @__PURE__ */ jsxRuntime.jsx(
2203
+ designSystem.Typography,
2204
+ {
2205
+ variant: "omega",
2206
+ fontWeight: "semiBold",
2207
+ textColor: "neutral800",
2208
+ tag: "p",
2209
+ style: { overflowWrap: "anywhere" },
2210
+ children: lock.user.username || lock.user.email
2211
+ }
2212
+ ),
2213
+ lock.user.email && lock.user.username ? /* @__PURE__ */ jsxRuntime.jsx(
2214
+ designSystem.Typography,
2215
+ {
2216
+ variant: "pi",
2217
+ textColor: "neutral600",
2218
+ tag: "p",
2219
+ style: { overflowWrap: "anywhere" },
2220
+ children: lock.user.email
2221
+ }
2222
+ ) : null
2223
+ ] });
2224
+ };
2225
+ const KindBadge = ({ kind }) => {
2226
+ const { t } = useSettingsTranslate();
2227
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: kind === "ip" ? t("settings.lockouts.kind.ip", "IP address") : t("settings.lockouts.kind.account", "Account") });
2228
+ };
2229
+ const lockName = (lock, t) => {
2230
+ if (lock.kind === "ip")
2231
+ return lock.ip || t("settings.lockouts.ipHidden", "IP address not stored");
2232
+ if (lock.user) return lock.user.username || lock.user.email;
2233
+ return t("settings.lockouts.unknownAccount", "Account that does not exist");
2234
+ };
2235
+ const LockedNowCard = () => {
2236
+ const { t } = useSettingsTranslate();
2237
+ const { get, post } = StrapiAdmin.useFetchClient();
2238
+ const { toggleNotification } = StrapiAdmin.useNotification();
2239
+ const { formatDate } = index.useSessionFormatters();
2240
+ const {
2241
+ isLoading: permissionsLoading,
2242
+ allowedActions: { canUnlock }
2243
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.lockoutsUnlock);
2244
+ const [widthRef, width] = dashboardModel.useElementWidth();
2245
+ const [locks, setLocks] = react.useState(null);
2246
+ const [error, setError] = react.useState(false);
2247
+ const [refreshing, setRefreshing] = react.useState(false);
2248
+ const refreshRef = react.useRef(null);
2249
+ const requestRef = react.useRef(0);
2250
+ const apply = react.useCallback(async (request, pending) => {
2251
+ try {
2252
+ const { data } = await pending;
2253
+ if (request !== requestRef.current) return;
2254
+ if (!Array.isArray(data?.data)) throw new Error("Invalid lock list");
2255
+ setLocks(sortLocks(data.data));
2256
+ setError(false);
2257
+ } catch (err) {
2258
+ if (index.isCancelledRequest(err) || request !== requestRef.current) return;
2259
+ index.logSafeAdminError("lockouts", err);
2260
+ setError(true);
2261
+ } finally {
2262
+ if (request === requestRef.current) setRefreshing(false);
2263
+ }
2264
+ }, []);
2265
+ const load = react.useCallback(() => {
2266
+ const request = ++requestRef.current;
2267
+ setRefreshing(true);
2268
+ return apply(request, get(`/${index.pluginId}/lockouts`));
2269
+ }, [apply, get]);
2270
+ react.useEffect(() => {
2271
+ apply(++requestRef.current, get(`/${index.pluginId}/lockouts`));
2272
+ }, [apply, get]);
2273
+ const unlock = async (lock) => {
2274
+ try {
2275
+ await post(`/${index.pluginId}/lockouts/unlock`, { id: lock.id });
2276
+ toggleNotification({
2277
+ type: "success",
2278
+ message: t("settings.lockouts.unlocked", "{name} was unlocked.", {
2279
+ name: lockName(lock, t)
2280
+ })
2281
+ });
2282
+ } catch (err) {
2283
+ if (err?.response?.status === 404) {
2284
+ toggleNotification({
2285
+ type: "info",
2286
+ message: t("settings.lockouts.alreadyEnded", "This lock had already ended.")
2287
+ });
2288
+ } else {
2289
+ index.logSafeAdminError("lockouts", err);
2290
+ toggleNotification({
2291
+ type: "danger",
2292
+ message: t("settings.lockouts.unlockFailed", "The lock could not be lifted.")
2293
+ });
2294
+ throw err;
2295
+ }
2296
+ } finally {
2297
+ await load();
2298
+ }
2299
+ };
2300
+ const showActions = !permissionsLoading && canUnlock;
2301
+ const asTable = width === 0 || width >= TABLE_MIN_WIDTH;
2302
+ const unlockAction = (lock) => showActions ? /* @__PURE__ */ jsxRuntime.jsx(
2303
+ index.ConfirmAction,
2304
+ {
2305
+ fallbackFocusRef: refreshRef,
2306
+ title: t("settings.lockouts.confirm.title", "Unlock {name}?", { name: lockName(lock, t) }),
2307
+ body: lock.kind === "ip" ? t(
2308
+ "settings.lockouts.confirm.bodyIp",
2309
+ "Sign-ins from this address are allowed again at once, and its failed attempts are reset. This is recorded in the security log."
2310
+ ) : t(
2311
+ "settings.lockouts.confirm.bodyAccount",
2312
+ "Sign-ins to this account are allowed again at once, and its failed attempts are reset. This is recorded in the security log."
2313
+ ),
2314
+ confirmLabel: t("settings.lockouts.confirm.action", "Unlock"),
2315
+ variant: "default",
2316
+ onConfirm: () => unlock(lock),
2317
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(
2318
+ designSystem.IconButton,
2319
+ {
2320
+ variant: "ghost",
2321
+ label: t("settings.lockouts.unlockLabel", "Unlock {name}", { name: lockName(lock, t) }),
2322
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {})
2323
+ }
2324
+ )
2325
+ },
2326
+ lock.id
2327
+ ) : null;
2328
+ const ends = (lock) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: lock.until, variant: "omega", textColor: "neutral800", children: formatDate(lock.until, { hour: "2-digit", minute: "2-digit" }) });
2329
+ let content;
2330
+ if (locks === null && !error) {
2331
+ content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("settings.lockouts.loading", "Loading locks…") }) });
2332
+ } else if (error && locks === null) {
2333
+ content = /* @__PURE__ */ jsxRuntime.jsx(
2334
+ index.PersistentAlert,
2335
+ {
2336
+ variant: "danger",
2337
+ closeLabel: t("common.close", "Close"),
2338
+ title: t("settings.lockouts.error", "Locks could not be loaded."),
2339
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: load, children: t("common.tryAgain", "Try again") }),
2340
+ children: t("settings.lockouts.errorBody", "Sign-ins are still checked; only this list is missing.")
2341
+ }
2342
+ );
2343
+ } else if (locks.length === 0) {
2344
+ content = /* @__PURE__ */ jsxRuntime.jsx(
2345
+ designSystem.EmptyStateLayout,
2346
+ {
2347
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyPermissions, { width: "16rem", height: "8rem" }),
2348
+ content: t(
2349
+ "settings.lockouts.empty",
2350
+ "Nothing is locked. Locked IP addresses and accounts appear here until their lock ends."
2351
+ )
2352
+ }
2353
+ );
2354
+ } else if (asTable) {
2355
+ content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", "data-locks-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: showActions ? 5 : 4, rowCount: locks.length + 1, "aria-busy": refreshing, children: [
2356
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
2357
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.locked", "Locked") }) }),
2358
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.kind", "Type") }) }),
2359
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.failures", "Failed sign-ins") }) }),
2360
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.until", "Locked until") }) }),
2361
+ showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("settings.lockouts.col.actions", "Actions") }) }) : null
2362
+ ] }) }),
2363
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: locks.map((lock) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-lock-row": lock.kind, children: [
2364
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsxRuntime.jsx(LockTarget, { lock }) }),
2365
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }) }),
2366
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
2367
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: ends(lock) }),
2368
+ showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
2369
+ ] }, lock.id)) })
2370
+ ] }) });
2371
+ } else {
2372
+ content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-locks-list": "", children: locks.map((lock) => /* @__PURE__ */ jsxRuntime.jsx(
2373
+ designSystem.Box,
2374
+ {
2375
+ tag: "li",
2376
+ padding: 4,
2377
+ hasRadius: true,
2378
+ borderColor: "neutral150",
2379
+ "data-lock-row": lock.kind,
2380
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
2381
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, minWidth: 0, children: [
2382
+ /* @__PURE__ */ jsxRuntime.jsx(LockTarget, { lock }),
2383
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
2384
+ /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }),
2385
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.lockouts.summary", "{count} failed, until {time}", {
2386
+ count: lock.failures,
2387
+ time: formatDate(lock.until, { hour: "2-digit", minute: "2-digit" })
2388
+ }) })
2389
+ ] })
2390
+ ] }),
2391
+ /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
2392
+ ] })
2393
+ },
2394
+ lock.id
2395
+ )) });
2396
+ }
2397
+ return /* @__PURE__ */ jsxRuntime.jsx(
2398
+ SectionCard.SectionCard,
2399
+ {
2400
+ id: "locked-now",
2401
+ title: t("settings.lockouts.title", "Locked now"),
2402
+ subtitle: t(
2403
+ "settings.lockouts.intro",
2404
+ "IP addresses and accounts that are refused right now after failed sign-ins."
2405
+ ),
2406
+ action: /* @__PURE__ */ jsxRuntime.jsx(
2407
+ designSystem.Button,
2408
+ {
2409
+ ref: refreshRef,
2410
+ variant: "tertiary",
2411
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
2412
+ onClick: load,
2413
+ loading: refreshing && locks !== null,
2414
+ children: t("settings.lockouts.refresh", "Refresh")
2415
+ }
2416
+ ),
2417
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: widthRef, "aria-live": "polite", children: [
2418
+ error && locks !== null ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
2419
+ index.PersistentAlert,
2420
+ {
2421
+ variant: "warning",
2422
+ closeLabel: t("common.close", "Close"),
2423
+ title: t("settings.lockouts.refreshErrorTitle", "Not refreshed"),
2424
+ children: t(
2425
+ "settings.lockouts.refreshError",
2426
+ "The list could not be refreshed. It shows the last known locks."
2427
+ )
2428
+ }
2429
+ ) }) : null,
2430
+ content,
2431
+ locks && locks.length > 0 && !showActions && !permissionsLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
2432
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Lock, { "aria-hidden": true, fill: "neutral600" }),
2433
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
2434
+ "settings.lockouts.noUnlock",
2435
+ 'Unlocking needs the "Unlock locked sign-ins" permission.'
2436
+ ) })
2437
+ ] }) }) : null,
2438
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: locks ? t(
2439
+ "settings.lockouts.count",
2440
+ "{count, plural, =0 {No locks} one {# lock} other {# locks}}",
2441
+ {
2442
+ count: locks.length
2443
+ }
2444
+ ) : null })
2445
+ ] })
2446
+ }
2447
+ );
2448
+ };
2449
+ const TrustedAddressesField = ({ form, disabled = false }) => {
2450
+ const { t, tError } = useSettingsTranslate();
2451
+ const { settings, handleChange, errors, draftVersion } = form;
2452
+ const [text, setText] = react.useState(
2453
+ () => formatTrustedAddressText(settings.lockoutTrustedAddresses)
2454
+ );
2455
+ const [version, setVersion] = react.useState(draftVersion);
2456
+ if (version !== draftVersion) {
2457
+ setVersion(draftVersion);
2458
+ setText(formatTrustedAddressText(settings.lockoutTrustedAddresses));
2459
+ }
2460
+ return /* @__PURE__ */ jsxRuntime.jsx(
2461
+ FormField,
2462
+ {
2463
+ id: "lockout-trusted-addresses",
2464
+ name: "lockoutTrustedAddresses",
2465
+ label: t("settings.config.failed.trusted.label", "Trusted addresses"),
2466
+ description: t(
2467
+ "settings.config.failed.trusted.hint",
2468
+ "One IP address or CIDR range per line, for example 192.0.2.10 or 192.0.2.0/24. These addresses are never locked by IP; accounts can still be locked. Use it for an office network or a server that signs in for many users."
2469
+ ),
2470
+ error: tError(errors.lockoutTrustedAddresses),
2471
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2472
+ designSystem.Textarea,
2473
+ {
2474
+ value: text,
2475
+ placeholder: "192.0.2.0/24",
2476
+ disabled,
2477
+ onChange: (event) => {
2478
+ setText(event.target.value);
2479
+ handleChange("lockoutTrustedAddresses", parseTrustedAddressText(event.target.value));
2480
+ }
2481
+ }
2482
+ )
2483
+ }
2484
+ );
2485
+ };
1531
2486
  const COUNTRIES = [
1532
2487
  { code: "DE", name: "Germany", flag: "🇩🇪" },
1533
2488
  { code: "AT", name: "Austria", flag: "🇦🇹" },
@@ -1923,19 +2878,59 @@ const CountryListEditor = ({ settings, handleChange }) => {
1923
2878
  ] })
1924
2879
  ] });
1925
2880
  };
2881
+ const describeLockout = (t, { ip, account, window: window2, duration }) => {
2882
+ if (ip === 0 && account === 0) {
2883
+ return t(
2884
+ "settings.config.failed.lockout.offBoth",
2885
+ "The lockout is off. Failed sign-ins are not limited."
2886
+ );
2887
+ }
2888
+ const parts = [];
2889
+ if (ip > 0) {
2890
+ parts.push(
2891
+ t(
2892
+ "settings.config.failed.preview.ip",
2893
+ "{count, plural, one {# failed sign-in} other {# failed sign-ins}} from one IP address within {window, plural, one {# minute} other {# minutes}} lock that address for {duration, plural, one {# minute} other {# minutes}}.",
2894
+ { count: ip, window: window2, duration }
2895
+ )
2896
+ );
2897
+ }
2898
+ if (account > 0) {
2899
+ parts.push(
2900
+ t(
2901
+ "settings.config.failed.preview.account",
2902
+ "{count, plural, one {# failed sign-in} other {# failed sign-ins}} for one account within {window, plural, one {# minute} other {# minutes}} lock that account for {duration, plural, one {# minute} other {# minutes}}, from every address.",
2903
+ { count: account, window: window2, duration }
2904
+ )
2905
+ );
2906
+ }
2907
+ return parts.join(" ");
2908
+ };
1926
2909
  const LoginProtectionTab = ({ form }) => {
1927
2910
  const { t, tError } = useSettingsTranslate();
1928
2911
  const { settings, handleChange, errors } = form;
1929
2912
  const maxFailedError = tError(errors.maxFailedLogins);
1930
2913
  const maxFailedValue = Number(settings.maxFailedLogins);
2914
+ const accountValue = Number(settings.maxFailedLoginsPerAccount) || 0;
2915
+ const accountByRole = (settings.roleRules || []).some(
2916
+ (rule) => rule.maxFailedLoginsPerAccount !== null && rule.maxFailedLoginsPerAccount !== void 0
2917
+ );
2918
+ const lockoutPreview = describeLockout(t, {
2919
+ ip: maxFailedValue,
2920
+ account: accountValue,
2921
+ window: Number(settings.lockoutWindowMinutes) || 15,
2922
+ duration: Number(settings.lockoutDurationMinutes) || 15
2923
+ });
1931
2924
  const lookupOff = !settings.enableGeolocation;
1932
- const risk = riskData.getRiskAvailability(form.geoIp.status);
1933
- const reject = riskData.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
2925
+ const locked = form.canChangeProtected === false;
2926
+ const policyLocked = locked;
2927
+ const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
2928
+ const reject = dashboardModel.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
1934
2929
  const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
1935
2930
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
1936
2931
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
1937
2932
  "settings.config.loginProtection.intro",
1938
- "These rules check new sign-ins before they succeed. Existing sessions are not affected, and refused sign-ins are not recorded."
2933
+ "These rules check new sign-ins before they succeed. Existing sessions are not affected. Failed and refused sign-ins are recorded in the security log while recording is on."
1939
2934
  ) }),
1940
2935
  /* @__PURE__ */ jsxRuntime.jsxs(
1941
2936
  SectionCard.SectionCard,
@@ -1943,63 +2938,180 @@ const LoginProtectionTab = ({ form }) => {
1943
2938
  title: t("settings.config.failed.title", "Failed sign-ins"),
1944
2939
  subtitle: t(
1945
2940
  "settings.config.failed.intro",
1946
- "Slows down password guessing from one IP address."
2941
+ "Slows down password guessing. Counts are shared by every server process."
1947
2942
  ),
1948
2943
  children: [
1949
- /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
1950
- FormField,
1951
- {
1952
- id: "max-failed-logins",
1953
- name: "maxFailedLogins",
1954
- label: t("settings.config.failed.lockout.label", "Temporary IP lockout after"),
1955
- description: t(
1956
- "settings.config.failed.lockout.hint",
1957
- "A whole number from 0 to 100. 0 turns the lockout off."
1958
- ),
1959
- suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
1960
- error: maxFailedError,
1961
- required: true,
1962
- children: /* @__PURE__ */ jsxRuntime.jsx(
1963
- designSystem.NumberInput,
1964
- {
1965
- value: settings.maxFailedLogins,
1966
- onValueChange: (value) => handleChange("maxFailedLogins", value),
1967
- min: MAX_FAILED_LOGINS_RANGE.min,
1968
- max: MAX_FAILED_LOGINS_RANGE.max,
1969
- step: 1
1970
- },
1971
- form.draftVersion
1972
- )
1973
- }
1974
- ) }),
1975
- !maxFailedError ? /* @__PURE__ */ jsxRuntime.jsx(
2944
+ policyLocked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
2945
+ /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
2946
+ /* @__PURE__ */ jsxRuntime.jsx(
2947
+ FormField,
2948
+ {
2949
+ id: "max-failed-logins",
2950
+ name: "maxFailedLogins",
2951
+ label: t("settings.config.failed.lockout.label", "Lock an IP address after"),
2952
+ description: t(
2953
+ "settings.config.failed.lockout.hint",
2954
+ "A whole number from 0 to 100. 0 turns the IP lockout off."
2955
+ ),
2956
+ suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
2957
+ error: maxFailedError,
2958
+ required: true,
2959
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2960
+ designSystem.NumberInput,
2961
+ {
2962
+ value: settings.maxFailedLogins,
2963
+ onValueChange: (value) => handleChange("maxFailedLogins", value),
2964
+ min: MAX_FAILED_LOGINS_RANGE.min,
2965
+ max: MAX_FAILED_LOGINS_RANGE.max,
2966
+ step: 1
2967
+ },
2968
+ form.draftVersion
2969
+ )
2970
+ }
2971
+ ),
2972
+ /* @__PURE__ */ jsxRuntime.jsx(
2973
+ FormField,
2974
+ {
2975
+ id: "max-failed-logins-account",
2976
+ name: "maxFailedLoginsPerAccount",
2977
+ label: t("settings.config.failed.account.label", "Lock an account after"),
2978
+ description: t(
2979
+ "settings.config.failed.account.hint",
2980
+ "Counts failed sign-ins for one account from any address. 0 turns it off. Anyone who knows an account name can lock it, so keep this higher than the IP limit."
2981
+ ),
2982
+ suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
2983
+ error: tError(errors.maxFailedLoginsPerAccount),
2984
+ required: true,
2985
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2986
+ designSystem.NumberInput,
2987
+ {
2988
+ value: settings.maxFailedLoginsPerAccount,
2989
+ onValueChange: (value) => handleChange("maxFailedLoginsPerAccount", value ?? ""),
2990
+ disabled: policyLocked,
2991
+ min: POLICY_RANGES.maxFailedLoginsPerAccount.min,
2992
+ max: POLICY_RANGES.maxFailedLoginsPerAccount.max,
2993
+ step: 1
2994
+ },
2995
+ form.draftVersion
2996
+ )
2997
+ }
2998
+ ),
2999
+ /* @__PURE__ */ jsxRuntime.jsx(
3000
+ FormField,
3001
+ {
3002
+ id: "lockout-window",
3003
+ name: "lockoutWindowMinutes",
3004
+ label: t("settings.config.failed.window.label", "Count failed sign-ins within"),
3005
+ description: t(
3006
+ "settings.config.failed.window.hint",
3007
+ "Failures older than this no longer count."
3008
+ ),
3009
+ suffix: t("settings.config.failed.minutes.suffix", "minutes"),
3010
+ error: tError(errors.lockoutWindowMinutes),
3011
+ required: true,
3012
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3013
+ designSystem.NumberInput,
3014
+ {
3015
+ value: settings.lockoutWindowMinutes,
3016
+ onValueChange: (value) => handleChange("lockoutWindowMinutes", value ?? ""),
3017
+ disabled: policyLocked,
3018
+ min: POLICY_RANGES.lockoutWindowMinutes.min,
3019
+ max: POLICY_RANGES.lockoutWindowMinutes.max,
3020
+ step: 1
3021
+ },
3022
+ form.draftVersion
3023
+ )
3024
+ }
3025
+ ),
3026
+ /* @__PURE__ */ jsxRuntime.jsx(
3027
+ FormField,
3028
+ {
3029
+ id: "lockout-duration",
3030
+ name: "lockoutDurationMinutes",
3031
+ label: t("settings.config.failed.duration.label", "Lock for"),
3032
+ description: t(
3033
+ "settings.config.failed.duration.hint",
3034
+ "A locked IP address or account is refused for this long. Admins can unlock it earlier."
3035
+ ),
3036
+ suffix: t("settings.config.failed.minutes.suffix", "minutes"),
3037
+ error: tError(errors.lockoutDurationMinutes),
3038
+ required: true,
3039
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3040
+ designSystem.NumberInput,
3041
+ {
3042
+ value: settings.lockoutDurationMinutes,
3043
+ onValueChange: (value) => handleChange("lockoutDurationMinutes", value ?? ""),
3044
+ disabled: policyLocked,
3045
+ min: POLICY_RANGES.lockoutDurationMinutes.min,
3046
+ max: POLICY_RANGES.lockoutDurationMinutes.max,
3047
+ step: 1
3048
+ },
3049
+ form.draftVersion
3050
+ )
3051
+ }
3052
+ )
3053
+ ] }),
3054
+ !maxFailedError && !errors.maxFailedLoginsPerAccount ? /* @__PURE__ */ jsxRuntime.jsx(
1976
3055
  designSystem.Box,
1977
3056
  {
1978
3057
  padding: 3,
1979
- background: maxFailedValue === 0 ? "warning100" : "neutral100",
3058
+ background: maxFailedValue === 0 && accountValue === 0 ? "warning100" : "neutral100",
1980
3059
  hasRadius: true,
1981
3060
  "aria-live": "polite",
1982
3061
  children: /* @__PURE__ */ jsxRuntime.jsx(
1983
3062
  index.ReadableParagraphs,
1984
3063
  {
1985
3064
  variant: "pi",
1986
- textColor: maxFailedValue === 0 ? "warning700" : "neutral700",
3065
+ textColor: maxFailedValue === 0 && accountValue === 0 ? "warning700" : "neutral700",
1987
3066
  tag: "p",
1988
- text: maxFailedValue === 0 ? t(
1989
- "settings.config.failed.lockout.off",
1990
- "The temporary IP lockout is off. Failed sign-ins are not limited."
1991
- ) : t(
1992
- "settings.config.failed.lockout.preview",
1993
- "After {count, plural, one {# failed sign-in} other {# failed sign-ins}} from one IP address within 15 minutes, that address is refused for 15 minutes. User accounts are not blocked. Counted per server process.",
1994
- { count: maxFailedValue }
1995
- )
3067
+ text: lockoutPreview
1996
3068
  }
1997
3069
  )
1998
3070
  }
1999
- ) : null
3071
+ ) : null,
3072
+ /* @__PURE__ */ jsxRuntime.jsx(
3073
+ SettingsToggleRow,
3074
+ {
3075
+ id: "lockout-notify-user",
3076
+ title: t(
3077
+ "settings.config.failed.notify.label",
3078
+ "Email the user when their account is locked"
3079
+ ),
3080
+ description: t(
3081
+ "settings.config.failed.notify.hint",
3082
+ "Sent through Strapi's email plugin (and Magic Mail when installed). The text is in Alerts, Email templates."
3083
+ ),
3084
+ checked: !!settings.lockoutNotifyUser,
3085
+ disabled: policyLocked || accountValue === 0 && !accountByRole,
3086
+ onChange: (checked) => handleChange("lockoutNotifyUser", checked)
3087
+ }
3088
+ ),
3089
+ /* @__PURE__ */ jsxRuntime.jsx(
3090
+ SettingsToggleRow,
3091
+ {
3092
+ id: "record-user-sign-in-events",
3093
+ title: t("settings.config.failed.record.label", "Record failed and refused sign-ins"),
3094
+ description: t(
3095
+ "settings.config.failed.record.hint",
3096
+ "Writes failed sign-ins, refused sign-ins and locks to the security log, with the IP address as the log stores it."
3097
+ ),
3098
+ checked: settings.recordUserSignInEvents !== false,
3099
+ disabled: policyLocked,
3100
+ onChange: (checked) => handleChange("recordUserSignInEvents", checked)
3101
+ }
3102
+ ),
3103
+ /* @__PURE__ */ jsxRuntime.jsx(
3104
+ AdvancedSection,
3105
+ {
3106
+ label: t("settings.config.failed.trusted.section", "Trusted addresses"),
3107
+ hasError: fieldHasError(errors, "lockoutTrustedAddresses"),
3108
+ children: /* @__PURE__ */ jsxRuntime.jsx(TrustedAddressesField, { form, disabled: policyLocked })
3109
+ }
3110
+ )
2000
3111
  ]
2001
3112
  }
2002
3113
  ),
3114
+ /* @__PURE__ */ jsxRuntime.jsx(LockedNowCard, {}),
2003
3115
  /* @__PURE__ */ jsxRuntime.jsx(
2004
3116
  SectionCard.SectionCard,
2005
3117
  {
@@ -2081,7 +3193,7 @@ const LoginProtectionTab = ({ form }) => {
2081
3193
  designSystem.SingleSelect,
2082
3194
  {
2083
3195
  value: settings.geoLookupFailureMode || "auto",
2084
- disabled: lookupOff,
3196
+ disabled: lookupOff || locked,
2085
3197
  onChange: (value) => handleChange("geoLookupFailureMode", value),
2086
3198
  children: [
2087
3199
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
@@ -2133,7 +3245,18 @@ const LoginProtectionTab = ({ form }) => {
2133
3245
  {
2134
3246
  id: "lockout",
2135
3247
  term: t("settings.config.refused.lockout.response", "429 with Retry-After"),
2136
- description: t("settings.config.refused.lockout.cause", "Temporary IP lockout")
3248
+ description: t(
3249
+ "settings.config.refused.lockout.cause",
3250
+ "Locked IP address or account after failed sign-ins"
3251
+ )
3252
+ },
3253
+ {
3254
+ id: "limit",
3255
+ term: t("settings.config.refused.limit.response", "403 SESSION_LIMIT_REACHED"),
3256
+ description: t(
3257
+ "settings.config.refused.limit.cause",
3258
+ 'Session limit reached with "Refuse the new sign-in"'
3259
+ )
2137
3260
  },
2138
3261
  {
2139
3262
  id: "rule",
@@ -2157,7 +3280,10 @@ const LoginProtectionTab = ({ form }) => {
2157
3280
  ]
2158
3281
  }
2159
3282
  ),
2160
- /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t("settings.config.refused.noLog", "Session Manager keeps no log of refused sign-ins.") })
3283
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
3284
+ "settings.config.refused.log",
3285
+ 'Refused sign-ins are written to the security log while "Record failed and refused sign-ins" is on.'
3286
+ ) })
2161
3287
  ] })
2162
3288
  ] });
2163
3289
  };
@@ -2189,6 +3315,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2189
3315
  );
2190
3316
  };
2191
3317
  const lookupOff = !settings.enableGeolocation;
3318
+ const locked = form.canChangeProtected === false;
2192
3319
  const localDatabase = usesLocalDatabase(settings.geoIpProvider);
2193
3320
  const databaseDisabled = lookupOff || !localDatabase;
2194
3321
  const credentialSource = geoIpStatus?.credentialSource;
@@ -2226,7 +3353,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2226
3353
  designSystem.SingleSelect,
2227
3354
  {
2228
3355
  value: settings.geoIpProvider || "auto",
2229
- disabled: lookupOff,
3356
+ disabled: lookupOff || locked,
2230
3357
  onChange: (value) => handleChange("geoIpProvider", value),
2231
3358
  children: [
2232
3359
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.config.provider.auto", "Automatic") }),
@@ -2422,7 +3549,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2422
3549
  {
2423
3550
  name: "geoIpDatabasePath",
2424
3551
  value: settings.geoIpDatabasePath || "",
2425
- disabled: databaseDisabled && !errors.geoIpDatabasePath,
3552
+ disabled: (databaseDisabled || locked) && !errors.geoIpDatabasePath,
2426
3553
  onChange: (event) => handleChange("geoIpDatabasePath", event.target.value),
2427
3554
  placeholder: "GeoLite2-City.mmdb",
2428
3555
  autoComplete: "off",
@@ -2509,7 +3636,7 @@ const RiskDataCard = ({ form }) => {
2509
3636
  const { t } = useSettingsTranslate();
2510
3637
  const { settings, geoIp } = form;
2511
3638
  const lookupOff = !settings.enableGeolocation;
2512
- const risk = riskData.getRiskAvailability(geoIp.status);
3639
+ const risk = dashboardModel.getRiskAvailability(geoIp.status);
2513
3640
  const sourceLabels = {
2514
3641
  "anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
2515
3642
  "asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
@@ -2576,8 +3703,9 @@ const RiskDataCard = ({ form }) => {
2576
3703
  const LocationDataTab = ({ form }) => {
2577
3704
  const { t } = useSettingsTranslate();
2578
3705
  const { settings, handleChange } = form;
2579
- const risk = riskData.getRiskAvailability(form.geoIp.status);
2580
- const scoring = riskData.riskDependentControl(settings.enableSecurityScoring, risk.state);
3706
+ const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
3707
+ const scoring = dashboardModel.riskDependentControl(settings.enableSecurityScoring, risk.state);
3708
+ const locked = form.canChangeProtected === false;
2581
3709
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
2582
3710
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2583
3711
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
@@ -2590,7 +3718,7 @@ const LocationDataTab = ({ form }) => {
2590
3718
  ) })
2591
3719
  ] }),
2592
3720
  /* @__PURE__ */ jsxRuntime.jsxs(SectionCard.SectionCard, { title: t("settings.config.lookup.title", "IP location lookup"), children: [
2593
- /* @__PURE__ */ jsxRuntime.jsx(
3721
+ /* @__PURE__ */ jsxRuntime.jsxs(
2594
3722
  SettingsToggleRow,
2595
3723
  {
2596
3724
  id: "enable-ip-geolocation",
@@ -2600,11 +3728,15 @@ const LocationDataTab = ({ form }) => {
2600
3728
  "Looks up country and city at every sign-in and for listed sessions without a location."
2601
3729
  ),
2602
3730
  checked: settings.enableGeolocation,
3731
+ disabled: locked,
2603
3732
  onChange: (checked) => handleChange("enableGeolocation", checked),
2604
- children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
2605
- "settings.config.lookup.enable.privacy",
2606
- "With the Automatic or ipapi.co provider, IP addresses can be sent to ipapi.co."
2607
- ) })
3733
+ children: [
3734
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
3735
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
3736
+ "settings.config.lookup.enable.privacy",
3737
+ "With the Automatic or ipapi.co provider, IP addresses can be sent to ipapi.co."
3738
+ ) })
3739
+ ]
2608
3740
  }
2609
3741
  ),
2610
3742
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2703,7 +3835,8 @@ const PreviewFrame = styled__default.default.iframe`
2703
3835
  const TEMPLATE_TAB_LABELS = {
2704
3836
  suspiciousLogin: ["settings.email.templates.tab.suspicious", "Suspicious sign-in"],
2705
3837
  newLocation: ["settings.email.templates.tab.newLocation", "New country"],
2706
- vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"]
3838
+ vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"],
3839
+ accountLocked: ["settings.email.templates.tab.accountLocked", "Account locked"]
2707
3840
  };
2708
3841
  const BlockLabel = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", tag: "div", textColor: "neutral800", children });
2709
3842
  const TemplateEditor = ({ templateKey, template, templates, handleChange, copyValue, errors }) => {
@@ -2973,6 +4106,84 @@ const EmailTemplatesCard = ({ form }) => {
2973
4106
  ] })
2974
4107
  ] });
2975
4108
  };
4109
+ const WebhookUrlField = ({
4110
+ form,
4111
+ id,
4112
+ field,
4113
+ hasKey,
4114
+ hintKey,
4115
+ label,
4116
+ description,
4117
+ placeholder,
4118
+ error,
4119
+ disabled = false
4120
+ }) => {
4121
+ const { t } = useSettingsTranslate();
4122
+ const { settings, handleChange } = form;
4123
+ const stored = settings[hasKey] === true;
4124
+ const draft = settings[field];
4125
+ const [replacing, setReplacing] = react.useState(false);
4126
+ const removing = stored && draft === "";
4127
+ const showInput = !stored || replacing || typeof draft === "string" && draft !== "";
4128
+ const onInput = (value) => handleChange(field, value ? value : void 0);
4129
+ const cancel = () => {
4130
+ handleChange(field, void 0);
4131
+ setReplacing(false);
4132
+ };
4133
+ if (!showInput) {
4134
+ 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: [
4135
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", minWidth: 0, children: [
4136
+ /* @__PURE__ */ jsxRuntime.jsx(
4137
+ designSystem.Badge,
4138
+ {
4139
+ backgroundColor: removing ? "danger100" : "success100",
4140
+ textColor: removing ? "danger700" : "success700",
4141
+ children: removing ? t("settings.webhooks.removing", "Removed on save") : t("settings.webhooks.saved", "Saved")
4142
+ }
4143
+ ),
4144
+ settings[hintKey] ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: settings[hintKey] }) : null
4145
+ ] }),
4146
+ /* @__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: [
4147
+ /* @__PURE__ */ jsxRuntime.jsx(
4148
+ designSystem.Button,
4149
+ {
4150
+ variant: "secondary",
4151
+ size: "S",
4152
+ disabled,
4153
+ onClick: () => setReplacing(true),
4154
+ children: t("settings.webhooks.replace", "Replace")
4155
+ }
4156
+ ),
4157
+ /* @__PURE__ */ jsxRuntime.jsx(
4158
+ designSystem.Button,
4159
+ {
4160
+ variant: "danger-light",
4161
+ size: "S",
4162
+ disabled,
4163
+ onClick: () => handleChange(field, ""),
4164
+ children: t("settings.webhooks.remove", "Remove")
4165
+ }
4166
+ )
4167
+ ] }) })
4168
+ ] }) });
4169
+ }
4170
+ return /* @__PURE__ */ jsxRuntime.jsx(FormField, { id, name: field, label, description, error, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
4171
+ /* @__PURE__ */ jsxRuntime.jsx(
4172
+ SecretTextInput,
4173
+ {
4174
+ name: field,
4175
+ revealedType: "url",
4176
+ value: typeof draft === "string" ? draft : "",
4177
+ disabled: disabled && !error,
4178
+ onChange: onInput,
4179
+ placeholder,
4180
+ showLabel: t("settings.webhooks.show", "Show URL"),
4181
+ hideLabel: t("settings.webhooks.hide", "Hide URL")
4182
+ }
4183
+ ),
4184
+ 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
4185
+ ] }) });
4186
+ };
2976
4187
  const WEBHOOK_EVENTS = Object.freeze({
2977
4188
  suspicious: "login.suspicious",
2978
4189
  newLocation: "login.new_location",
@@ -3012,8 +4223,9 @@ const AlertsTab = ({ form }) => {
3012
4223
  const lookupOff = !settings.enableGeolocation;
3013
4224
  const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
3014
4225
  const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
4226
+ const locked = form.canChangeProtected === false;
3015
4227
  const templateErrors = fieldHasError(errors, "emailTemplates");
3016
- const risk = riskData.getRiskAvailability(form.geoIp.status);
4228
+ const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
3017
4229
  const emailTypes = [
3018
4230
  {
3019
4231
  field: "alertOnSuspiciousLogin",
@@ -3081,7 +4293,7 @@ const AlertsTab = ({ form }) => {
3081
4293
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
3082
4294
  !lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
3083
4295
  /* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
3084
- const control = needsRiskData ? riskData.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
4296
+ const control = needsRiskData ? dashboardModel.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
3085
4297
  const disabled = emailTypesDisabled || control.disabled;
3086
4298
  return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
3087
4299
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3137,7 +4349,7 @@ const AlertsTab = ({ form }) => {
3137
4349
  WEBHOOK_EVENTS
3138
4350
  ),
3139
4351
  checked: settings.enableWebhooks,
3140
- disabled: lookupOff,
4352
+ disabled: lookupOff || locked,
3141
4353
  onChange: (checked) => handleChange("enableWebhooks", checked)
3142
4354
  }
3143
4355
  ),
@@ -3147,64 +4359,51 @@ const AlertsTab = ({ form }) => {
3147
4359
  "Without a risk data source, {suspicious} is never sent.",
3148
4360
  WEBHOOK_EVENTS
3149
4361
  ) }) : null,
4362
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
3150
4363
  /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
3151
4364
  /* @__PURE__ */ jsxRuntime.jsx(
3152
- FormField,
4365
+ WebhookUrlField,
3153
4366
  {
4367
+ form,
3154
4368
  id: "discord-webhook-url",
3155
- name: "discordWebhookUrl",
4369
+ field: "discordWebhookUrl",
4370
+ hasKey: "hasDiscordWebhook",
4371
+ hintKey: "discordWebhookHint",
3156
4372
  label: t("settings.config.webhooks.discord.label", "Discord webhook URL"),
3157
4373
  description: t(
3158
4374
  "settings.config.webhooks.discord.hint",
3159
4375
  "Must start with https://discord.com or https://discordapp.com. Anyone with this URL can post to your channel."
3160
4376
  ),
3161
4377
  error: tError(errors.discordWebhookUrl),
3162
- children: /* @__PURE__ */ jsxRuntime.jsx(
3163
- SecretTextInput,
3164
- {
3165
- name: "discordWebhookUrl",
3166
- revealedType: "url",
3167
- value: settings.discordWebhookUrl || "",
3168
- disabled: webhookFieldsDisabled && !errors.discordWebhookUrl,
3169
- onChange: (value) => handleChange("discordWebhookUrl", value),
3170
- placeholder: t(
3171
- "settings.webhooks.discord.placeholder",
3172
- "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."
3173
- ),
3174
- showLabel: t("settings.webhooks.show", "Show URL"),
3175
- hideLabel: t("settings.webhooks.hide", "Hide URL")
3176
- }
4378
+ disabled: webhookFieldsDisabled || locked,
4379
+ placeholder: t(
4380
+ "settings.webhooks.discord.placeholder",
4381
+ "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."
3177
4382
  )
3178
- }
4383
+ },
4384
+ `discord-${form.draftVersion}`
3179
4385
  ),
3180
4386
  /* @__PURE__ */ jsxRuntime.jsx(
3181
- FormField,
4387
+ WebhookUrlField,
3182
4388
  {
4389
+ form,
3183
4390
  id: "slack-webhook-url",
3184
- name: "slackWebhookUrl",
4391
+ field: "slackWebhookUrl",
4392
+ hasKey: "hasSlackWebhook",
4393
+ hintKey: "slackWebhookHint",
3185
4394
  label: t("settings.config.webhooks.slack.label", "Slack webhook URL"),
3186
4395
  description: t(
3187
4396
  "settings.config.webhooks.slack.hint",
3188
4397
  "Must start with https://hooks.slack.com. Anyone with this URL can post to your channel."
3189
4398
  ),
3190
4399
  error: tError(errors.slackWebhookUrl),
3191
- children: /* @__PURE__ */ jsxRuntime.jsx(
3192
- SecretTextInput,
3193
- {
3194
- name: "slackWebhookUrl",
3195
- revealedType: "url",
3196
- value: settings.slackWebhookUrl || "",
3197
- disabled: webhookFieldsDisabled && !errors.slackWebhookUrl,
3198
- onChange: (value) => handleChange("slackWebhookUrl", value),
3199
- placeholder: t(
3200
- "settings.webhooks.slack.placeholder",
3201
- "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
3202
- ),
3203
- showLabel: t("settings.webhooks.show", "Show URL"),
3204
- hideLabel: t("settings.webhooks.hide", "Hide URL")
3205
- }
4400
+ disabled: webhookFieldsDisabled || locked,
4401
+ placeholder: t(
4402
+ "settings.webhooks.slack.placeholder",
4403
+ "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
3206
4404
  )
3207
- }
4405
+ },
4406
+ `slack-${form.draftVersion}`
3208
4407
  )
3209
4408
  ] })
3210
4409
  ]
@@ -3290,11 +4489,13 @@ const AdminActivityTab = ({ form }) => {
3290
4489
  const { t } = useSettingsTranslate();
3291
4490
  const units = useOptionLabels();
3292
4491
  const { settings, handleChange } = form;
4492
+ const locked = form.canChangeProtected === false;
3293
4493
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3294
4494
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
3295
4495
  "settings.config.adminActivity.intro",
3296
4496
  "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."
3297
4497
  ) }),
4498
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
3298
4499
  /* @__PURE__ */ jsxRuntime.jsxs(SectionCard.SectionCard, { title: t("settings.config.adminActivity.recording.title", "What is recorded"), children: [
3299
4500
  /* @__PURE__ */ jsxRuntime.jsx(
3300
4501
  SettingsToggleRow,
@@ -3306,6 +4507,7 @@ const AdminActivityTab = ({ form }) => {
3306
4507
  "Every sign-in, failed attempt, lockout and sign-out, and who signed out whom, with time, browser and operating system."
3307
4508
  ),
3308
4509
  checked: settings.adminSignInHistory,
4510
+ disabled: locked,
3309
4511
  onChange: (checked) => handleChange("adminSignInHistory", checked)
3310
4512
  }
3311
4513
  ),
@@ -3319,9 +4521,10 @@ const AdminActivityTab = ({ form }) => {
3319
4521
  ),
3320
4522
  description: t(
3321
4523
  "settings.config.adminActivity.content.hint",
3322
- "Which entries each admin opens, creates, edits, publishes, unpublishes or deletes, with content type, title, locale and time."
4524
+ "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."
3323
4525
  ),
3324
4526
  checked: settings.adminContentActivity,
4527
+ disabled: locked,
3325
4528
  onChange: (checked) => handleChange("adminContentActivity", checked),
3326
4529
  children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
3327
4530
  "settings.config.adminActivity.content.notice",
@@ -3349,6 +4552,7 @@ const AdminActivityTab = ({ form }) => {
3349
4552
  "The address comes from Strapi’s client IP (server.proxy settings). The location uses the IP location lookup under Location data."
3350
4553
  ),
3351
4554
  checked: settings.securityLogStoreIp,
4555
+ disabled: locked,
3352
4556
  onChange: (checked) => handleChange("securityLogStoreIp", checked)
3353
4557
  }
3354
4558
  ),
@@ -3365,11 +4569,29 @@ const AdminActivityTab = ({ form }) => {
3365
4569
  "Stores 203.0.113.0 instead of 203.0.113.42 (IPv6: the first 48 bits only)."
3366
4570
  ),
3367
4571
  checked: settings.securityLogAnonymizeIp,
3368
- disabled: !settings.securityLogStoreIp,
4572
+ disabled: locked || !settings.securityLogStoreIp,
3369
4573
  onChange: (checked) => handleChange("securityLogAnonymizeIp", checked),
3370
4574
  children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
3371
4575
  }
3372
4576
  ),
4577
+ /* @__PURE__ */ jsxRuntime.jsx(
4578
+ SettingsToggleRow,
4579
+ {
4580
+ id: "security-log-geo-lookup",
4581
+ title: t(
4582
+ "settings.config.adminActivity.geoLookup.label",
4583
+ "Look up the location of security events"
4584
+ ),
4585
+ description: t(
4586
+ "settings.config.adminActivity.geoLookup.hint",
4587
+ "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."
4588
+ ),
4589
+ checked: settings.securityLogGeoLookup,
4590
+ disabled: locked || !settings.securityLogStoreIp,
4591
+ onChange: (checked) => handleChange("securityLogGeoLookup", checked),
4592
+ children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
4593
+ }
4594
+ ),
3373
4595
  /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
3374
4596
  PresetSelect,
3375
4597
  {
@@ -3378,11 +4600,12 @@ const AdminActivityTab = ({ form }) => {
3378
4600
  label: t("settings.config.adminActivity.retention.label", "Keep security events for"),
3379
4601
  description: t(
3380
4602
  "settings.config.adminActivity.retention.hint",
3381
- "Older events are deleted once a day. Events of a deleted admin are deleted with the account."
4603
+ "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."
3382
4604
  ),
3383
4605
  value: settings.securityLogRetentionDays,
3384
4606
  presets: SELECT_PRESETS.securityLogRetentionDays,
3385
4607
  format: units.days,
4608
+ disabled: locked,
3386
4609
  onChange: (value) => handleChange("securityLogRetentionDays", value)
3387
4610
  }
3388
4611
  ) })
@@ -3517,7 +4740,14 @@ function useSettingsForm() {
3517
4740
  if (key === "strictSessionEnforcement") {
3518
4741
  setRelaxedWarningDismissed(false);
3519
4742
  }
3520
- setSettings((previousSettings) => ({ ...previousSettings, [key]: value }));
4743
+ setSettings((previousSettings) => {
4744
+ if (value === void 0) {
4745
+ const next = { ...previousSettings };
4746
+ delete next[key];
4747
+ return next;
4748
+ }
4749
+ return { ...previousSettings, [key]: value };
4750
+ });
3521
4751
  }, []);
3522
4752
  const handleSave = react.useCallback(async () => {
3523
4753
  const submitted = buildSavePayload(settingsRef.current, savedSettingsRef.current);
@@ -3787,6 +5017,9 @@ const SettingsPage = () => {
3787
5017
  const {
3788
5018
  allowedActions: { canRead: canViewAdminActivity }
3789
5019
  } = StrapiAdmin.useRBAC(index.pluginPermissions.adminActivityRead);
5020
+ const {
5021
+ allowedActions: { canUpdate: canChangeProtected }
5022
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.settingsUpdate);
3790
5023
  const visibleTabs = react.useMemo(
3791
5024
  () => getVisibleSettingsTabs(Boolean(canViewAdminActivity)),
3792
5025
  [canViewAdminActivity]
@@ -3915,7 +5148,12 @@ const SettingsPage = () => {
3915
5148
  ),
3916
5149
  visibleTabs.map((tab) => {
3917
5150
  const TabPanel = TAB_COMPONENTS[tab];
3918
- 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);
5151
+ 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(
5152
+ TabPanel,
5153
+ {
5154
+ form: { ...form, canChangeProtected: Boolean(canChangeProtected) }
5155
+ }
5156
+ ) }) }) }, tab);
3919
5157
  }),
3920
5158
  /* @__PURE__ */ jsxRuntime.jsxs(StrapiAdmin.Form, { method: "PUT", initialValues: form.savedSettings, children: [
3921
5159
  /* @__PURE__ */ jsxRuntime.jsx(DraftSync, { values: form.settings }),