strapi-plugin-magic-sessionmanager 4.16.1 → 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 +41 -0
- package/README.md +49 -15
- package/dist/admin/{Analytics-FcRt0X62.mjs → Analytics-B-p2Q7th.mjs} +1 -1
- package/dist/admin/{Analytics-CMR62DiD.js → Analytics-BTIByTUY.js} +1 -1
- package/dist/admin/{App-CmytGbze.js → App-CH6635JB.js} +33 -170
- package/dist/admin/{App-DBieSWB0.mjs → App-DmesuM2g.mjs} +3 -140
- package/dist/admin/{OnlineUsersWidget-zP9Hl_it.mjs → OnlineUsersWidget-CuqeQ0tb.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-Lzx9XB74.js → OnlineUsersWidget-TlOp8nie.js} +1 -1
- package/dist/admin/{Settings-CZOPusQK.mjs → Settings-C4IgGBjQ.mjs} +1163 -56
- package/dist/admin/{Settings-1v--SXC0.js → Settings-DtP_H4JS.js} +1167 -60
- package/dist/admin/dashboardModel-0ROcWcB1.mjs +189 -0
- package/dist/admin/dashboardModel-BSJhZdXI.js +188 -0
- package/dist/admin/{de-D3TSA066.mjs → de-BoahnYIP.mjs} +110 -9
- package/dist/admin/{de-y_9mdVT7.js → de-C_ooq6EF.js} +110 -9
- package/dist/admin/{en-CIQB8nfI.js → en-CuUVE2K0.js} +110 -9
- package/dist/admin/{en-B60I97bK.mjs → en-DHme92L-.mjs} +110 -9
- package/dist/admin/{es-CJEL_iGC.mjs → es-CjcTgS9Z.mjs} +110 -9
- package/dist/admin/{es-DHhHzlRY.js → es-lbDNXcQi.js} +110 -9
- package/dist/admin/{fr-BfBK_iuV.mjs → fr-BPwnrSaC.mjs} +110 -9
- package/dist/admin/{fr-D86FTt1w.js → fr-RtypjgGp.js} +110 -9
- package/dist/admin/{index-tt61o2VH.mjs → index-B102RF2H.mjs} +40 -38
- package/dist/admin/{index-CSJJn4qy.js → index-w0OuPYFm.js} +12 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-BE-FT-L8.js → pt-BMCAKRQ4.js} +110 -9
- package/dist/admin/{pt-C3PSvC7z.mjs → pt-D5FHSP2y.mjs} +110 -9
- package/dist/server/index.js +1519 -78
- package/dist/server/index.mjs +1519 -78
- package/package.json +1 -1
- package/dist/admin/riskData-BVs9GpgD.js +0 -26
- package/dist/admin/riskData-CI1gm2yI.mjs +0 -27
|
@@ -6,10 +6,11 @@ const designSystem = require("@strapi/design-system");
|
|
|
6
6
|
const StrapiAdmin = require("@strapi/strapi/admin");
|
|
7
7
|
const icons = require("@strapi/icons");
|
|
8
8
|
const styled = require("styled-components");
|
|
9
|
-
const index = require("./index-
|
|
9
|
+
const index = require("./index-w0OuPYFm.js");
|
|
10
10
|
const reactIntl = require("react-intl");
|
|
11
11
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
12
|
-
const
|
|
12
|
+
const dashboardModel = require("./dashboardModel-BSJhZdXI.js");
|
|
13
|
+
const symbols = require("@strapi/icons/symbols");
|
|
13
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
15
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
15
16
|
const SETTINGS_TAB_IDS = Object.freeze([
|
|
@@ -38,10 +39,20 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
|
38
39
|
"cleanupInterval",
|
|
39
40
|
"cleanupUseDbDirect",
|
|
40
41
|
"strictSessionEnforcement",
|
|
41
|
-
"sessionCreationGraceMs"
|
|
42
|
+
"sessionCreationGraceMs",
|
|
43
|
+
"maxSessionsPerUser",
|
|
44
|
+
"sessionLimitPolicy",
|
|
45
|
+
"endOtherSessionsOnPasswordChange",
|
|
46
|
+
"roleRules"
|
|
42
47
|
],
|
|
43
48
|
"login-protection": [
|
|
44
49
|
"maxFailedLogins",
|
|
50
|
+
"maxFailedLoginsPerAccount",
|
|
51
|
+
"lockoutWindowMinutes",
|
|
52
|
+
"lockoutDurationMinutes",
|
|
53
|
+
"lockoutTrustedAddresses",
|
|
54
|
+
"lockoutNotifyUser",
|
|
55
|
+
"recordUserSignInEvents",
|
|
45
56
|
"trustedProxies",
|
|
46
57
|
"blockSuspiciousSessions",
|
|
47
58
|
"geoLookupFailureMode",
|
|
@@ -91,7 +102,26 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
|
|
|
91
102
|
cleanupUseDbDirect: ["settings.config.sessions.idleMethod.label", "Idle check method"],
|
|
92
103
|
strictSessionEnforcement: ["settings.config.token.check.label", "Strict token check"],
|
|
93
104
|
sessionCreationGraceMs: ["settings.config.token.grace.label", "Grace period after sign-in"],
|
|
94
|
-
maxFailedLogins: ["settings.config.failed.lockout.label", "
|
|
105
|
+
maxFailedLogins: ["settings.config.failed.lockout.label", "Lock an IP address after"],
|
|
106
|
+
maxFailedLoginsPerAccount: ["settings.config.failed.account.label", "Lock an account after"],
|
|
107
|
+
lockoutWindowMinutes: ["settings.config.failed.window.label", "Count failed sign-ins within"],
|
|
108
|
+
lockoutDurationMinutes: ["settings.config.failed.duration.label", "Lock for"],
|
|
109
|
+
lockoutTrustedAddresses: ["settings.config.failed.trusted.label", "Trusted addresses"],
|
|
110
|
+
lockoutNotifyUser: [
|
|
111
|
+
"settings.config.failed.notify.label",
|
|
112
|
+
"Email the user when their account is locked"
|
|
113
|
+
],
|
|
114
|
+
recordUserSignInEvents: [
|
|
115
|
+
"settings.config.failed.record.label",
|
|
116
|
+
"Record failed and refused sign-ins"
|
|
117
|
+
],
|
|
118
|
+
maxSessionsPerUser: ["settings.config.sessionLimit.max.label", "Open sessions per user"],
|
|
119
|
+
sessionLimitPolicy: ["settings.config.sessionLimit.policy.label", "When the limit is reached"],
|
|
120
|
+
endOtherSessionsOnPasswordChange: [
|
|
121
|
+
"settings.config.passwordChange.label",
|
|
122
|
+
"End other sessions after a password change"
|
|
123
|
+
],
|
|
124
|
+
roleRules: ["settings.roleRules.title", "Different rules for some roles"],
|
|
95
125
|
trustedProxies: ["settings.config.clientIp.trustProxy.label", "Trust proxy headers"],
|
|
96
126
|
blockSuspiciousSessions: [
|
|
97
127
|
"settings.config.suspicious.reject.label",
|
|
@@ -737,6 +767,441 @@ const TermList = ({ items, label, code = false }) => /* @__PURE__ */ jsxRuntime.
|
|
|
737
767
|
) }),
|
|
738
768
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral700", children: item.description }) })
|
|
739
769
|
] }, item.id)) });
|
|
770
|
+
const POLICY_FORM_DEFAULTS = Object.freeze({
|
|
771
|
+
maxFailedLoginsPerAccount: 0,
|
|
772
|
+
lockoutWindowMinutes: 15,
|
|
773
|
+
lockoutDurationMinutes: 15,
|
|
774
|
+
lockoutTrustedAddresses: Object.freeze([]),
|
|
775
|
+
lockoutNotifyUser: false,
|
|
776
|
+
recordUserSignInEvents: true,
|
|
777
|
+
maxSessionsPerUser: 0,
|
|
778
|
+
sessionLimitPolicy: "end-oldest",
|
|
779
|
+
endOtherSessionsOnPasswordChange: true,
|
|
780
|
+
roleRules: Object.freeze([])
|
|
781
|
+
});
|
|
782
|
+
const POLICY_RANGES = Object.freeze({
|
|
783
|
+
maxFailedLoginsPerAccount: Object.freeze({ min: 0, max: 100 }),
|
|
784
|
+
lockoutWindowMinutes: Object.freeze({ min: 1, max: 1440 }),
|
|
785
|
+
lockoutDurationMinutes: Object.freeze({ min: 1, max: 10080 }),
|
|
786
|
+
maxSessionsPerUser: Object.freeze({ min: 0, max: 100 })
|
|
787
|
+
});
|
|
788
|
+
const ROLE_RULE_RANGES = Object.freeze({
|
|
789
|
+
maxSessionsPerUser: Object.freeze({ min: 0, max: 100 }),
|
|
790
|
+
inactivityTimeout: Object.freeze({ min: 1, max: 1440 }),
|
|
791
|
+
maxFailedLoginsPerAccount: Object.freeze({ min: 0, max: 100 })
|
|
792
|
+
});
|
|
793
|
+
const ROLE_RULE_FIELDS = Object.freeze(Object.keys(ROLE_RULE_RANGES));
|
|
794
|
+
const MAX_TRUSTED_ADDRESSES = 100;
|
|
795
|
+
const message$1 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
|
|
796
|
+
function validateWholeNumber(value, { min, max }) {
|
|
797
|
+
if (value === void 0 || value === null || value === "") {
|
|
798
|
+
return message$1("settings.validation.required", "Enter a value.");
|
|
799
|
+
}
|
|
800
|
+
const number = Number(value);
|
|
801
|
+
if (!Number.isInteger(number) || number < min || number > max) {
|
|
802
|
+
return message$1("settings.validation.range", "Enter a whole number from {min} to {max}.", {
|
|
803
|
+
min,
|
|
804
|
+
max
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
const IPV4 = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
|
|
810
|
+
const IPV6_CHARS = /^[0-9a-f:.]{2,45}$/i;
|
|
811
|
+
function isTrustedAddressLine(line) {
|
|
812
|
+
const value = String(line || "").trim();
|
|
813
|
+
if (!value || value.length > 64) return false;
|
|
814
|
+
const [address, prefix, extra] = value.split("/");
|
|
815
|
+
if (extra !== void 0) return false;
|
|
816
|
+
const v4 = IPV4.test(address);
|
|
817
|
+
const v6 = !v4 && address.includes(":") && IPV6_CHARS.test(address) && !address.includes(":::");
|
|
818
|
+
if (!v4 && !v6) return false;
|
|
819
|
+
if (prefix === void 0) return true;
|
|
820
|
+
if (!/^\d{1,3}$/.test(prefix)) return false;
|
|
821
|
+
return Number(prefix) <= (v4 ? 32 : 128);
|
|
822
|
+
}
|
|
823
|
+
function parseTrustedAddressText(text) {
|
|
824
|
+
return String(text || "").split(/[\n,]/).map((line) => line.trim()).filter(Boolean);
|
|
825
|
+
}
|
|
826
|
+
function formatTrustedAddressText(list) {
|
|
827
|
+
return Array.isArray(list) ? list.join("\n") : "";
|
|
828
|
+
}
|
|
829
|
+
function validatePolicyFields(settings) {
|
|
830
|
+
const source = settings || {};
|
|
831
|
+
const errors = {};
|
|
832
|
+
for (const [key, range] of Object.entries(POLICY_RANGES)) {
|
|
833
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
|
|
834
|
+
const error = validateWholeNumber(source[key], range);
|
|
835
|
+
if (error) errors[key] = error;
|
|
836
|
+
}
|
|
837
|
+
const entries = Array.isArray(source.lockoutTrustedAddresses) ? source.lockoutTrustedAddresses : [];
|
|
838
|
+
if (entries.length > MAX_TRUSTED_ADDRESSES) {
|
|
839
|
+
errors.lockoutTrustedAddresses = message$1(
|
|
840
|
+
"settings.validation.trustedTooMany",
|
|
841
|
+
"Enter at most {max} addresses.",
|
|
842
|
+
{ max: MAX_TRUSTED_ADDRESSES }
|
|
843
|
+
);
|
|
844
|
+
} else {
|
|
845
|
+
const invalid = entries.find((entry) => !isTrustedAddressLine(entry));
|
|
846
|
+
if (invalid !== void 0) {
|
|
847
|
+
errors.lockoutTrustedAddresses = message$1(
|
|
848
|
+
"settings.validation.trustedAddress",
|
|
849
|
+
'"{value}" is not an IP address or CIDR range. Use for example 192.0.2.10 or 192.0.2.0/24.',
|
|
850
|
+
{ value: String(invalid).slice(0, 64) }
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return errors;
|
|
855
|
+
}
|
|
856
|
+
function validateRoleRule(draft, takenRoles = []) {
|
|
857
|
+
const errors = {};
|
|
858
|
+
if (!draft?.role) {
|
|
859
|
+
errors.role = message$1("settings.roleRules.validation.role", "Choose a role.");
|
|
860
|
+
} else if (takenRoles.includes(draft.role)) {
|
|
861
|
+
errors.role = message$1(
|
|
862
|
+
"settings.roleRules.validation.duplicate",
|
|
863
|
+
"This role already has a rule."
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
let values = 0;
|
|
867
|
+
for (const field of ROLE_RULE_FIELDS) {
|
|
868
|
+
const value = draft?.[field];
|
|
869
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
870
|
+
const error = validateWholeNumber(value, ROLE_RULE_RANGES[field]);
|
|
871
|
+
if (error) errors[field] = error;
|
|
872
|
+
else values += 1;
|
|
873
|
+
}
|
|
874
|
+
if (values === 0 && !ROLE_RULE_FIELDS.some((field) => errors[field])) {
|
|
875
|
+
errors.form = message$1(
|
|
876
|
+
"settings.roleRules.validation.empty",
|
|
877
|
+
"Set at least one value. Empty fields use the general setting."
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
return errors;
|
|
881
|
+
}
|
|
882
|
+
function toRoleRule(draft) {
|
|
883
|
+
const rule = { role: draft.role };
|
|
884
|
+
for (const field of ROLE_RULE_FIELDS) {
|
|
885
|
+
const value = draft[field];
|
|
886
|
+
rule[field] = value === void 0 || value === null || value === "" ? null : Number(value);
|
|
887
|
+
}
|
|
888
|
+
return rule;
|
|
889
|
+
}
|
|
890
|
+
function upsertRoleRule(rules, rule, previousRole = null) {
|
|
891
|
+
const list = Array.isArray(rules) ? rules : [];
|
|
892
|
+
const key = previousRole || rule.role;
|
|
893
|
+
const index2 = list.findIndex((candidate) => candidate.role === key);
|
|
894
|
+
if (index2 === -1) return [...list, rule];
|
|
895
|
+
return list.map((candidate, position) => position === index2 ? rule : candidate);
|
|
896
|
+
}
|
|
897
|
+
function removeRoleRule(rules, role) {
|
|
898
|
+
return (Array.isArray(rules) ? rules : []).filter((rule) => rule.role !== role);
|
|
899
|
+
}
|
|
900
|
+
function sortLocks(locks) {
|
|
901
|
+
return (Array.isArray(locks) ? locks : []).slice().sort((a, b) => {
|
|
902
|
+
const until = Date.parse(b.until) - Date.parse(a.until);
|
|
903
|
+
return Number.isFinite(until) && until !== 0 ? until : String(a.id).localeCompare(b.id);
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
const TABLE_MIN_WIDTH$1 = 640;
|
|
907
|
+
const keepActionKeys$1 = (event) => {
|
|
908
|
+
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
909
|
+
};
|
|
910
|
+
const EMPTY_DRAFT = Object.freeze({
|
|
911
|
+
role: "",
|
|
912
|
+
maxSessionsPerUser: void 0,
|
|
913
|
+
inactivityTimeout: void 0,
|
|
914
|
+
maxFailedLoginsPerAccount: void 0
|
|
915
|
+
});
|
|
916
|
+
const RuleValue = ({ value, format }) => {
|
|
917
|
+
const { t } = useSettingsTranslate();
|
|
918
|
+
if (value === null || value === void 0) {
|
|
919
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.roleRules.general", "General setting") });
|
|
920
|
+
}
|
|
921
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: format(value) });
|
|
922
|
+
};
|
|
923
|
+
const RoleRulesSection = ({ form }) => {
|
|
924
|
+
const { t, tError } = useSettingsTranslate();
|
|
925
|
+
const { get } = StrapiAdmin.useFetchClient();
|
|
926
|
+
const { settings, handleChange } = form;
|
|
927
|
+
const locked = form.canChangeProtected === false;
|
|
928
|
+
const rules = Array.isArray(settings.roleRules) ? settings.roleRules : [];
|
|
929
|
+
const [roles, setRoles] = react.useState(null);
|
|
930
|
+
const [rolesError, setRolesError] = react.useState(false);
|
|
931
|
+
const [dialog, setDialog] = react.useState(null);
|
|
932
|
+
const [draft, setDraft] = react.useState(EMPTY_DRAFT);
|
|
933
|
+
const [showErrors, setShowErrors] = react.useState(false);
|
|
934
|
+
const addRef = react.useRef(null);
|
|
935
|
+
const returnFocusRef = react.useRef(null);
|
|
936
|
+
const [widthRef, width] = dashboardModel.useElementWidth();
|
|
937
|
+
react.useEffect(() => {
|
|
938
|
+
let active = true;
|
|
939
|
+
get(`/${index.pluginId}/roles`).then(({ data }) => {
|
|
940
|
+
if (!active) return;
|
|
941
|
+
if (!Array.isArray(data?.data)) throw new Error("Invalid role list");
|
|
942
|
+
setRoles(data.data);
|
|
943
|
+
}).catch((err) => {
|
|
944
|
+
if (!active || index.isCancelledRequest(err)) return;
|
|
945
|
+
index.logSafeAdminError("roles", err);
|
|
946
|
+
setRolesError(true);
|
|
947
|
+
});
|
|
948
|
+
return () => {
|
|
949
|
+
active = false;
|
|
950
|
+
};
|
|
951
|
+
}, [get]);
|
|
952
|
+
const roleName = (documentId) => roles?.find((role) => role.documentId === documentId)?.name || t("settings.roleRules.unknownRole", "Removed role");
|
|
953
|
+
const minutes = (value) => t("settings.roleRules.minutes", "{count, plural, one {# minute} other {# minutes}}", {
|
|
954
|
+
count: value
|
|
955
|
+
});
|
|
956
|
+
const sessions = (value) => value === 0 ? t("settings.roleRules.noLimit", "No limit") : t("settings.roleRules.sessions", "{count, plural, one {# session} other {# sessions}}", {
|
|
957
|
+
count: value
|
|
958
|
+
});
|
|
959
|
+
const failures = (value) => value === 0 ? t("settings.roleRules.noAccountLock", "Off") : t("settings.roleRules.failures", "{count, plural, one {# failure} other {# failures}}", {
|
|
960
|
+
count: value
|
|
961
|
+
});
|
|
962
|
+
const open = (rule, trigger) => {
|
|
963
|
+
returnFocusRef.current = trigger || addRef.current;
|
|
964
|
+
setShowErrors(false);
|
|
965
|
+
setDraft(
|
|
966
|
+
rule ? {
|
|
967
|
+
role: rule.role,
|
|
968
|
+
maxSessionsPerUser: rule.maxSessionsPerUser ?? void 0,
|
|
969
|
+
inactivityTimeout: rule.inactivityTimeout ?? void 0,
|
|
970
|
+
maxFailedLoginsPerAccount: rule.maxFailedLoginsPerAccount ?? void 0
|
|
971
|
+
} : EMPTY_DRAFT
|
|
972
|
+
);
|
|
973
|
+
setDialog({ editing: rule ? rule.role : null });
|
|
974
|
+
};
|
|
975
|
+
const close = () => {
|
|
976
|
+
setDialog(null);
|
|
977
|
+
window.requestAnimationFrame?.(() => {
|
|
978
|
+
const target = returnFocusRef.current?.isConnected ? returnFocusRef.current : addRef.current;
|
|
979
|
+
target?.focus?.();
|
|
980
|
+
});
|
|
981
|
+
};
|
|
982
|
+
const taken = rules.map((rule) => rule.role).filter((role) => role !== dialog?.editing);
|
|
983
|
+
const draftErrors = validateRoleRule(draft, taken);
|
|
984
|
+
const submit = () => {
|
|
985
|
+
if (Object.keys(draftErrors).length > 0) {
|
|
986
|
+
setShowErrors(true);
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
handleChange("roleRules", upsertRoleRule(rules, toRoleRule(draft), dialog?.editing));
|
|
990
|
+
close();
|
|
991
|
+
};
|
|
992
|
+
const fieldError = (key) => showErrors ? tError(draftErrors[key]) : void 0;
|
|
993
|
+
const availableRoles = (roles || []).filter((role) => !taken.includes(role.documentId));
|
|
994
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
|
|
995
|
+
const actions = (rule) => {
|
|
996
|
+
const name = roleName(rule.role);
|
|
997
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys$1, children: [
|
|
998
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
999
|
+
designSystem.IconButton,
|
|
1000
|
+
{
|
|
1001
|
+
variant: "ghost",
|
|
1002
|
+
disabled: locked,
|
|
1003
|
+
label: t("settings.roleRules.edit", "Edit the rule for {role}", { role: name }),
|
|
1004
|
+
onClick: (event) => open(rule, event.currentTarget),
|
|
1005
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
|
1006
|
+
}
|
|
1007
|
+
),
|
|
1008
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1009
|
+
designSystem.IconButton,
|
|
1010
|
+
{
|
|
1011
|
+
variant: "ghost",
|
|
1012
|
+
disabled: locked,
|
|
1013
|
+
label: t("settings.roleRules.remove", "Remove the rule for {role}", { role: name }),
|
|
1014
|
+
onClick: () => {
|
|
1015
|
+
handleChange("roleRules", removeRoleRule(rules, rule.role));
|
|
1016
|
+
window.requestAnimationFrame?.(() => addRef.current?.focus?.());
|
|
1017
|
+
},
|
|
1018
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
1019
|
+
}
|
|
1020
|
+
)
|
|
1021
|
+
] });
|
|
1022
|
+
};
|
|
1023
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1024
|
+
AdvancedSection,
|
|
1025
|
+
{
|
|
1026
|
+
label: t("settings.roleRules.title", "Different rules for some roles"),
|
|
1027
|
+
hasError: Object.keys(form.errors || {}).some((key) => key.startsWith("roleRules")),
|
|
1028
|
+
children: [
|
|
1029
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
1030
|
+
"settings.roleRules.intro",
|
|
1031
|
+
"Give a Users & Permissions role its own session limit, inactivity timeout or account lockout. Empty values use the general setting. The overview still counts sessions as idle by the general timeout."
|
|
1032
|
+
) }),
|
|
1033
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
1034
|
+
rolesError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1035
|
+
index.PersistentAlert,
|
|
1036
|
+
{
|
|
1037
|
+
variant: "warning",
|
|
1038
|
+
closeLabel: t("common.close", "Close"),
|
|
1039
|
+
title: t("settings.roleRules.rolesError", "Roles could not be loaded."),
|
|
1040
|
+
children: t(
|
|
1041
|
+
"settings.roleRules.rolesErrorBody",
|
|
1042
|
+
"Existing rules still apply. Reload the page to add or edit rules."
|
|
1043
|
+
)
|
|
1044
|
+
}
|
|
1045
|
+
) : null,
|
|
1046
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: widthRef, children: rules.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", tag: "p", children: t(
|
|
1047
|
+
"settings.roleRules.empty",
|
|
1048
|
+
"No role has its own rules. Every role uses the general settings."
|
|
1049
|
+
) }) : asTable ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", "data-role-rules-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: rules.length + 1, children: [
|
|
1050
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
1051
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.role", "Role") }) }),
|
|
1052
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.sessions", "Session limit") }) }),
|
|
1053
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.idle", "Inactivity timeout") }) }),
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.lockout", "Account lockout") }) }),
|
|
1055
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("settings.roleRules.col.actions", "Actions") }) })
|
|
1056
|
+
] }) }),
|
|
1057
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-role-rule": rule.role, children: [
|
|
1058
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: roleName(rule.role) }) }),
|
|
1059
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.maxSessionsPerUser, format: sessions }) }),
|
|
1060
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.inactivityTimeout, format: minutes }) }),
|
|
1061
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.maxFailedLoginsPerAccount, format: failures }) }),
|
|
1062
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: actions(rule) })
|
|
1063
|
+
] }, rule.role)) })
|
|
1064
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", children: rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1065
|
+
designSystem.Box,
|
|
1066
|
+
{
|
|
1067
|
+
tag: "li",
|
|
1068
|
+
padding: 4,
|
|
1069
|
+
hasRadius: true,
|
|
1070
|
+
borderColor: "neutral150",
|
|
1071
|
+
"data-role-rule": rule.role,
|
|
1072
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
|
|
1073
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
1074
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: roleName(rule.role) }),
|
|
1075
|
+
[
|
|
1076
|
+
[
|
|
1077
|
+
"settings.roleRules.col.sessions",
|
|
1078
|
+
"Session limit",
|
|
1079
|
+
rule.maxSessionsPerUser,
|
|
1080
|
+
sessions
|
|
1081
|
+
],
|
|
1082
|
+
[
|
|
1083
|
+
"settings.roleRules.col.idle",
|
|
1084
|
+
"Inactivity timeout",
|
|
1085
|
+
rule.inactivityTimeout,
|
|
1086
|
+
minutes
|
|
1087
|
+
],
|
|
1088
|
+
[
|
|
1089
|
+
"settings.roleRules.col.lockout",
|
|
1090
|
+
"Account lockout",
|
|
1091
|
+
rule.maxFailedLoginsPerAccount,
|
|
1092
|
+
failures
|
|
1093
|
+
]
|
|
1094
|
+
].map(([id, label, value, format]) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.roleRules.line", "{label}: {value}", {
|
|
1095
|
+
label: t(id, label),
|
|
1096
|
+
value: value === null || value === void 0 ? t("settings.roleRules.general", "General setting") : format(value)
|
|
1097
|
+
}) }, id))
|
|
1098
|
+
] }),
|
|
1099
|
+
actions(rule)
|
|
1100
|
+
] })
|
|
1101
|
+
},
|
|
1102
|
+
rule.role
|
|
1103
|
+
)) }) }),
|
|
1104
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, wrap: "wrap", alignItems: "center", children: [
|
|
1105
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1106
|
+
designSystem.Button,
|
|
1107
|
+
{
|
|
1108
|
+
ref: addRef,
|
|
1109
|
+
variant: "secondary",
|
|
1110
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
1111
|
+
disabled: locked || roles !== null && availableRoles.length === 0 && !dialog,
|
|
1112
|
+
onClick: () => open(null, addRef.current),
|
|
1113
|
+
children: t("settings.roleRules.add", "Add rule")
|
|
1114
|
+
}
|
|
1115
|
+
),
|
|
1116
|
+
roles !== null && roles.length > 0 && availableRoles.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", "data-role-rules-full": "", children: t(
|
|
1117
|
+
"settings.roleRules.allRoles",
|
|
1118
|
+
"Every role already has a rule. Edit a rule to change it."
|
|
1119
|
+
) }) : null
|
|
1120
|
+
] }),
|
|
1121
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: Boolean(dialog), onOpenChange: (next) => next ? null : close(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { "aria-describedby": void 0, children: [
|
|
1122
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: dialog?.editing ? t("settings.roleRules.dialog.editTitle", "Edit the rule for {role}", {
|
|
1123
|
+
role: roleName(dialog.editing)
|
|
1124
|
+
}) : t("settings.roleRules.dialog.addTitle", "Add a rule for a role") }) }),
|
|
1125
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 5, children: [
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
+
FormField,
|
|
1128
|
+
{
|
|
1129
|
+
id: "role-rule-role",
|
|
1130
|
+
name: "role",
|
|
1131
|
+
label: t("settings.roleRules.col.role", "Role"),
|
|
1132
|
+
error: fieldError("role"),
|
|
1133
|
+
required: true,
|
|
1134
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1135
|
+
designSystem.SingleSelect,
|
|
1136
|
+
{
|
|
1137
|
+
value: draft.role || void 0,
|
|
1138
|
+
placeholder: t("settings.roleRules.dialog.rolePlaceholder", "Choose a role"),
|
|
1139
|
+
onChange: (value) => setDraft((previous) => ({ ...previous, role: value })),
|
|
1140
|
+
children: (roles || []).filter(
|
|
1141
|
+
(role) => role.documentId === draft.role || !taken.includes(role.documentId)
|
|
1142
|
+
).map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: role.documentId, children: role.name }, role.documentId))
|
|
1143
|
+
}
|
|
1144
|
+
)
|
|
1145
|
+
}
|
|
1146
|
+
),
|
|
1147
|
+
[
|
|
1148
|
+
[
|
|
1149
|
+
"maxSessionsPerUser",
|
|
1150
|
+
"role-rule-sessions",
|
|
1151
|
+
t("settings.config.sessionLimit.max.label", "Open sessions per user"),
|
|
1152
|
+
t("settings.roleRules.dialog.sessionsHint", "0 means no limit for this role."),
|
|
1153
|
+
t("settings.roleRules.dialog.sessionsSuffix", "sessions")
|
|
1154
|
+
],
|
|
1155
|
+
[
|
|
1156
|
+
"inactivityTimeout",
|
|
1157
|
+
"role-rule-idle",
|
|
1158
|
+
t("settings.config.sessions.inactivity.label", "Inactivity timeout"),
|
|
1159
|
+
t("settings.roleRules.dialog.idleHint", "From 1 to 1440 minutes."),
|
|
1160
|
+
t("settings.config.failed.minutes.suffix", "minutes")
|
|
1161
|
+
],
|
|
1162
|
+
[
|
|
1163
|
+
"maxFailedLoginsPerAccount",
|
|
1164
|
+
"role-rule-lockout",
|
|
1165
|
+
t("settings.config.failed.account.label", "Lock an account after"),
|
|
1166
|
+
t(
|
|
1167
|
+
"settings.roleRules.dialog.lockoutHint",
|
|
1168
|
+
"0 turns the account lockout off for this role."
|
|
1169
|
+
),
|
|
1170
|
+
t("settings.config.failed.lockout.suffix", "failed sign-ins")
|
|
1171
|
+
]
|
|
1172
|
+
].map(([key, id, label, hint, suffix]) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1173
|
+
FormField,
|
|
1174
|
+
{
|
|
1175
|
+
id,
|
|
1176
|
+
name: key,
|
|
1177
|
+
label,
|
|
1178
|
+
description: `${hint} ${t("settings.roleRules.dialog.emptyHint", "Leave empty to use the general setting.")}`,
|
|
1179
|
+
suffix,
|
|
1180
|
+
error: fieldError(key),
|
|
1181
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1182
|
+
designSystem.NumberInput,
|
|
1183
|
+
{
|
|
1184
|
+
value: draft[key],
|
|
1185
|
+
onValueChange: (value) => setDraft((previous) => ({ ...previous, [key]: value })),
|
|
1186
|
+
min: ROLE_RULE_RANGES[key].min,
|
|
1187
|
+
max: ROLE_RULE_RANGES[key].max,
|
|
1188
|
+
step: 1
|
|
1189
|
+
}
|
|
1190
|
+
)
|
|
1191
|
+
},
|
|
1192
|
+
key
|
|
1193
|
+
)),
|
|
1194
|
+
showErrors && draftErrors.form ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", tag: "p", role: "alert", children: tError(draftErrors.form) }) : null
|
|
1195
|
+
] }) }),
|
|
1196
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
1197
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.cancel", "Cancel") }) }),
|
|
1198
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: submit, children: dialog?.editing ? t("settings.roleRules.dialog.apply", "Apply") : t("settings.roleRules.dialog.add", "Add rule") })
|
|
1199
|
+
] })
|
|
1200
|
+
] }) })
|
|
1201
|
+
]
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
};
|
|
740
1205
|
const REJECTION_REASONS = [
|
|
741
1206
|
["logout", "settings.config.rejected.reason.logout", "The user signed out."],
|
|
742
1207
|
[
|
|
@@ -767,10 +1232,12 @@ const formatReasonCodes = (locale) => {
|
|
|
767
1232
|
}
|
|
768
1233
|
};
|
|
769
1234
|
const SessionsTab = ({ form }) => {
|
|
770
|
-
const { t, locale } = useSettingsTranslate();
|
|
1235
|
+
const { t, tError, locale } = useSettingsTranslate();
|
|
771
1236
|
const units = useOptionLabels();
|
|
772
1237
|
const encryptionKeyDraft = useEncryptionKeyDraft();
|
|
773
|
-
const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed } = form;
|
|
1238
|
+
const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed, errors } = form;
|
|
1239
|
+
const sessionLimit = Number(settings.maxSessionsPerUser) || 0;
|
|
1240
|
+
const locked = form.canChangeProtected === false;
|
|
774
1241
|
const lastSeenTooSlow = Number(settings.lastSeenRateLimit) * 2 > Number(settings.inactivityTimeout) * 60;
|
|
775
1242
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
776
1243
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
@@ -961,6 +1428,127 @@ const SessionsTab = ({ form }) => {
|
|
|
961
1428
|
]
|
|
962
1429
|
}
|
|
963
1430
|
),
|
|
1431
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1432
|
+
SectionCard.SectionCard,
|
|
1433
|
+
{
|
|
1434
|
+
id: "session-limit",
|
|
1435
|
+
title: t("settings.config.sessionLimit.title", "Concurrent sessions"),
|
|
1436
|
+
subtitle: t(
|
|
1437
|
+
"settings.config.sessionLimit.intro",
|
|
1438
|
+
"Limits how many sessions one user can have open at the same time."
|
|
1439
|
+
),
|
|
1440
|
+
children: [
|
|
1441
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
1442
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1443
|
+
FormField,
|
|
1444
|
+
{
|
|
1445
|
+
id: "max-sessions-per-user",
|
|
1446
|
+
name: "maxSessionsPerUser",
|
|
1447
|
+
label: t("settings.config.sessionLimit.max.label", "Open sessions per user"),
|
|
1448
|
+
description: t(
|
|
1449
|
+
"settings.config.sessionLimit.max.hint",
|
|
1450
|
+
"0 means no limit. Sessions that are idle or past their maximum age do not count."
|
|
1451
|
+
),
|
|
1452
|
+
suffix: t("settings.roleRules.dialog.sessionsSuffix", "sessions"),
|
|
1453
|
+
error: tError(errors.maxSessionsPerUser),
|
|
1454
|
+
required: true,
|
|
1455
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1456
|
+
designSystem.NumberInput,
|
|
1457
|
+
{
|
|
1458
|
+
value: settings.maxSessionsPerUser,
|
|
1459
|
+
onValueChange: (value) => handleChange("maxSessionsPerUser", value ?? ""),
|
|
1460
|
+
disabled: locked,
|
|
1461
|
+
min: POLICY_RANGES.maxSessionsPerUser.min,
|
|
1462
|
+
max: POLICY_RANGES.maxSessionsPerUser.max,
|
|
1463
|
+
step: 1
|
|
1464
|
+
},
|
|
1465
|
+
form.draftVersion
|
|
1466
|
+
)
|
|
1467
|
+
}
|
|
1468
|
+
) }),
|
|
1469
|
+
sessionLimit > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-session-limit-policy": "", children: [
|
|
1470
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1471
|
+
designSystem.Typography,
|
|
1472
|
+
{
|
|
1473
|
+
id: "session-limit-policy-label",
|
|
1474
|
+
variant: "pi",
|
|
1475
|
+
fontWeight: "bold",
|
|
1476
|
+
tag: "div",
|
|
1477
|
+
textColor: "neutral800",
|
|
1478
|
+
children: t("settings.config.sessionLimit.policy.label", "When the limit is reached")
|
|
1479
|
+
}
|
|
1480
|
+
),
|
|
1481
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1482
|
+
designSystem.Radio.Group,
|
|
1483
|
+
{
|
|
1484
|
+
"aria-labelledby": "session-limit-policy-label",
|
|
1485
|
+
value: settings.sessionLimitPolicy || "end-oldest",
|
|
1486
|
+
disabled: locked,
|
|
1487
|
+
onValueChange: (value) => handleChange("sessionLimitPolicy", value),
|
|
1488
|
+
children: [
|
|
1489
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "end-oldest", children: t("settings.config.sessionLimit.policy.endOldest", "End the oldest session") }),
|
|
1490
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "refuse", children: t("settings.config.sessionLimit.policy.refuse", "Refuse the new sign-in") })
|
|
1491
|
+
]
|
|
1492
|
+
}
|
|
1493
|
+
),
|
|
1494
|
+
settings.sessionLimitPolicy === "refuse" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1495
|
+
designSystem.Alert,
|
|
1496
|
+
{
|
|
1497
|
+
variant: "warning",
|
|
1498
|
+
closeLabel: t("common.close", "Close"),
|
|
1499
|
+
title: t(
|
|
1500
|
+
"settings.config.sessionLimit.refuse.title",
|
|
1501
|
+
"Users can lock themselves out"
|
|
1502
|
+
),
|
|
1503
|
+
children: t(
|
|
1504
|
+
"settings.config.sessionLimit.refuse.body",
|
|
1505
|
+
"A user who reaches the limit cannot sign in on a new device until another session ends or times out. The app receives 403 with the code SESSION_LIMIT_REACHED."
|
|
1506
|
+
)
|
|
1507
|
+
}
|
|
1508
|
+
) : null
|
|
1509
|
+
] }) : null
|
|
1510
|
+
]
|
|
1511
|
+
}
|
|
1512
|
+
),
|
|
1513
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1514
|
+
SectionCard.SectionCard,
|
|
1515
|
+
{
|
|
1516
|
+
id: "password-change",
|
|
1517
|
+
title: t("settings.config.passwordChange.title", "Password change"),
|
|
1518
|
+
children: [
|
|
1519
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
1520
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1521
|
+
SettingsToggleRow,
|
|
1522
|
+
{
|
|
1523
|
+
id: "end-other-sessions-on-password-change",
|
|
1524
|
+
title: t(
|
|
1525
|
+
"settings.config.passwordChange.label",
|
|
1526
|
+
"End other sessions after a password change"
|
|
1527
|
+
),
|
|
1528
|
+
description: t(
|
|
1529
|
+
"settings.config.passwordChange.hint",
|
|
1530
|
+
"When a user changes their password, every other session of that user ends. The session that made the change stays. A password reset always ends the other sessions."
|
|
1531
|
+
),
|
|
1532
|
+
checked: settings.endOtherSessionsOnPasswordChange === true,
|
|
1533
|
+
disabled: locked,
|
|
1534
|
+
onChange: (checked) => handleChange("endOtherSessionsOnPasswordChange", checked)
|
|
1535
|
+
}
|
|
1536
|
+
)
|
|
1537
|
+
]
|
|
1538
|
+
}
|
|
1539
|
+
),
|
|
1540
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1541
|
+
SectionCard.SectionCard,
|
|
1542
|
+
{
|
|
1543
|
+
id: "role-rules",
|
|
1544
|
+
title: t("settings.roleRules.cardTitle", "Roles"),
|
|
1545
|
+
subtitle: t(
|
|
1546
|
+
"settings.roleRules.cardIntro",
|
|
1547
|
+
"Optional. Most installations need no role rules."
|
|
1548
|
+
),
|
|
1549
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RoleRulesSection, { form })
|
|
1550
|
+
}
|
|
1551
|
+
),
|
|
964
1552
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
965
1553
|
SectionCard.SectionCard,
|
|
966
1554
|
{
|
|
@@ -1014,7 +1602,12 @@ function areSettingsEqual(left, right) {
|
|
|
1014
1602
|
(key, index2) => key === rightKeys[index2] && areSettingsEqual(left[key], right[key])
|
|
1015
1603
|
);
|
|
1016
1604
|
}
|
|
1017
|
-
const TEMPLATE_KEYS = Object.freeze([
|
|
1605
|
+
const TEMPLATE_KEYS = Object.freeze([
|
|
1606
|
+
"suspiciousLogin",
|
|
1607
|
+
"newLocation",
|
|
1608
|
+
"vpnProxy",
|
|
1609
|
+
"accountLocked"
|
|
1610
|
+
]);
|
|
1018
1611
|
const TEMPLATE_LIMITS = Object.freeze({ subject: 200, html: 1e4, text: 5e3 });
|
|
1019
1612
|
const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
|
|
1020
1613
|
"{{user.email}}": {
|
|
@@ -1064,6 +1657,14 @@ const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
|
|
|
1064
1657
|
"{{reason.securityScore}}": {
|
|
1065
1658
|
messageId: "settings.email.templates.variable.securityScore",
|
|
1066
1659
|
defaultMessage: "Security score (0 to 100)"
|
|
1660
|
+
},
|
|
1661
|
+
"{{lock.minutes}}": {
|
|
1662
|
+
messageId: "settings.email.templates.variable.lockMinutes",
|
|
1663
|
+
defaultMessage: "Lock duration in minutes"
|
|
1664
|
+
},
|
|
1665
|
+
"{{lock.until}}": {
|
|
1666
|
+
messageId: "settings.email.templates.variable.lockUntil",
|
|
1667
|
+
defaultMessage: "Time the lock ends (UTC)"
|
|
1067
1668
|
}
|
|
1068
1669
|
});
|
|
1069
1670
|
const TEMPLATE_VARIABLES = Object.freeze({
|
|
@@ -1101,7 +1702,8 @@ const TEMPLATE_VARIABLES = Object.freeze({
|
|
|
1101
1702
|
"{{session.userAgent}}",
|
|
1102
1703
|
"{{reason.isVpn}}",
|
|
1103
1704
|
"{{reason.isProxy}}"
|
|
1104
|
-
]
|
|
1705
|
+
],
|
|
1706
|
+
accountLocked: ["{{user.email}}", "{{user.username}}", "{{lock.minutes}}", "{{lock.until}}"]
|
|
1105
1707
|
});
|
|
1106
1708
|
const TEMPLATE_PREVIEW_VALUES = Object.freeze({
|
|
1107
1709
|
"{{user.email}}": "jane.doe@example.com",
|
|
@@ -1115,7 +1717,9 @@ const TEMPLATE_PREVIEW_VALUES = Object.freeze({
|
|
|
1115
1717
|
"{{reason.isVpn}}": "true",
|
|
1116
1718
|
"{{reason.isProxy}}": "false",
|
|
1117
1719
|
"{{reason.isThreat}}": "false",
|
|
1118
|
-
"{{reason.securityScore}}": "35"
|
|
1720
|
+
"{{reason.securityScore}}": "35",
|
|
1721
|
+
"{{lock.minutes}}": "15",
|
|
1722
|
+
"{{lock.until}}": "Fri, 06 Nov 2026 09:56:00 GMT"
|
|
1119
1723
|
});
|
|
1120
1724
|
function updateEmailTemplate(templates, templateKey, field, value) {
|
|
1121
1725
|
return { ...templates, [templateKey]: { ...templates[templateKey], [field]: value } };
|
|
@@ -1376,6 +1980,28 @@ Login Details:
|
|
|
1376
1980
|
- IP Address: {{session.ipAddress}}
|
|
1377
1981
|
- Location: {{geo.city}}, {{geo.country}}
|
|
1378
1982
|
- VPN: {{reason.isVpn}}, Proxy: {{reason.isProxy}}`
|
|
1983
|
+
},
|
|
1984
|
+
// Same default as server/src/services/notifications.js (4.17).
|
|
1985
|
+
accountLocked: {
|
|
1986
|
+
subject: "Your account was locked after failed sign-ins",
|
|
1987
|
+
html: `<html>
|
|
1988
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
|
1989
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
1990
|
+
<h2>Your account was temporarily locked</h2>
|
|
1991
|
+
<p>Hello {{user.username}},</p>
|
|
1992
|
+
<p>There were several failed sign-in attempts for your account. To protect it, sign-in is locked for {{lock.minutes}} minutes, until {{lock.until}}.</p>
|
|
1993
|
+
<p>If these attempts were not yours, change your password after the lock ends.</p>
|
|
1994
|
+
<p style="color: #666; font-size: 12px;">This is an automated security notification.</p>
|
|
1995
|
+
</div>
|
|
1996
|
+
</body>
|
|
1997
|
+
</html>`,
|
|
1998
|
+
text: `Your account was temporarily locked
|
|
1999
|
+
|
|
2000
|
+
Hello {{user.username}},
|
|
2001
|
+
|
|
2002
|
+
There were several failed sign-in attempts for your account. To protect it, sign-in is locked for {{lock.minutes}} minutes, until {{lock.until}}.
|
|
2003
|
+
|
|
2004
|
+
If these attempts were not yours, change your password after the lock ends.`
|
|
1379
2005
|
}
|
|
1380
2006
|
});
|
|
1381
2007
|
function fillMissingTemplates(templates) {
|
|
@@ -1432,7 +2058,8 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
1432
2058
|
securityLogStoreIp: true,
|
|
1433
2059
|
securityLogAnonymizeIp: false,
|
|
1434
2060
|
securityLogGeoLookup: false,
|
|
1435
|
-
securityLogRetentionDays: 90
|
|
2061
|
+
securityLogRetentionDays: 90,
|
|
2062
|
+
...POLICY_FORM_DEFAULTS
|
|
1436
2063
|
});
|
|
1437
2064
|
const WRITE_ONLY_SETTINGS_KEYS = Object.freeze(["discordWebhookUrl", "slackWebhookUrl"]);
|
|
1438
2065
|
const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
|
|
@@ -1455,6 +2082,8 @@ function normalizeSettings(loaded) {
|
|
|
1455
2082
|
...loaded,
|
|
1456
2083
|
allowedCountries: Array.isArray(loaded.allowedCountries) ? loaded.allowedCountries : [],
|
|
1457
2084
|
blockedCountries: Array.isArray(loaded.blockedCountries) ? loaded.blockedCountries : [],
|
|
2085
|
+
lockoutTrustedAddresses: Array.isArray(loaded.lockoutTrustedAddresses) ? loaded.lockoutTrustedAddresses : [],
|
|
2086
|
+
roleRules: Array.isArray(loaded.roleRules) ? loaded.roleRules : [],
|
|
1458
2087
|
emailTemplates: fillMissingTemplates(loaded.emailTemplates)
|
|
1459
2088
|
};
|
|
1460
2089
|
}
|
|
@@ -1504,6 +2133,7 @@ function validateSettings(settings) {
|
|
|
1504
2133
|
const source = settings || {};
|
|
1505
2134
|
const maxFailed = validateMaxFailedLogins(source.maxFailedLogins);
|
|
1506
2135
|
if (maxFailed) errors.maxFailedLogins = maxFailed;
|
|
2136
|
+
Object.assign(errors, validatePolicyFields(source));
|
|
1507
2137
|
if (!isAllowedWebhookUrl(source.discordWebhookUrl, WEBHOOK_HOSTS.discordWebhookUrl)) {
|
|
1508
2138
|
errors.discordWebhookUrl = message(
|
|
1509
2139
|
"settings.validation.webhookDiscord",
|
|
@@ -1547,6 +2177,312 @@ function getAdjustedFields(submitted, stored, previous) {
|
|
|
1547
2177
|
(key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
|
|
1548
2178
|
);
|
|
1549
2179
|
}
|
|
2180
|
+
const TABLE_MIN_WIDTH = 640;
|
|
2181
|
+
const keepActionKeys = (event) => {
|
|
2182
|
+
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2183
|
+
};
|
|
2184
|
+
const LockTarget = ({ lock }) => {
|
|
2185
|
+
const { t } = useSettingsTranslate();
|
|
2186
|
+
if (lock.kind === "ip") {
|
|
2187
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2188
|
+
designSystem.Typography,
|
|
2189
|
+
{
|
|
2190
|
+
variant: "omega",
|
|
2191
|
+
textColor: "neutral800",
|
|
2192
|
+
tag: "p",
|
|
2193
|
+
style: { overflowWrap: "anywhere" },
|
|
2194
|
+
children: lock.ip || t("settings.lockouts.ipHidden", "IP address not stored")
|
|
2195
|
+
}
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
if (!lock.user) {
|
|
2199
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.lockouts.unknownAccount", "Account that does not exist") });
|
|
2200
|
+
}
|
|
2201
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, width: "100%", children: [
|
|
2202
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2203
|
+
designSystem.Typography,
|
|
2204
|
+
{
|
|
2205
|
+
variant: "omega",
|
|
2206
|
+
fontWeight: "semiBold",
|
|
2207
|
+
textColor: "neutral800",
|
|
2208
|
+
tag: "p",
|
|
2209
|
+
style: { overflowWrap: "anywhere" },
|
|
2210
|
+
children: lock.user.username || lock.user.email
|
|
2211
|
+
}
|
|
2212
|
+
),
|
|
2213
|
+
lock.user.email && lock.user.username ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2214
|
+
designSystem.Typography,
|
|
2215
|
+
{
|
|
2216
|
+
variant: "pi",
|
|
2217
|
+
textColor: "neutral600",
|
|
2218
|
+
tag: "p",
|
|
2219
|
+
style: { overflowWrap: "anywhere" },
|
|
2220
|
+
children: lock.user.email
|
|
2221
|
+
}
|
|
2222
|
+
) : null
|
|
2223
|
+
] });
|
|
2224
|
+
};
|
|
2225
|
+
const KindBadge = ({ kind }) => {
|
|
2226
|
+
const { t } = useSettingsTranslate();
|
|
2227
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: kind === "ip" ? t("settings.lockouts.kind.ip", "IP address") : t("settings.lockouts.kind.account", "Account") });
|
|
2228
|
+
};
|
|
2229
|
+
const lockName = (lock, t) => {
|
|
2230
|
+
if (lock.kind === "ip")
|
|
2231
|
+
return lock.ip || t("settings.lockouts.ipHidden", "IP address not stored");
|
|
2232
|
+
if (lock.user) return lock.user.username || lock.user.email;
|
|
2233
|
+
return t("settings.lockouts.unknownAccount", "Account that does not exist");
|
|
2234
|
+
};
|
|
2235
|
+
const LockedNowCard = () => {
|
|
2236
|
+
const { t } = useSettingsTranslate();
|
|
2237
|
+
const { get, post } = StrapiAdmin.useFetchClient();
|
|
2238
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
2239
|
+
const { formatDate } = index.useSessionFormatters();
|
|
2240
|
+
const {
|
|
2241
|
+
isLoading: permissionsLoading,
|
|
2242
|
+
allowedActions: { canUnlock }
|
|
2243
|
+
} = StrapiAdmin.useRBAC(index.pluginPermissions.lockoutsUnlock);
|
|
2244
|
+
const [widthRef, width] = dashboardModel.useElementWidth();
|
|
2245
|
+
const [locks, setLocks] = react.useState(null);
|
|
2246
|
+
const [error, setError] = react.useState(false);
|
|
2247
|
+
const [refreshing, setRefreshing] = react.useState(false);
|
|
2248
|
+
const refreshRef = react.useRef(null);
|
|
2249
|
+
const requestRef = react.useRef(0);
|
|
2250
|
+
const apply = react.useCallback(async (request, pending) => {
|
|
2251
|
+
try {
|
|
2252
|
+
const { data } = await pending;
|
|
2253
|
+
if (request !== requestRef.current) return;
|
|
2254
|
+
if (!Array.isArray(data?.data)) throw new Error("Invalid lock list");
|
|
2255
|
+
setLocks(sortLocks(data.data));
|
|
2256
|
+
setError(false);
|
|
2257
|
+
} catch (err) {
|
|
2258
|
+
if (index.isCancelledRequest(err) || request !== requestRef.current) return;
|
|
2259
|
+
index.logSafeAdminError("lockouts", err);
|
|
2260
|
+
setError(true);
|
|
2261
|
+
} finally {
|
|
2262
|
+
if (request === requestRef.current) setRefreshing(false);
|
|
2263
|
+
}
|
|
2264
|
+
}, []);
|
|
2265
|
+
const load = react.useCallback(() => {
|
|
2266
|
+
const request = ++requestRef.current;
|
|
2267
|
+
setRefreshing(true);
|
|
2268
|
+
return apply(request, get(`/${index.pluginId}/lockouts`));
|
|
2269
|
+
}, [apply, get]);
|
|
2270
|
+
react.useEffect(() => {
|
|
2271
|
+
apply(++requestRef.current, get(`/${index.pluginId}/lockouts`));
|
|
2272
|
+
}, [apply, get]);
|
|
2273
|
+
const unlock = async (lock) => {
|
|
2274
|
+
try {
|
|
2275
|
+
await post(`/${index.pluginId}/lockouts/unlock`, { id: lock.id });
|
|
2276
|
+
toggleNotification({
|
|
2277
|
+
type: "success",
|
|
2278
|
+
message: t("settings.lockouts.unlocked", "{name} was unlocked.", {
|
|
2279
|
+
name: lockName(lock, t)
|
|
2280
|
+
})
|
|
2281
|
+
});
|
|
2282
|
+
} catch (err) {
|
|
2283
|
+
if (err?.response?.status === 404) {
|
|
2284
|
+
toggleNotification({
|
|
2285
|
+
type: "info",
|
|
2286
|
+
message: t("settings.lockouts.alreadyEnded", "This lock had already ended.")
|
|
2287
|
+
});
|
|
2288
|
+
} else {
|
|
2289
|
+
index.logSafeAdminError("lockouts", err);
|
|
2290
|
+
toggleNotification({
|
|
2291
|
+
type: "danger",
|
|
2292
|
+
message: t("settings.lockouts.unlockFailed", "The lock could not be lifted.")
|
|
2293
|
+
});
|
|
2294
|
+
throw err;
|
|
2295
|
+
}
|
|
2296
|
+
} finally {
|
|
2297
|
+
await load();
|
|
2298
|
+
}
|
|
2299
|
+
};
|
|
2300
|
+
const showActions = !permissionsLoading && canUnlock;
|
|
2301
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH;
|
|
2302
|
+
const unlockAction = (lock) => showActions ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2303
|
+
index.ConfirmAction,
|
|
2304
|
+
{
|
|
2305
|
+
fallbackFocusRef: refreshRef,
|
|
2306
|
+
title: t("settings.lockouts.confirm.title", "Unlock {name}?", { name: lockName(lock, t) }),
|
|
2307
|
+
body: lock.kind === "ip" ? t(
|
|
2308
|
+
"settings.lockouts.confirm.bodyIp",
|
|
2309
|
+
"Sign-ins from this address are allowed again at once, and its failed attempts are reset. This is recorded in the security log."
|
|
2310
|
+
) : t(
|
|
2311
|
+
"settings.lockouts.confirm.bodyAccount",
|
|
2312
|
+
"Sign-ins to this account are allowed again at once, and its failed attempts are reset. This is recorded in the security log."
|
|
2313
|
+
),
|
|
2314
|
+
confirmLabel: t("settings.lockouts.confirm.action", "Unlock"),
|
|
2315
|
+
variant: "default",
|
|
2316
|
+
onConfirm: () => unlock(lock),
|
|
2317
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2318
|
+
designSystem.IconButton,
|
|
2319
|
+
{
|
|
2320
|
+
variant: "ghost",
|
|
2321
|
+
label: t("settings.lockouts.unlockLabel", "Unlock {name}", { name: lockName(lock, t) }),
|
|
2322
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {})
|
|
2323
|
+
}
|
|
2324
|
+
)
|
|
2325
|
+
},
|
|
2326
|
+
lock.id
|
|
2327
|
+
) : null;
|
|
2328
|
+
const ends = (lock) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: lock.until, variant: "omega", textColor: "neutral800", children: formatDate(lock.until, { hour: "2-digit", minute: "2-digit" }) });
|
|
2329
|
+
let content;
|
|
2330
|
+
if (locks === null && !error) {
|
|
2331
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("settings.lockouts.loading", "Loading locks…") }) });
|
|
2332
|
+
} else if (error && locks === null) {
|
|
2333
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2334
|
+
index.PersistentAlert,
|
|
2335
|
+
{
|
|
2336
|
+
variant: "danger",
|
|
2337
|
+
closeLabel: t("common.close", "Close"),
|
|
2338
|
+
title: t("settings.lockouts.error", "Locks could not be loaded."),
|
|
2339
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: load, children: t("common.tryAgain", "Try again") }),
|
|
2340
|
+
children: t("settings.lockouts.errorBody", "Sign-ins are still checked; only this list is missing.")
|
|
2341
|
+
}
|
|
2342
|
+
);
|
|
2343
|
+
} else if (locks.length === 0) {
|
|
2344
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2345
|
+
designSystem.EmptyStateLayout,
|
|
2346
|
+
{
|
|
2347
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyPermissions, { width: "16rem", height: "8rem" }),
|
|
2348
|
+
content: t(
|
|
2349
|
+
"settings.lockouts.empty",
|
|
2350
|
+
"Nothing is locked. Locked IP addresses and accounts appear here until their lock ends."
|
|
2351
|
+
)
|
|
2352
|
+
}
|
|
2353
|
+
);
|
|
2354
|
+
} else if (asTable) {
|
|
2355
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", "data-locks-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: showActions ? 5 : 4, rowCount: locks.length + 1, "aria-busy": refreshing, children: [
|
|
2356
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
2357
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.locked", "Locked") }) }),
|
|
2358
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.kind", "Type") }) }),
|
|
2359
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.failures", "Failed sign-ins") }) }),
|
|
2360
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.until", "Locked until") }) }),
|
|
2361
|
+
showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("settings.lockouts.col.actions", "Actions") }) }) : null
|
|
2362
|
+
] }) }),
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: locks.map((lock) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-lock-row": lock.kind, children: [
|
|
2364
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsxRuntime.jsx(LockTarget, { lock }) }),
|
|
2365
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }) }),
|
|
2366
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
|
|
2367
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: ends(lock) }),
|
|
2368
|
+
showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
|
|
2369
|
+
] }, lock.id)) })
|
|
2370
|
+
] }) });
|
|
2371
|
+
} else {
|
|
2372
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-locks-list": "", children: locks.map((lock) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2373
|
+
designSystem.Box,
|
|
2374
|
+
{
|
|
2375
|
+
tag: "li",
|
|
2376
|
+
padding: 4,
|
|
2377
|
+
hasRadius: true,
|
|
2378
|
+
borderColor: "neutral150",
|
|
2379
|
+
"data-lock-row": lock.kind,
|
|
2380
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
|
|
2381
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, minWidth: 0, children: [
|
|
2382
|
+
/* @__PURE__ */ jsxRuntime.jsx(LockTarget, { lock }),
|
|
2383
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
2384
|
+
/* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }),
|
|
2385
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.lockouts.summary", "{count} failed, until {time}", {
|
|
2386
|
+
count: lock.failures,
|
|
2387
|
+
time: formatDate(lock.until, { hour: "2-digit", minute: "2-digit" })
|
|
2388
|
+
}) })
|
|
2389
|
+
] })
|
|
2390
|
+
] }),
|
|
2391
|
+
/* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
|
|
2392
|
+
] })
|
|
2393
|
+
},
|
|
2394
|
+
lock.id
|
|
2395
|
+
)) });
|
|
2396
|
+
}
|
|
2397
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2398
|
+
SectionCard.SectionCard,
|
|
2399
|
+
{
|
|
2400
|
+
id: "locked-now",
|
|
2401
|
+
title: t("settings.lockouts.title", "Locked now"),
|
|
2402
|
+
subtitle: t(
|
|
2403
|
+
"settings.lockouts.intro",
|
|
2404
|
+
"IP addresses and accounts that are refused right now after failed sign-ins."
|
|
2405
|
+
),
|
|
2406
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2407
|
+
designSystem.Button,
|
|
2408
|
+
{
|
|
2409
|
+
ref: refreshRef,
|
|
2410
|
+
variant: "tertiary",
|
|
2411
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
|
|
2412
|
+
onClick: load,
|
|
2413
|
+
loading: refreshing && locks !== null,
|
|
2414
|
+
children: t("settings.lockouts.refresh", "Refresh")
|
|
2415
|
+
}
|
|
2416
|
+
),
|
|
2417
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: widthRef, "aria-live": "polite", children: [
|
|
2418
|
+
error && locks !== null ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2419
|
+
index.PersistentAlert,
|
|
2420
|
+
{
|
|
2421
|
+
variant: "warning",
|
|
2422
|
+
closeLabel: t("common.close", "Close"),
|
|
2423
|
+
title: t("settings.lockouts.refreshErrorTitle", "Not refreshed"),
|
|
2424
|
+
children: t(
|
|
2425
|
+
"settings.lockouts.refreshError",
|
|
2426
|
+
"The list could not be refreshed. It shows the last known locks."
|
|
2427
|
+
)
|
|
2428
|
+
}
|
|
2429
|
+
) }) : null,
|
|
2430
|
+
content,
|
|
2431
|
+
locks && locks.length > 0 && !showActions && !permissionsLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
2432
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Lock, { "aria-hidden": true, fill: "neutral600" }),
|
|
2433
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
2434
|
+
"settings.lockouts.noUnlock",
|
|
2435
|
+
'Unlocking needs the "Unlock locked sign-ins" permission.'
|
|
2436
|
+
) })
|
|
2437
|
+
] }) }) : null,
|
|
2438
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: locks ? t(
|
|
2439
|
+
"settings.lockouts.count",
|
|
2440
|
+
"{count, plural, =0 {No locks} one {# lock} other {# locks}}",
|
|
2441
|
+
{
|
|
2442
|
+
count: locks.length
|
|
2443
|
+
}
|
|
2444
|
+
) : null })
|
|
2445
|
+
] })
|
|
2446
|
+
}
|
|
2447
|
+
);
|
|
2448
|
+
};
|
|
2449
|
+
const TrustedAddressesField = ({ form, disabled = false }) => {
|
|
2450
|
+
const { t, tError } = useSettingsTranslate();
|
|
2451
|
+
const { settings, handleChange, errors, draftVersion } = form;
|
|
2452
|
+
const [text, setText] = react.useState(
|
|
2453
|
+
() => formatTrustedAddressText(settings.lockoutTrustedAddresses)
|
|
2454
|
+
);
|
|
2455
|
+
const [version, setVersion] = react.useState(draftVersion);
|
|
2456
|
+
if (version !== draftVersion) {
|
|
2457
|
+
setVersion(draftVersion);
|
|
2458
|
+
setText(formatTrustedAddressText(settings.lockoutTrustedAddresses));
|
|
2459
|
+
}
|
|
2460
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2461
|
+
FormField,
|
|
2462
|
+
{
|
|
2463
|
+
id: "lockout-trusted-addresses",
|
|
2464
|
+
name: "lockoutTrustedAddresses",
|
|
2465
|
+
label: t("settings.config.failed.trusted.label", "Trusted addresses"),
|
|
2466
|
+
description: t(
|
|
2467
|
+
"settings.config.failed.trusted.hint",
|
|
2468
|
+
"One IP address or CIDR range per line, for example 192.0.2.10 or 192.0.2.0/24. These addresses are never locked by IP; accounts can still be locked. Use it for an office network or a server that signs in for many users."
|
|
2469
|
+
),
|
|
2470
|
+
error: tError(errors.lockoutTrustedAddresses),
|
|
2471
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2472
|
+
designSystem.Textarea,
|
|
2473
|
+
{
|
|
2474
|
+
value: text,
|
|
2475
|
+
placeholder: "192.0.2.0/24",
|
|
2476
|
+
disabled,
|
|
2477
|
+
onChange: (event) => {
|
|
2478
|
+
setText(event.target.value);
|
|
2479
|
+
handleChange("lockoutTrustedAddresses", parseTrustedAddressText(event.target.value));
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
)
|
|
2483
|
+
}
|
|
2484
|
+
);
|
|
2485
|
+
};
|
|
1550
2486
|
const COUNTRIES = [
|
|
1551
2487
|
{ code: "DE", name: "Germany", flag: "🇩🇪" },
|
|
1552
2488
|
{ code: "AT", name: "Austria", flag: "🇦🇹" },
|
|
@@ -1942,20 +2878,59 @@ const CountryListEditor = ({ settings, handleChange }) => {
|
|
|
1942
2878
|
] })
|
|
1943
2879
|
] });
|
|
1944
2880
|
};
|
|
2881
|
+
const describeLockout = (t, { ip, account, window: window2, duration }) => {
|
|
2882
|
+
if (ip === 0 && account === 0) {
|
|
2883
|
+
return t(
|
|
2884
|
+
"settings.config.failed.lockout.offBoth",
|
|
2885
|
+
"The lockout is off. Failed sign-ins are not limited."
|
|
2886
|
+
);
|
|
2887
|
+
}
|
|
2888
|
+
const parts = [];
|
|
2889
|
+
if (ip > 0) {
|
|
2890
|
+
parts.push(
|
|
2891
|
+
t(
|
|
2892
|
+
"settings.config.failed.preview.ip",
|
|
2893
|
+
"{count, plural, one {# failed sign-in} other {# failed sign-ins}} from one IP address within {window, plural, one {# minute} other {# minutes}} lock that address for {duration, plural, one {# minute} other {# minutes}}.",
|
|
2894
|
+
{ count: ip, window: window2, duration }
|
|
2895
|
+
)
|
|
2896
|
+
);
|
|
2897
|
+
}
|
|
2898
|
+
if (account > 0) {
|
|
2899
|
+
parts.push(
|
|
2900
|
+
t(
|
|
2901
|
+
"settings.config.failed.preview.account",
|
|
2902
|
+
"{count, plural, one {# failed sign-in} other {# failed sign-ins}} for one account within {window, plural, one {# minute} other {# minutes}} lock that account for {duration, plural, one {# minute} other {# minutes}}, from every address.",
|
|
2903
|
+
{ count: account, window: window2, duration }
|
|
2904
|
+
)
|
|
2905
|
+
);
|
|
2906
|
+
}
|
|
2907
|
+
return parts.join(" ");
|
|
2908
|
+
};
|
|
1945
2909
|
const LoginProtectionTab = ({ form }) => {
|
|
1946
2910
|
const { t, tError } = useSettingsTranslate();
|
|
1947
2911
|
const { settings, handleChange, errors } = form;
|
|
1948
2912
|
const maxFailedError = tError(errors.maxFailedLogins);
|
|
1949
2913
|
const maxFailedValue = Number(settings.maxFailedLogins);
|
|
2914
|
+
const accountValue = Number(settings.maxFailedLoginsPerAccount) || 0;
|
|
2915
|
+
const accountByRole = (settings.roleRules || []).some(
|
|
2916
|
+
(rule) => rule.maxFailedLoginsPerAccount !== null && rule.maxFailedLoginsPerAccount !== void 0
|
|
2917
|
+
);
|
|
2918
|
+
const lockoutPreview = describeLockout(t, {
|
|
2919
|
+
ip: maxFailedValue,
|
|
2920
|
+
account: accountValue,
|
|
2921
|
+
window: Number(settings.lockoutWindowMinutes) || 15,
|
|
2922
|
+
duration: Number(settings.lockoutDurationMinutes) || 15
|
|
2923
|
+
});
|
|
1950
2924
|
const lookupOff = !settings.enableGeolocation;
|
|
1951
2925
|
const locked = form.canChangeProtected === false;
|
|
1952
|
-
const
|
|
1953
|
-
const
|
|
2926
|
+
const policyLocked = locked;
|
|
2927
|
+
const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
|
|
2928
|
+
const reject = dashboardModel.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
|
|
1954
2929
|
const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
|
|
1955
2930
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1956
2931
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
1957
2932
|
"settings.config.loginProtection.intro",
|
|
1958
|
-
"These rules check new sign-ins before they succeed. Existing sessions are not affected
|
|
2933
|
+
"These rules check new sign-ins before they succeed. Existing sessions are not affected. Failed and refused sign-ins are recorded in the security log while recording is on."
|
|
1959
2934
|
) }),
|
|
1960
2935
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1961
2936
|
SectionCard.SectionCard,
|
|
@@ -1963,63 +2938,180 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
1963
2938
|
title: t("settings.config.failed.title", "Failed sign-ins"),
|
|
1964
2939
|
subtitle: t(
|
|
1965
2940
|
"settings.config.failed.intro",
|
|
1966
|
-
"Slows down password guessing
|
|
2941
|
+
"Slows down password guessing. Counts are shared by every server process."
|
|
1967
2942
|
),
|
|
1968
2943
|
children: [
|
|
1969
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
"settings.config.failed.lockout.
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
2944
|
+
policyLocked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
2945
|
+
/* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
|
|
2946
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2947
|
+
FormField,
|
|
2948
|
+
{
|
|
2949
|
+
id: "max-failed-logins",
|
|
2950
|
+
name: "maxFailedLogins",
|
|
2951
|
+
label: t("settings.config.failed.lockout.label", "Lock an IP address after"),
|
|
2952
|
+
description: t(
|
|
2953
|
+
"settings.config.failed.lockout.hint",
|
|
2954
|
+
"A whole number from 0 to 100. 0 turns the IP lockout off."
|
|
2955
|
+
),
|
|
2956
|
+
suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
|
|
2957
|
+
error: maxFailedError,
|
|
2958
|
+
required: true,
|
|
2959
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2960
|
+
designSystem.NumberInput,
|
|
2961
|
+
{
|
|
2962
|
+
value: settings.maxFailedLogins,
|
|
2963
|
+
onValueChange: (value) => handleChange("maxFailedLogins", value),
|
|
2964
|
+
min: MAX_FAILED_LOGINS_RANGE.min,
|
|
2965
|
+
max: MAX_FAILED_LOGINS_RANGE.max,
|
|
2966
|
+
step: 1
|
|
2967
|
+
},
|
|
2968
|
+
form.draftVersion
|
|
2969
|
+
)
|
|
2970
|
+
}
|
|
2971
|
+
),
|
|
2972
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2973
|
+
FormField,
|
|
2974
|
+
{
|
|
2975
|
+
id: "max-failed-logins-account",
|
|
2976
|
+
name: "maxFailedLoginsPerAccount",
|
|
2977
|
+
label: t("settings.config.failed.account.label", "Lock an account after"),
|
|
2978
|
+
description: t(
|
|
2979
|
+
"settings.config.failed.account.hint",
|
|
2980
|
+
"Counts failed sign-ins for one account from any address. 0 turns it off. Anyone who knows an account name can lock it, so keep this higher than the IP limit."
|
|
2981
|
+
),
|
|
2982
|
+
suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
|
|
2983
|
+
error: tError(errors.maxFailedLoginsPerAccount),
|
|
2984
|
+
required: true,
|
|
2985
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2986
|
+
designSystem.NumberInput,
|
|
2987
|
+
{
|
|
2988
|
+
value: settings.maxFailedLoginsPerAccount,
|
|
2989
|
+
onValueChange: (value) => handleChange("maxFailedLoginsPerAccount", value ?? ""),
|
|
2990
|
+
disabled: policyLocked,
|
|
2991
|
+
min: POLICY_RANGES.maxFailedLoginsPerAccount.min,
|
|
2992
|
+
max: POLICY_RANGES.maxFailedLoginsPerAccount.max,
|
|
2993
|
+
step: 1
|
|
2994
|
+
},
|
|
2995
|
+
form.draftVersion
|
|
2996
|
+
)
|
|
2997
|
+
}
|
|
2998
|
+
),
|
|
2999
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3000
|
+
FormField,
|
|
3001
|
+
{
|
|
3002
|
+
id: "lockout-window",
|
|
3003
|
+
name: "lockoutWindowMinutes",
|
|
3004
|
+
label: t("settings.config.failed.window.label", "Count failed sign-ins within"),
|
|
3005
|
+
description: t(
|
|
3006
|
+
"settings.config.failed.window.hint",
|
|
3007
|
+
"Failures older than this no longer count."
|
|
3008
|
+
),
|
|
3009
|
+
suffix: t("settings.config.failed.minutes.suffix", "minutes"),
|
|
3010
|
+
error: tError(errors.lockoutWindowMinutes),
|
|
3011
|
+
required: true,
|
|
3012
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3013
|
+
designSystem.NumberInput,
|
|
3014
|
+
{
|
|
3015
|
+
value: settings.lockoutWindowMinutes,
|
|
3016
|
+
onValueChange: (value) => handleChange("lockoutWindowMinutes", value ?? ""),
|
|
3017
|
+
disabled: policyLocked,
|
|
3018
|
+
min: POLICY_RANGES.lockoutWindowMinutes.min,
|
|
3019
|
+
max: POLICY_RANGES.lockoutWindowMinutes.max,
|
|
3020
|
+
step: 1
|
|
3021
|
+
},
|
|
3022
|
+
form.draftVersion
|
|
3023
|
+
)
|
|
3024
|
+
}
|
|
3025
|
+
),
|
|
3026
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3027
|
+
FormField,
|
|
3028
|
+
{
|
|
3029
|
+
id: "lockout-duration",
|
|
3030
|
+
name: "lockoutDurationMinutes",
|
|
3031
|
+
label: t("settings.config.failed.duration.label", "Lock for"),
|
|
3032
|
+
description: t(
|
|
3033
|
+
"settings.config.failed.duration.hint",
|
|
3034
|
+
"A locked IP address or account is refused for this long. Admins can unlock it earlier."
|
|
3035
|
+
),
|
|
3036
|
+
suffix: t("settings.config.failed.minutes.suffix", "minutes"),
|
|
3037
|
+
error: tError(errors.lockoutDurationMinutes),
|
|
3038
|
+
required: true,
|
|
3039
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3040
|
+
designSystem.NumberInput,
|
|
3041
|
+
{
|
|
3042
|
+
value: settings.lockoutDurationMinutes,
|
|
3043
|
+
onValueChange: (value) => handleChange("lockoutDurationMinutes", value ?? ""),
|
|
3044
|
+
disabled: policyLocked,
|
|
3045
|
+
min: POLICY_RANGES.lockoutDurationMinutes.min,
|
|
3046
|
+
max: POLICY_RANGES.lockoutDurationMinutes.max,
|
|
3047
|
+
step: 1
|
|
3048
|
+
},
|
|
3049
|
+
form.draftVersion
|
|
3050
|
+
)
|
|
3051
|
+
}
|
|
3052
|
+
)
|
|
3053
|
+
] }),
|
|
3054
|
+
!maxFailedError && !errors.maxFailedLoginsPerAccount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1996
3055
|
designSystem.Box,
|
|
1997
3056
|
{
|
|
1998
3057
|
padding: 3,
|
|
1999
|
-
background: maxFailedValue === 0 ? "warning100" : "neutral100",
|
|
3058
|
+
background: maxFailedValue === 0 && accountValue === 0 ? "warning100" : "neutral100",
|
|
2000
3059
|
hasRadius: true,
|
|
2001
3060
|
"aria-live": "polite",
|
|
2002
3061
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2003
3062
|
index.ReadableParagraphs,
|
|
2004
3063
|
{
|
|
2005
3064
|
variant: "pi",
|
|
2006
|
-
textColor: maxFailedValue === 0 ? "warning700" : "neutral700",
|
|
3065
|
+
textColor: maxFailedValue === 0 && accountValue === 0 ? "warning700" : "neutral700",
|
|
2007
3066
|
tag: "p",
|
|
2008
|
-
text:
|
|
2009
|
-
"settings.config.failed.lockout.off",
|
|
2010
|
-
"The temporary IP lockout is off. Failed sign-ins are not limited."
|
|
2011
|
-
) : t(
|
|
2012
|
-
"settings.config.failed.lockout.preview",
|
|
2013
|
-
"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.",
|
|
2014
|
-
{ count: maxFailedValue }
|
|
2015
|
-
)
|
|
3067
|
+
text: lockoutPreview
|
|
2016
3068
|
}
|
|
2017
3069
|
)
|
|
2018
3070
|
}
|
|
2019
|
-
) : null
|
|
3071
|
+
) : null,
|
|
3072
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3073
|
+
SettingsToggleRow,
|
|
3074
|
+
{
|
|
3075
|
+
id: "lockout-notify-user",
|
|
3076
|
+
title: t(
|
|
3077
|
+
"settings.config.failed.notify.label",
|
|
3078
|
+
"Email the user when their account is locked"
|
|
3079
|
+
),
|
|
3080
|
+
description: t(
|
|
3081
|
+
"settings.config.failed.notify.hint",
|
|
3082
|
+
"Sent through Strapi's email plugin (and Magic Mail when installed). The text is in Alerts, Email templates."
|
|
3083
|
+
),
|
|
3084
|
+
checked: !!settings.lockoutNotifyUser,
|
|
3085
|
+
disabled: policyLocked || accountValue === 0 && !accountByRole,
|
|
3086
|
+
onChange: (checked) => handleChange("lockoutNotifyUser", checked)
|
|
3087
|
+
}
|
|
3088
|
+
),
|
|
3089
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3090
|
+
SettingsToggleRow,
|
|
3091
|
+
{
|
|
3092
|
+
id: "record-user-sign-in-events",
|
|
3093
|
+
title: t("settings.config.failed.record.label", "Record failed and refused sign-ins"),
|
|
3094
|
+
description: t(
|
|
3095
|
+
"settings.config.failed.record.hint",
|
|
3096
|
+
"Writes failed sign-ins, refused sign-ins and locks to the security log, with the IP address as the log stores it."
|
|
3097
|
+
),
|
|
3098
|
+
checked: settings.recordUserSignInEvents !== false,
|
|
3099
|
+
disabled: policyLocked,
|
|
3100
|
+
onChange: (checked) => handleChange("recordUserSignInEvents", checked)
|
|
3101
|
+
}
|
|
3102
|
+
),
|
|
3103
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3104
|
+
AdvancedSection,
|
|
3105
|
+
{
|
|
3106
|
+
label: t("settings.config.failed.trusted.section", "Trusted addresses"),
|
|
3107
|
+
hasError: fieldHasError(errors, "lockoutTrustedAddresses"),
|
|
3108
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(TrustedAddressesField, { form, disabled: policyLocked })
|
|
3109
|
+
}
|
|
3110
|
+
)
|
|
2020
3111
|
]
|
|
2021
3112
|
}
|
|
2022
3113
|
),
|
|
3114
|
+
/* @__PURE__ */ jsxRuntime.jsx(LockedNowCard, {}),
|
|
2023
3115
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2024
3116
|
SectionCard.SectionCard,
|
|
2025
3117
|
{
|
|
@@ -2153,7 +3245,18 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
2153
3245
|
{
|
|
2154
3246
|
id: "lockout",
|
|
2155
3247
|
term: t("settings.config.refused.lockout.response", "429 with Retry-After"),
|
|
2156
|
-
description: t(
|
|
3248
|
+
description: t(
|
|
3249
|
+
"settings.config.refused.lockout.cause",
|
|
3250
|
+
"Locked IP address or account after failed sign-ins"
|
|
3251
|
+
)
|
|
3252
|
+
},
|
|
3253
|
+
{
|
|
3254
|
+
id: "limit",
|
|
3255
|
+
term: t("settings.config.refused.limit.response", "403 SESSION_LIMIT_REACHED"),
|
|
3256
|
+
description: t(
|
|
3257
|
+
"settings.config.refused.limit.cause",
|
|
3258
|
+
'Session limit reached with "Refuse the new sign-in"'
|
|
3259
|
+
)
|
|
2157
3260
|
},
|
|
2158
3261
|
{
|
|
2159
3262
|
id: "rule",
|
|
@@ -2177,7 +3280,10 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
2177
3280
|
]
|
|
2178
3281
|
}
|
|
2179
3282
|
),
|
|
2180
|
-
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
3283
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
3284
|
+
"settings.config.refused.log",
|
|
3285
|
+
'Refused sign-ins are written to the security log while "Record failed and refused sign-ins" is on.'
|
|
3286
|
+
) })
|
|
2181
3287
|
] })
|
|
2182
3288
|
] });
|
|
2183
3289
|
};
|
|
@@ -2530,7 +3636,7 @@ const RiskDataCard = ({ form }) => {
|
|
|
2530
3636
|
const { t } = useSettingsTranslate();
|
|
2531
3637
|
const { settings, geoIp } = form;
|
|
2532
3638
|
const lookupOff = !settings.enableGeolocation;
|
|
2533
|
-
const risk =
|
|
3639
|
+
const risk = dashboardModel.getRiskAvailability(geoIp.status);
|
|
2534
3640
|
const sourceLabels = {
|
|
2535
3641
|
"anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
|
|
2536
3642
|
"asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
|
|
@@ -2597,8 +3703,8 @@ const RiskDataCard = ({ form }) => {
|
|
|
2597
3703
|
const LocationDataTab = ({ form }) => {
|
|
2598
3704
|
const { t } = useSettingsTranslate();
|
|
2599
3705
|
const { settings, handleChange } = form;
|
|
2600
|
-
const risk =
|
|
2601
|
-
const scoring =
|
|
3706
|
+
const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
|
|
3707
|
+
const scoring = dashboardModel.riskDependentControl(settings.enableSecurityScoring, risk.state);
|
|
2602
3708
|
const locked = form.canChangeProtected === false;
|
|
2603
3709
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
2604
3710
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
@@ -2729,7 +3835,8 @@ const PreviewFrame = styled__default.default.iframe`
|
|
|
2729
3835
|
const TEMPLATE_TAB_LABELS = {
|
|
2730
3836
|
suspiciousLogin: ["settings.email.templates.tab.suspicious", "Suspicious sign-in"],
|
|
2731
3837
|
newLocation: ["settings.email.templates.tab.newLocation", "New country"],
|
|
2732
|
-
vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"]
|
|
3838
|
+
vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"],
|
|
3839
|
+
accountLocked: ["settings.email.templates.tab.accountLocked", "Account locked"]
|
|
2733
3840
|
};
|
|
2734
3841
|
const BlockLabel = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", tag: "div", textColor: "neutral800", children });
|
|
2735
3842
|
const TemplateEditor = ({ templateKey, template, templates, handleChange, copyValue, errors }) => {
|
|
@@ -3118,7 +4225,7 @@ const AlertsTab = ({ form }) => {
|
|
|
3118
4225
|
const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
|
|
3119
4226
|
const locked = form.canChangeProtected === false;
|
|
3120
4227
|
const templateErrors = fieldHasError(errors, "emailTemplates");
|
|
3121
|
-
const risk =
|
|
4228
|
+
const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
|
|
3122
4229
|
const emailTypes = [
|
|
3123
4230
|
{
|
|
3124
4231
|
field: "alertOnSuspiciousLogin",
|
|
@@ -3186,7 +4293,7 @@ const AlertsTab = ({ form }) => {
|
|
|
3186
4293
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
|
|
3187
4294
|
!lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
|
|
3188
4295
|
/* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
|
|
3189
|
-
const control = needsRiskData ?
|
|
4296
|
+
const control = needsRiskData ? dashboardModel.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
|
|
3190
4297
|
const disabled = emailTypesDisabled || control.disabled;
|
|
3191
4298
|
return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
|
|
3192
4299
|
/* @__PURE__ */ jsxRuntime.jsx(
|