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