strapi-plugin-magic-sessionmanager 4.16.1 → 4.18.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 +76 -0
- package/README.md +119 -25
- package/dist/admin/{Analytics-CMR62DiD.js → Analytics-C8fV6LDV.js} +1 -1
- package/dist/admin/{Analytics-FcRt0X62.mjs → Analytics-CBspdl1I.mjs} +1 -1
- package/dist/admin/{App-CmytGbze.js → App-D92MTQmn.js} +33 -170
- package/dist/admin/{App-DBieSWB0.mjs → App-PLwqaRSQ.mjs} +3 -140
- package/dist/admin/{OnlineUsersWidget-Lzx9XB74.js → OnlineUsersWidget-CiKapC1B.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-zP9Hl_it.mjs → OnlineUsersWidget-CwfBJdIX.mjs} +1 -1
- package/dist/admin/{Settings-CZOPusQK.mjs → Settings-CMgL-Aub.mjs} +2013 -78
- package/dist/admin/{Settings-1v--SXC0.js → Settings-Duil_4jv.js} +2017 -82
- package/dist/admin/dashboardModel-BhUonEqc.mjs +189 -0
- package/dist/admin/dashboardModel-sksvIc1c.js +188 -0
- package/dist/admin/{de-y_9mdVT7.js → de-CnInuvMY.js} +196 -11
- package/dist/admin/{de-D3TSA066.mjs → de-D2BqfY1f.mjs} +196 -11
- package/dist/admin/{en-B60I97bK.mjs → en-BPy208we.mjs} +196 -11
- package/dist/admin/{en-CIQB8nfI.js → en-KnmmYHTF.js} +196 -11
- package/dist/admin/{es-CJEL_iGC.mjs → es-B4VNeT0A.mjs} +196 -11
- package/dist/admin/{es-DHhHzlRY.js → es-D1NGCAJK.js} +196 -11
- package/dist/admin/{fr-BfBK_iuV.mjs → fr-AwhLN1BC.mjs} +196 -11
- package/dist/admin/{fr-D86FTt1w.js → fr-D1KNyogi.js} +196 -11
- package/dist/admin/{index-tt61o2VH.mjs → index-BmnC2BPs.mjs} +40 -38
- package/dist/admin/{index-CSJJn4qy.js → index-Bnt0Jq6O.js} +12 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-C3PSvC7z.mjs → pt-D6m1TijL.mjs} +196 -11
- package/dist/admin/{pt-BE-FT-L8.js → pt-EKThRXPY.js} +196 -11
- package/dist/server/index.js +3230 -129
- package/dist/server/index.mjs +3230 -129
- 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-Bnt0Jq6O.js");
|
|
10
10
|
const reactIntl = require("react-intl");
|
|
11
11
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
12
|
-
const
|
|
12
|
+
const dashboardModel = require("./dashboardModel-sksvIc1c.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,24 @@ 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",
|
|
56
|
+
"impossibleTravelEnabled",
|
|
57
|
+
"impossibleTravelSpeedKmh",
|
|
58
|
+
"impossibleTravelMinDistanceKm",
|
|
59
|
+
"impossibleTravelAction",
|
|
45
60
|
"trustedProxies",
|
|
46
61
|
"blockSuspiciousSessions",
|
|
47
62
|
"geoLookupFailureMode",
|
|
@@ -63,9 +78,15 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
|
63
78
|
"emailTemplates",
|
|
64
79
|
"enableWebhooks",
|
|
65
80
|
"discordWebhookUrl",
|
|
66
|
-
"slackWebhookUrl"
|
|
81
|
+
"slackWebhookUrl",
|
|
82
|
+
"alertOnNewDevice",
|
|
83
|
+
"alertOnImpossibleTravel",
|
|
84
|
+
"webhookEvents",
|
|
85
|
+
"genericWebhookEnabled",
|
|
86
|
+
"genericWebhookUrl",
|
|
87
|
+
"genericWebhookSecret"
|
|
67
88
|
],
|
|
68
|
-
"data-retention": ["retentionDays"],
|
|
89
|
+
"data-retention": ["retentionDays", "sessionIpAnonymize"],
|
|
69
90
|
"admin-activity": [
|
|
70
91
|
"adminSignInHistory",
|
|
71
92
|
"adminContentActivity",
|
|
@@ -91,7 +112,37 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
|
|
|
91
112
|
cleanupUseDbDirect: ["settings.config.sessions.idleMethod.label", "Idle check method"],
|
|
92
113
|
strictSessionEnforcement: ["settings.config.token.check.label", "Strict token check"],
|
|
93
114
|
sessionCreationGraceMs: ["settings.config.token.grace.label", "Grace period after sign-in"],
|
|
94
|
-
maxFailedLogins: ["settings.config.failed.lockout.label", "
|
|
115
|
+
maxFailedLogins: ["settings.config.failed.lockout.label", "Lock an IP address after"],
|
|
116
|
+
maxFailedLoginsPerAccount: ["settings.config.failed.account.label", "Lock an account after"],
|
|
117
|
+
lockoutWindowMinutes: ["settings.config.failed.window.label", "Count failed sign-ins within"],
|
|
118
|
+
lockoutDurationMinutes: ["settings.config.failed.duration.label", "Lock for"],
|
|
119
|
+
lockoutTrustedAddresses: ["settings.config.failed.trusted.label", "Trusted addresses"],
|
|
120
|
+
lockoutNotifyUser: [
|
|
121
|
+
"settings.config.failed.notify.label",
|
|
122
|
+
"Email the user when their account is locked"
|
|
123
|
+
],
|
|
124
|
+
recordUserSignInEvents: [
|
|
125
|
+
"settings.config.failed.record.label",
|
|
126
|
+
"Record failed and refused sign-ins"
|
|
127
|
+
],
|
|
128
|
+
maxSessionsPerUser: ["settings.config.sessionLimit.max.label", "Open sessions per user"],
|
|
129
|
+
sessionLimitPolicy: ["settings.config.sessionLimit.policy.label", "When the limit is reached"],
|
|
130
|
+
endOtherSessionsOnPasswordChange: [
|
|
131
|
+
"settings.config.passwordChange.label",
|
|
132
|
+
"End other sessions after a password change"
|
|
133
|
+
],
|
|
134
|
+
roleRules: ["settings.roleRules.title", "Different rules for some roles"],
|
|
135
|
+
impossibleTravelEnabled: ["settings.config.travel.enable.label", "Detect impossible travel"],
|
|
136
|
+
impossibleTravelSpeedKmh: ["settings.config.travel.speed.label", "Faster than"],
|
|
137
|
+
impossibleTravelMinDistanceKm: ["settings.config.travel.distance.label", "Over at least"],
|
|
138
|
+
impossibleTravelAction: ["settings.config.travel.action.label", "Then"],
|
|
139
|
+
alertOnNewDevice: ["settings.config.email.newDevice.label", "Sign-in from a new device"],
|
|
140
|
+
alertOnImpossibleTravel: ["settings.config.email.travel.label", "Impossible travel"],
|
|
141
|
+
webhookEvents: ["settings.webhookEvents.title", "Events to send"],
|
|
142
|
+
genericWebhookEnabled: ["settings.signedWebhook.enable.label", "Send to the signed webhook"],
|
|
143
|
+
genericWebhookUrl: ["settings.signedWebhook.url.label", "Webhook URL"],
|
|
144
|
+
genericWebhookSecret: ["settings.signedWebhook.secret.label", "Signing secret"],
|
|
145
|
+
sessionIpAnonymize: ["settings.config.privacy.shortIp.label", "Shorten IP addresses of sessions"],
|
|
95
146
|
trustedProxies: ["settings.config.clientIp.trustProxy.label", "Trust proxy headers"],
|
|
96
147
|
blockSuspiciousSessions: [
|
|
97
148
|
"settings.config.suspicious.reject.label",
|
|
@@ -737,6 +788,441 @@ const TermList = ({ items, label, code = false }) => /* @__PURE__ */ jsxRuntime.
|
|
|
737
788
|
) }),
|
|
738
789
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral700", children: item.description }) })
|
|
739
790
|
] }, item.id)) });
|
|
791
|
+
const POLICY_FORM_DEFAULTS = Object.freeze({
|
|
792
|
+
maxFailedLoginsPerAccount: 0,
|
|
793
|
+
lockoutWindowMinutes: 15,
|
|
794
|
+
lockoutDurationMinutes: 15,
|
|
795
|
+
lockoutTrustedAddresses: Object.freeze([]),
|
|
796
|
+
lockoutNotifyUser: false,
|
|
797
|
+
recordUserSignInEvents: true,
|
|
798
|
+
maxSessionsPerUser: 0,
|
|
799
|
+
sessionLimitPolicy: "end-oldest",
|
|
800
|
+
endOtherSessionsOnPasswordChange: true,
|
|
801
|
+
roleRules: Object.freeze([])
|
|
802
|
+
});
|
|
803
|
+
const POLICY_RANGES = Object.freeze({
|
|
804
|
+
maxFailedLoginsPerAccount: Object.freeze({ min: 0, max: 100 }),
|
|
805
|
+
lockoutWindowMinutes: Object.freeze({ min: 1, max: 1440 }),
|
|
806
|
+
lockoutDurationMinutes: Object.freeze({ min: 1, max: 10080 }),
|
|
807
|
+
maxSessionsPerUser: Object.freeze({ min: 0, max: 100 })
|
|
808
|
+
});
|
|
809
|
+
const ROLE_RULE_RANGES = Object.freeze({
|
|
810
|
+
maxSessionsPerUser: Object.freeze({ min: 0, max: 100 }),
|
|
811
|
+
inactivityTimeout: Object.freeze({ min: 1, max: 1440 }),
|
|
812
|
+
maxFailedLoginsPerAccount: Object.freeze({ min: 0, max: 100 })
|
|
813
|
+
});
|
|
814
|
+
const ROLE_RULE_FIELDS = Object.freeze(Object.keys(ROLE_RULE_RANGES));
|
|
815
|
+
const MAX_TRUSTED_ADDRESSES = 100;
|
|
816
|
+
const message$2 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
|
|
817
|
+
function validateWholeNumber(value, { min, max }) {
|
|
818
|
+
if (value === void 0 || value === null || value === "") {
|
|
819
|
+
return message$2("settings.validation.required", "Enter a value.");
|
|
820
|
+
}
|
|
821
|
+
const number = Number(value);
|
|
822
|
+
if (!Number.isInteger(number) || number < min || number > max) {
|
|
823
|
+
return message$2("settings.validation.range", "Enter a whole number from {min} to {max}.", {
|
|
824
|
+
min,
|
|
825
|
+
max
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
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}$/;
|
|
831
|
+
const IPV6_CHARS = /^[0-9a-f:.]{2,45}$/i;
|
|
832
|
+
function isTrustedAddressLine(line) {
|
|
833
|
+
const value = String(line || "").trim();
|
|
834
|
+
if (!value || value.length > 64) return false;
|
|
835
|
+
const [address, prefix, extra] = value.split("/");
|
|
836
|
+
if (extra !== void 0) return false;
|
|
837
|
+
const v4 = IPV4.test(address);
|
|
838
|
+
const v6 = !v4 && address.includes(":") && IPV6_CHARS.test(address) && !address.includes(":::");
|
|
839
|
+
if (!v4 && !v6) return false;
|
|
840
|
+
if (prefix === void 0) return true;
|
|
841
|
+
if (!/^\d{1,3}$/.test(prefix)) return false;
|
|
842
|
+
return Number(prefix) <= (v4 ? 32 : 128);
|
|
843
|
+
}
|
|
844
|
+
function parseTrustedAddressText(text) {
|
|
845
|
+
return String(text || "").split(/[\n,]/).map((line) => line.trim()).filter(Boolean);
|
|
846
|
+
}
|
|
847
|
+
function formatTrustedAddressText(list) {
|
|
848
|
+
return Array.isArray(list) ? list.join("\n") : "";
|
|
849
|
+
}
|
|
850
|
+
function validatePolicyFields(settings) {
|
|
851
|
+
const source = settings || {};
|
|
852
|
+
const errors = {};
|
|
853
|
+
for (const [key, range] of Object.entries(POLICY_RANGES)) {
|
|
854
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
|
|
855
|
+
const error = validateWholeNumber(source[key], range);
|
|
856
|
+
if (error) errors[key] = error;
|
|
857
|
+
}
|
|
858
|
+
const entries = Array.isArray(source.lockoutTrustedAddresses) ? source.lockoutTrustedAddresses : [];
|
|
859
|
+
if (entries.length > MAX_TRUSTED_ADDRESSES) {
|
|
860
|
+
errors.lockoutTrustedAddresses = message$2(
|
|
861
|
+
"settings.validation.trustedTooMany",
|
|
862
|
+
"Enter at most {max} addresses.",
|
|
863
|
+
{ max: MAX_TRUSTED_ADDRESSES }
|
|
864
|
+
);
|
|
865
|
+
} else {
|
|
866
|
+
const invalid = entries.find((entry) => !isTrustedAddressLine(entry));
|
|
867
|
+
if (invalid !== void 0) {
|
|
868
|
+
errors.lockoutTrustedAddresses = message$2(
|
|
869
|
+
"settings.validation.trustedAddress",
|
|
870
|
+
'"{value}" is not an IP address or CIDR range. Use for example 192.0.2.10 or 192.0.2.0/24.',
|
|
871
|
+
{ value: String(invalid).slice(0, 64) }
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return errors;
|
|
876
|
+
}
|
|
877
|
+
function validateRoleRule(draft, takenRoles = []) {
|
|
878
|
+
const errors = {};
|
|
879
|
+
if (!draft?.role) {
|
|
880
|
+
errors.role = message$2("settings.roleRules.validation.role", "Choose a role.");
|
|
881
|
+
} else if (takenRoles.includes(draft.role)) {
|
|
882
|
+
errors.role = message$2(
|
|
883
|
+
"settings.roleRules.validation.duplicate",
|
|
884
|
+
"This role already has a rule."
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
let values = 0;
|
|
888
|
+
for (const field of ROLE_RULE_FIELDS) {
|
|
889
|
+
const value = draft?.[field];
|
|
890
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
891
|
+
const error = validateWholeNumber(value, ROLE_RULE_RANGES[field]);
|
|
892
|
+
if (error) errors[field] = error;
|
|
893
|
+
else values += 1;
|
|
894
|
+
}
|
|
895
|
+
if (values === 0 && !ROLE_RULE_FIELDS.some((field) => errors[field])) {
|
|
896
|
+
errors.form = message$2(
|
|
897
|
+
"settings.roleRules.validation.empty",
|
|
898
|
+
"Set at least one value. Empty fields use the general setting."
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
return errors;
|
|
902
|
+
}
|
|
903
|
+
function toRoleRule(draft) {
|
|
904
|
+
const rule = { role: draft.role };
|
|
905
|
+
for (const field of ROLE_RULE_FIELDS) {
|
|
906
|
+
const value = draft[field];
|
|
907
|
+
rule[field] = value === void 0 || value === null || value === "" ? null : Number(value);
|
|
908
|
+
}
|
|
909
|
+
return rule;
|
|
910
|
+
}
|
|
911
|
+
function upsertRoleRule(rules, rule, previousRole = null) {
|
|
912
|
+
const list = Array.isArray(rules) ? rules : [];
|
|
913
|
+
const key = previousRole || rule.role;
|
|
914
|
+
const index2 = list.findIndex((candidate) => candidate.role === key);
|
|
915
|
+
if (index2 === -1) return [...list, rule];
|
|
916
|
+
return list.map((candidate, position) => position === index2 ? rule : candidate);
|
|
917
|
+
}
|
|
918
|
+
function removeRoleRule(rules, role) {
|
|
919
|
+
return (Array.isArray(rules) ? rules : []).filter((rule) => rule.role !== role);
|
|
920
|
+
}
|
|
921
|
+
function sortLocks(locks) {
|
|
922
|
+
return (Array.isArray(locks) ? locks : []).slice().sort((a, b) => {
|
|
923
|
+
const until = Date.parse(b.until) - Date.parse(a.until);
|
|
924
|
+
return Number.isFinite(until) && until !== 0 ? until : String(a.id).localeCompare(b.id);
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
const TABLE_MIN_WIDTH$1 = 640;
|
|
928
|
+
const keepActionKeys$1 = (event) => {
|
|
929
|
+
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
930
|
+
};
|
|
931
|
+
const EMPTY_DRAFT = Object.freeze({
|
|
932
|
+
role: "",
|
|
933
|
+
maxSessionsPerUser: void 0,
|
|
934
|
+
inactivityTimeout: void 0,
|
|
935
|
+
maxFailedLoginsPerAccount: void 0
|
|
936
|
+
});
|
|
937
|
+
const RuleValue = ({ value, format }) => {
|
|
938
|
+
const { t } = useSettingsTranslate();
|
|
939
|
+
if (value === null || value === void 0) {
|
|
940
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.roleRules.general", "General setting") });
|
|
941
|
+
}
|
|
942
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: format(value) });
|
|
943
|
+
};
|
|
944
|
+
const RoleRulesSection = ({ form }) => {
|
|
945
|
+
const { t, tError } = useSettingsTranslate();
|
|
946
|
+
const { get } = StrapiAdmin.useFetchClient();
|
|
947
|
+
const { settings, handleChange } = form;
|
|
948
|
+
const locked = form.canChangeProtected === false;
|
|
949
|
+
const rules = Array.isArray(settings.roleRules) ? settings.roleRules : [];
|
|
950
|
+
const [roles, setRoles] = react.useState(null);
|
|
951
|
+
const [rolesError, setRolesError] = react.useState(false);
|
|
952
|
+
const [dialog, setDialog] = react.useState(null);
|
|
953
|
+
const [draft, setDraft] = react.useState(EMPTY_DRAFT);
|
|
954
|
+
const [showErrors, setShowErrors] = react.useState(false);
|
|
955
|
+
const addRef = react.useRef(null);
|
|
956
|
+
const returnFocusRef = react.useRef(null);
|
|
957
|
+
const [widthRef, width] = dashboardModel.useElementWidth();
|
|
958
|
+
react.useEffect(() => {
|
|
959
|
+
let active = true;
|
|
960
|
+
get(`/${index.pluginId}/roles`).then(({ data }) => {
|
|
961
|
+
if (!active) return;
|
|
962
|
+
if (!Array.isArray(data?.data)) throw new Error("Invalid role list");
|
|
963
|
+
setRoles(data.data);
|
|
964
|
+
}).catch((err) => {
|
|
965
|
+
if (!active || index.isCancelledRequest(err)) return;
|
|
966
|
+
index.logSafeAdminError("roles", err);
|
|
967
|
+
setRolesError(true);
|
|
968
|
+
});
|
|
969
|
+
return () => {
|
|
970
|
+
active = false;
|
|
971
|
+
};
|
|
972
|
+
}, [get]);
|
|
973
|
+
const roleName = (documentId) => roles?.find((role) => role.documentId === documentId)?.name || t("settings.roleRules.unknownRole", "Removed role");
|
|
974
|
+
const minutes = (value) => t("settings.roleRules.minutes", "{count, plural, one {# minute} other {# minutes}}", {
|
|
975
|
+
count: value
|
|
976
|
+
});
|
|
977
|
+
const sessions = (value) => value === 0 ? t("settings.roleRules.noLimit", "No limit") : t("settings.roleRules.sessions", "{count, plural, one {# session} other {# sessions}}", {
|
|
978
|
+
count: value
|
|
979
|
+
});
|
|
980
|
+
const failures = (value) => value === 0 ? t("settings.roleRules.noAccountLock", "Off") : t("settings.roleRules.failures", "{count, plural, one {# failure} other {# failures}}", {
|
|
981
|
+
count: value
|
|
982
|
+
});
|
|
983
|
+
const open = (rule, trigger) => {
|
|
984
|
+
returnFocusRef.current = trigger || addRef.current;
|
|
985
|
+
setShowErrors(false);
|
|
986
|
+
setDraft(
|
|
987
|
+
rule ? {
|
|
988
|
+
role: rule.role,
|
|
989
|
+
maxSessionsPerUser: rule.maxSessionsPerUser ?? void 0,
|
|
990
|
+
inactivityTimeout: rule.inactivityTimeout ?? void 0,
|
|
991
|
+
maxFailedLoginsPerAccount: rule.maxFailedLoginsPerAccount ?? void 0
|
|
992
|
+
} : EMPTY_DRAFT
|
|
993
|
+
);
|
|
994
|
+
setDialog({ editing: rule ? rule.role : null });
|
|
995
|
+
};
|
|
996
|
+
const close = () => {
|
|
997
|
+
setDialog(null);
|
|
998
|
+
window.requestAnimationFrame?.(() => {
|
|
999
|
+
const target = returnFocusRef.current?.isConnected ? returnFocusRef.current : addRef.current;
|
|
1000
|
+
target?.focus?.();
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
const taken = rules.map((rule) => rule.role).filter((role) => role !== dialog?.editing);
|
|
1004
|
+
const draftErrors = validateRoleRule(draft, taken);
|
|
1005
|
+
const submit = () => {
|
|
1006
|
+
if (Object.keys(draftErrors).length > 0) {
|
|
1007
|
+
setShowErrors(true);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
handleChange("roleRules", upsertRoleRule(rules, toRoleRule(draft), dialog?.editing));
|
|
1011
|
+
close();
|
|
1012
|
+
};
|
|
1013
|
+
const fieldError = (key) => showErrors ? tError(draftErrors[key]) : void 0;
|
|
1014
|
+
const availableRoles = (roles || []).filter((role) => !taken.includes(role.documentId));
|
|
1015
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
|
|
1016
|
+
const actions = (rule) => {
|
|
1017
|
+
const name = roleName(rule.role);
|
|
1018
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys$1, children: [
|
|
1019
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1020
|
+
designSystem.IconButton,
|
|
1021
|
+
{
|
|
1022
|
+
variant: "ghost",
|
|
1023
|
+
disabled: locked,
|
|
1024
|
+
label: t("settings.roleRules.edit", "Edit the rule for {role}", { role: name }),
|
|
1025
|
+
onClick: (event) => open(rule, event.currentTarget),
|
|
1026
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
|
1027
|
+
}
|
|
1028
|
+
),
|
|
1029
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1030
|
+
designSystem.IconButton,
|
|
1031
|
+
{
|
|
1032
|
+
variant: "ghost",
|
|
1033
|
+
disabled: locked,
|
|
1034
|
+
label: t("settings.roleRules.remove", "Remove the rule for {role}", { role: name }),
|
|
1035
|
+
onClick: () => {
|
|
1036
|
+
handleChange("roleRules", removeRoleRule(rules, rule.role));
|
|
1037
|
+
window.requestAnimationFrame?.(() => addRef.current?.focus?.());
|
|
1038
|
+
},
|
|
1039
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
1040
|
+
}
|
|
1041
|
+
)
|
|
1042
|
+
] });
|
|
1043
|
+
};
|
|
1044
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1045
|
+
AdvancedSection,
|
|
1046
|
+
{
|
|
1047
|
+
label: t("settings.roleRules.title", "Different rules for some roles"),
|
|
1048
|
+
hasError: Object.keys(form.errors || {}).some((key) => key.startsWith("roleRules")),
|
|
1049
|
+
children: [
|
|
1050
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
1051
|
+
"settings.roleRules.intro",
|
|
1052
|
+
"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."
|
|
1053
|
+
) }),
|
|
1054
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
1055
|
+
rolesError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1056
|
+
index.PersistentAlert,
|
|
1057
|
+
{
|
|
1058
|
+
variant: "warning",
|
|
1059
|
+
closeLabel: t("common.close", "Close"),
|
|
1060
|
+
title: t("settings.roleRules.rolesError", "Roles could not be loaded."),
|
|
1061
|
+
children: t(
|
|
1062
|
+
"settings.roleRules.rolesErrorBody",
|
|
1063
|
+
"Existing rules still apply. Reload the page to add or edit rules."
|
|
1064
|
+
)
|
|
1065
|
+
}
|
|
1066
|
+
) : null,
|
|
1067
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: widthRef, children: rules.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", tag: "p", children: t(
|
|
1068
|
+
"settings.roleRules.empty",
|
|
1069
|
+
"No role has its own rules. Every role uses the general settings."
|
|
1070
|
+
) }) : 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: [
|
|
1071
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
1072
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.role", "Role") }) }),
|
|
1073
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.sessions", "Session limit") }) }),
|
|
1074
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.idle", "Inactivity timeout") }) }),
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.roleRules.col.lockout", "Account lockout") }) }),
|
|
1076
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("settings.roleRules.col.actions", "Actions") }) })
|
|
1077
|
+
] }) }),
|
|
1078
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-role-rule": rule.role, children: [
|
|
1079
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: roleName(rule.role) }) }),
|
|
1080
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.maxSessionsPerUser, format: sessions }) }),
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.inactivityTimeout, format: minutes }) }),
|
|
1082
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(RuleValue, { value: rule.maxFailedLoginsPerAccount, format: failures }) }),
|
|
1083
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: actions(rule) })
|
|
1084
|
+
] }, rule.role)) })
|
|
1085
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", children: rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1086
|
+
designSystem.Box,
|
|
1087
|
+
{
|
|
1088
|
+
tag: "li",
|
|
1089
|
+
padding: 4,
|
|
1090
|
+
hasRadius: true,
|
|
1091
|
+
borderColor: "neutral150",
|
|
1092
|
+
"data-role-rule": rule.role,
|
|
1093
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
|
|
1094
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
1095
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: roleName(rule.role) }),
|
|
1096
|
+
[
|
|
1097
|
+
[
|
|
1098
|
+
"settings.roleRules.col.sessions",
|
|
1099
|
+
"Session limit",
|
|
1100
|
+
rule.maxSessionsPerUser,
|
|
1101
|
+
sessions
|
|
1102
|
+
],
|
|
1103
|
+
[
|
|
1104
|
+
"settings.roleRules.col.idle",
|
|
1105
|
+
"Inactivity timeout",
|
|
1106
|
+
rule.inactivityTimeout,
|
|
1107
|
+
minutes
|
|
1108
|
+
],
|
|
1109
|
+
[
|
|
1110
|
+
"settings.roleRules.col.lockout",
|
|
1111
|
+
"Account lockout",
|
|
1112
|
+
rule.maxFailedLoginsPerAccount,
|
|
1113
|
+
failures
|
|
1114
|
+
]
|
|
1115
|
+
].map(([id, label, value, format]) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.roleRules.line", "{label}: {value}", {
|
|
1116
|
+
label: t(id, label),
|
|
1117
|
+
value: value === null || value === void 0 ? t("settings.roleRules.general", "General setting") : format(value)
|
|
1118
|
+
}) }, id))
|
|
1119
|
+
] }),
|
|
1120
|
+
actions(rule)
|
|
1121
|
+
] })
|
|
1122
|
+
},
|
|
1123
|
+
rule.role
|
|
1124
|
+
)) }) }),
|
|
1125
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, wrap: "wrap", alignItems: "center", children: [
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
+
designSystem.Button,
|
|
1128
|
+
{
|
|
1129
|
+
ref: addRef,
|
|
1130
|
+
variant: "secondary",
|
|
1131
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
1132
|
+
disabled: locked || roles !== null && availableRoles.length === 0 && !dialog,
|
|
1133
|
+
onClick: () => open(null, addRef.current),
|
|
1134
|
+
children: t("settings.roleRules.add", "Add rule")
|
|
1135
|
+
}
|
|
1136
|
+
),
|
|
1137
|
+
roles !== null && roles.length > 0 && availableRoles.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", "data-role-rules-full": "", children: t(
|
|
1138
|
+
"settings.roleRules.allRoles",
|
|
1139
|
+
"Every role already has a rule. Edit a rule to change it."
|
|
1140
|
+
) }) : null
|
|
1141
|
+
] }),
|
|
1142
|
+
/* @__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: [
|
|
1143
|
+
/* @__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}", {
|
|
1144
|
+
role: roleName(dialog.editing)
|
|
1145
|
+
}) : t("settings.roleRules.dialog.addTitle", "Add a rule for a role") }) }),
|
|
1146
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 5, children: [
|
|
1147
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1148
|
+
FormField,
|
|
1149
|
+
{
|
|
1150
|
+
id: "role-rule-role",
|
|
1151
|
+
name: "role",
|
|
1152
|
+
label: t("settings.roleRules.col.role", "Role"),
|
|
1153
|
+
error: fieldError("role"),
|
|
1154
|
+
required: true,
|
|
1155
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1156
|
+
designSystem.SingleSelect,
|
|
1157
|
+
{
|
|
1158
|
+
value: draft.role || void 0,
|
|
1159
|
+
placeholder: t("settings.roleRules.dialog.rolePlaceholder", "Choose a role"),
|
|
1160
|
+
onChange: (value) => setDraft((previous) => ({ ...previous, role: value })),
|
|
1161
|
+
children: (roles || []).filter(
|
|
1162
|
+
(role) => role.documentId === draft.role || !taken.includes(role.documentId)
|
|
1163
|
+
).map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: role.documentId, children: role.name }, role.documentId))
|
|
1164
|
+
}
|
|
1165
|
+
)
|
|
1166
|
+
}
|
|
1167
|
+
),
|
|
1168
|
+
[
|
|
1169
|
+
[
|
|
1170
|
+
"maxSessionsPerUser",
|
|
1171
|
+
"role-rule-sessions",
|
|
1172
|
+
t("settings.config.sessionLimit.max.label", "Open sessions per user"),
|
|
1173
|
+
t("settings.roleRules.dialog.sessionsHint", "0 means no limit for this role."),
|
|
1174
|
+
t("settings.roleRules.dialog.sessionsSuffix", "sessions")
|
|
1175
|
+
],
|
|
1176
|
+
[
|
|
1177
|
+
"inactivityTimeout",
|
|
1178
|
+
"role-rule-idle",
|
|
1179
|
+
t("settings.config.sessions.inactivity.label", "Inactivity timeout"),
|
|
1180
|
+
t("settings.roleRules.dialog.idleHint", "From 1 to 1440 minutes."),
|
|
1181
|
+
t("settings.config.failed.minutes.suffix", "minutes")
|
|
1182
|
+
],
|
|
1183
|
+
[
|
|
1184
|
+
"maxFailedLoginsPerAccount",
|
|
1185
|
+
"role-rule-lockout",
|
|
1186
|
+
t("settings.config.failed.account.label", "Lock an account after"),
|
|
1187
|
+
t(
|
|
1188
|
+
"settings.roleRules.dialog.lockoutHint",
|
|
1189
|
+
"0 turns the account lockout off for this role."
|
|
1190
|
+
),
|
|
1191
|
+
t("settings.config.failed.lockout.suffix", "failed sign-ins")
|
|
1192
|
+
]
|
|
1193
|
+
].map(([key, id, label, hint, suffix]) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1194
|
+
FormField,
|
|
1195
|
+
{
|
|
1196
|
+
id,
|
|
1197
|
+
name: key,
|
|
1198
|
+
label,
|
|
1199
|
+
description: `${hint} ${t("settings.roleRules.dialog.emptyHint", "Leave empty to use the general setting.")}`,
|
|
1200
|
+
suffix,
|
|
1201
|
+
error: fieldError(key),
|
|
1202
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1203
|
+
designSystem.NumberInput,
|
|
1204
|
+
{
|
|
1205
|
+
value: draft[key],
|
|
1206
|
+
onValueChange: (value) => setDraft((previous) => ({ ...previous, [key]: value })),
|
|
1207
|
+
min: ROLE_RULE_RANGES[key].min,
|
|
1208
|
+
max: ROLE_RULE_RANGES[key].max,
|
|
1209
|
+
step: 1
|
|
1210
|
+
}
|
|
1211
|
+
)
|
|
1212
|
+
},
|
|
1213
|
+
key
|
|
1214
|
+
)),
|
|
1215
|
+
showErrors && draftErrors.form ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", tag: "p", role: "alert", children: tError(draftErrors.form) }) : null
|
|
1216
|
+
] }) }),
|
|
1217
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
1218
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: t("common.cancel", "Cancel") }) }),
|
|
1219
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: submit, children: dialog?.editing ? t("settings.roleRules.dialog.apply", "Apply") : t("settings.roleRules.dialog.add", "Add rule") })
|
|
1220
|
+
] })
|
|
1221
|
+
] }) })
|
|
1222
|
+
]
|
|
1223
|
+
}
|
|
1224
|
+
);
|
|
1225
|
+
};
|
|
740
1226
|
const REJECTION_REASONS = [
|
|
741
1227
|
["logout", "settings.config.rejected.reason.logout", "The user signed out."],
|
|
742
1228
|
[
|
|
@@ -767,10 +1253,12 @@ const formatReasonCodes = (locale) => {
|
|
|
767
1253
|
}
|
|
768
1254
|
};
|
|
769
1255
|
const SessionsTab = ({ form }) => {
|
|
770
|
-
const { t, locale } = useSettingsTranslate();
|
|
1256
|
+
const { t, tError, locale } = useSettingsTranslate();
|
|
771
1257
|
const units = useOptionLabels();
|
|
772
1258
|
const encryptionKeyDraft = useEncryptionKeyDraft();
|
|
773
|
-
const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed } = form;
|
|
1259
|
+
const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed, errors } = form;
|
|
1260
|
+
const sessionLimit = Number(settings.maxSessionsPerUser) || 0;
|
|
1261
|
+
const locked = form.canChangeProtected === false;
|
|
774
1262
|
const lastSeenTooSlow = Number(settings.lastSeenRateLimit) * 2 > Number(settings.inactivityTimeout) * 60;
|
|
775
1263
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
776
1264
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
@@ -961,6 +1449,127 @@ const SessionsTab = ({ form }) => {
|
|
|
961
1449
|
]
|
|
962
1450
|
}
|
|
963
1451
|
),
|
|
1452
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1453
|
+
SectionCard.SectionCard,
|
|
1454
|
+
{
|
|
1455
|
+
id: "session-limit",
|
|
1456
|
+
title: t("settings.config.sessionLimit.title", "Concurrent sessions"),
|
|
1457
|
+
subtitle: t(
|
|
1458
|
+
"settings.config.sessionLimit.intro",
|
|
1459
|
+
"Limits how many sessions one user can have open at the same time."
|
|
1460
|
+
),
|
|
1461
|
+
children: [
|
|
1462
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
1463
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1464
|
+
FormField,
|
|
1465
|
+
{
|
|
1466
|
+
id: "max-sessions-per-user",
|
|
1467
|
+
name: "maxSessionsPerUser",
|
|
1468
|
+
label: t("settings.config.sessionLimit.max.label", "Open sessions per user"),
|
|
1469
|
+
description: t(
|
|
1470
|
+
"settings.config.sessionLimit.max.hint",
|
|
1471
|
+
"0 means no limit. Sessions that are idle or past their maximum age do not count."
|
|
1472
|
+
),
|
|
1473
|
+
suffix: t("settings.roleRules.dialog.sessionsSuffix", "sessions"),
|
|
1474
|
+
error: tError(errors.maxSessionsPerUser),
|
|
1475
|
+
required: true,
|
|
1476
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1477
|
+
designSystem.NumberInput,
|
|
1478
|
+
{
|
|
1479
|
+
value: settings.maxSessionsPerUser,
|
|
1480
|
+
onValueChange: (value) => handleChange("maxSessionsPerUser", value ?? ""),
|
|
1481
|
+
disabled: locked,
|
|
1482
|
+
min: POLICY_RANGES.maxSessionsPerUser.min,
|
|
1483
|
+
max: POLICY_RANGES.maxSessionsPerUser.max,
|
|
1484
|
+
step: 1
|
|
1485
|
+
},
|
|
1486
|
+
form.draftVersion
|
|
1487
|
+
)
|
|
1488
|
+
}
|
|
1489
|
+
) }),
|
|
1490
|
+
sessionLimit > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-session-limit-policy": "", children: [
|
|
1491
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1492
|
+
designSystem.Typography,
|
|
1493
|
+
{
|
|
1494
|
+
id: "session-limit-policy-label",
|
|
1495
|
+
variant: "pi",
|
|
1496
|
+
fontWeight: "bold",
|
|
1497
|
+
tag: "div",
|
|
1498
|
+
textColor: "neutral800",
|
|
1499
|
+
children: t("settings.config.sessionLimit.policy.label", "When the limit is reached")
|
|
1500
|
+
}
|
|
1501
|
+
),
|
|
1502
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1503
|
+
designSystem.Radio.Group,
|
|
1504
|
+
{
|
|
1505
|
+
"aria-labelledby": "session-limit-policy-label",
|
|
1506
|
+
value: settings.sessionLimitPolicy || "end-oldest",
|
|
1507
|
+
disabled: locked,
|
|
1508
|
+
onValueChange: (value) => handleChange("sessionLimitPolicy", value),
|
|
1509
|
+
children: [
|
|
1510
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "end-oldest", children: t("settings.config.sessionLimit.policy.endOldest", "End the oldest session") }),
|
|
1511
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "refuse", children: t("settings.config.sessionLimit.policy.refuse", "Refuse the new sign-in") })
|
|
1512
|
+
]
|
|
1513
|
+
}
|
|
1514
|
+
),
|
|
1515
|
+
settings.sessionLimitPolicy === "refuse" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1516
|
+
designSystem.Alert,
|
|
1517
|
+
{
|
|
1518
|
+
variant: "warning",
|
|
1519
|
+
closeLabel: t("common.close", "Close"),
|
|
1520
|
+
title: t(
|
|
1521
|
+
"settings.config.sessionLimit.refuse.title",
|
|
1522
|
+
"Users can lock themselves out"
|
|
1523
|
+
),
|
|
1524
|
+
children: t(
|
|
1525
|
+
"settings.config.sessionLimit.refuse.body",
|
|
1526
|
+
"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."
|
|
1527
|
+
)
|
|
1528
|
+
}
|
|
1529
|
+
) : null
|
|
1530
|
+
] }) : null
|
|
1531
|
+
]
|
|
1532
|
+
}
|
|
1533
|
+
),
|
|
1534
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1535
|
+
SectionCard.SectionCard,
|
|
1536
|
+
{
|
|
1537
|
+
id: "password-change",
|
|
1538
|
+
title: t("settings.config.passwordChange.title", "Password change"),
|
|
1539
|
+
children: [
|
|
1540
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
1541
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1542
|
+
SettingsToggleRow,
|
|
1543
|
+
{
|
|
1544
|
+
id: "end-other-sessions-on-password-change",
|
|
1545
|
+
title: t(
|
|
1546
|
+
"settings.config.passwordChange.label",
|
|
1547
|
+
"End other sessions after a password change"
|
|
1548
|
+
),
|
|
1549
|
+
description: t(
|
|
1550
|
+
"settings.config.passwordChange.hint",
|
|
1551
|
+
"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."
|
|
1552
|
+
),
|
|
1553
|
+
checked: settings.endOtherSessionsOnPasswordChange === true,
|
|
1554
|
+
disabled: locked,
|
|
1555
|
+
onChange: (checked) => handleChange("endOtherSessionsOnPasswordChange", checked)
|
|
1556
|
+
}
|
|
1557
|
+
)
|
|
1558
|
+
]
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1562
|
+
SectionCard.SectionCard,
|
|
1563
|
+
{
|
|
1564
|
+
id: "role-rules",
|
|
1565
|
+
title: t("settings.roleRules.cardTitle", "Roles"),
|
|
1566
|
+
subtitle: t(
|
|
1567
|
+
"settings.roleRules.cardIntro",
|
|
1568
|
+
"Optional. Most installations need no role rules."
|
|
1569
|
+
),
|
|
1570
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RoleRulesSection, { form })
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
964
1573
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
965
1574
|
SectionCard.SectionCard,
|
|
966
1575
|
{
|
|
@@ -1014,7 +1623,14 @@ function areSettingsEqual(left, right) {
|
|
|
1014
1623
|
(key, index2) => key === rightKeys[index2] && areSettingsEqual(left[key], right[key])
|
|
1015
1624
|
);
|
|
1016
1625
|
}
|
|
1017
|
-
const TEMPLATE_KEYS = Object.freeze([
|
|
1626
|
+
const TEMPLATE_KEYS = Object.freeze([
|
|
1627
|
+
"suspiciousLogin",
|
|
1628
|
+
"newLocation",
|
|
1629
|
+
"vpnProxy",
|
|
1630
|
+
"accountLocked",
|
|
1631
|
+
"newDevice",
|
|
1632
|
+
"impossibleTravel"
|
|
1633
|
+
]);
|
|
1018
1634
|
const TEMPLATE_LIMITS = Object.freeze({ subject: 200, html: 1e4, text: 5e3 });
|
|
1019
1635
|
const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
|
|
1020
1636
|
"{{user.email}}": {
|
|
@@ -1064,6 +1680,30 @@ const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
|
|
|
1064
1680
|
"{{reason.securityScore}}": {
|
|
1065
1681
|
messageId: "settings.email.templates.variable.securityScore",
|
|
1066
1682
|
defaultMessage: "Security score (0 to 100)"
|
|
1683
|
+
},
|
|
1684
|
+
"{{lock.minutes}}": {
|
|
1685
|
+
messageId: "settings.email.templates.variable.lockMinutes",
|
|
1686
|
+
defaultMessage: "Lock duration in minutes"
|
|
1687
|
+
},
|
|
1688
|
+
"{{lock.until}}": {
|
|
1689
|
+
messageId: "settings.email.templates.variable.lockUntil",
|
|
1690
|
+
defaultMessage: "Time the lock ends (UTC)"
|
|
1691
|
+
},
|
|
1692
|
+
"{{device.browser}}": {
|
|
1693
|
+
messageId: "settings.email.templates.variable.deviceBrowser",
|
|
1694
|
+
defaultMessage: "Browser of the sign-in"
|
|
1695
|
+
},
|
|
1696
|
+
"{{device.os}}": {
|
|
1697
|
+
messageId: "settings.email.templates.variable.deviceOs",
|
|
1698
|
+
defaultMessage: "Operating system of the sign-in"
|
|
1699
|
+
},
|
|
1700
|
+
"{{travel.distanceKm}}": {
|
|
1701
|
+
messageId: "settings.email.templates.variable.travelDistance",
|
|
1702
|
+
defaultMessage: "Distance from the previous sign-in in km"
|
|
1703
|
+
},
|
|
1704
|
+
"{{link.notMe}}": {
|
|
1705
|
+
messageId: "settings.email.templates.variable.notMe",
|
|
1706
|
+
defaultMessage: "“This wasn’t me” link (works once, 72 hours)"
|
|
1067
1707
|
}
|
|
1068
1708
|
});
|
|
1069
1709
|
const TEMPLATE_VARIABLES = Object.freeze({
|
|
@@ -1101,6 +1741,29 @@ const TEMPLATE_VARIABLES = Object.freeze({
|
|
|
1101
1741
|
"{{session.userAgent}}",
|
|
1102
1742
|
"{{reason.isVpn}}",
|
|
1103
1743
|
"{{reason.isProxy}}"
|
|
1744
|
+
],
|
|
1745
|
+
accountLocked: ["{{user.email}}", "{{user.username}}", "{{lock.minutes}}", "{{lock.until}}"],
|
|
1746
|
+
newDevice: [
|
|
1747
|
+
"{{user.email}}",
|
|
1748
|
+
"{{user.username}}",
|
|
1749
|
+
"{{session.loginTime}}",
|
|
1750
|
+
"{{session.ipAddress}}",
|
|
1751
|
+
"{{geo.city}}",
|
|
1752
|
+
"{{geo.country}}",
|
|
1753
|
+
"{{device.browser}}",
|
|
1754
|
+
"{{device.os}}",
|
|
1755
|
+
"{{link.notMe}}"
|
|
1756
|
+
],
|
|
1757
|
+
impossibleTravel: [
|
|
1758
|
+
"{{user.email}}",
|
|
1759
|
+
"{{user.username}}",
|
|
1760
|
+
"{{session.loginTime}}",
|
|
1761
|
+
"{{geo.city}}",
|
|
1762
|
+
"{{geo.country}}",
|
|
1763
|
+
"{{device.browser}}",
|
|
1764
|
+
"{{device.os}}",
|
|
1765
|
+
"{{travel.distanceKm}}",
|
|
1766
|
+
"{{link.notMe}}"
|
|
1104
1767
|
]
|
|
1105
1768
|
});
|
|
1106
1769
|
const TEMPLATE_PREVIEW_VALUES = Object.freeze({
|
|
@@ -1115,7 +1778,13 @@ const TEMPLATE_PREVIEW_VALUES = Object.freeze({
|
|
|
1115
1778
|
"{{reason.isVpn}}": "true",
|
|
1116
1779
|
"{{reason.isProxy}}": "false",
|
|
1117
1780
|
"{{reason.isThreat}}": "false",
|
|
1118
|
-
"{{reason.securityScore}}": "35"
|
|
1781
|
+
"{{reason.securityScore}}": "35",
|
|
1782
|
+
"{{lock.minutes}}": "15",
|
|
1783
|
+
"{{lock.until}}": "Fri, 06 Nov 2026 09:56:00 GMT",
|
|
1784
|
+
"{{device.browser}}": "Firefox",
|
|
1785
|
+
"{{device.os}}": "macOS",
|
|
1786
|
+
"{{travel.distanceKm}}": "16032",
|
|
1787
|
+
"{{link.notMe}}": "https://app.example.com/api/magic-sessionmanager/not-me?token=preview"
|
|
1119
1788
|
});
|
|
1120
1789
|
function updateEmailTemplate(templates, templateKey, field, value) {
|
|
1121
1790
|
return { ...templates, [templateKey]: { ...templates[templateKey], [field]: value } };
|
|
@@ -1376,6 +2045,97 @@ Login Details:
|
|
|
1376
2045
|
- IP Address: {{session.ipAddress}}
|
|
1377
2046
|
- Location: {{geo.city}}, {{geo.country}}
|
|
1378
2047
|
- VPN: {{reason.isVpn}}, Proxy: {{reason.isProxy}}`
|
|
2048
|
+
},
|
|
2049
|
+
// Same default as server/src/services/notifications.js (4.17).
|
|
2050
|
+
accountLocked: {
|
|
2051
|
+
subject: "Your account was locked after failed sign-ins",
|
|
2052
|
+
html: `<html>
|
|
2053
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
|
2054
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
2055
|
+
<h2>Your account was temporarily locked</h2>
|
|
2056
|
+
<p>Hello {{user.username}},</p>
|
|
2057
|
+
<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>
|
|
2058
|
+
<p>If these attempts were not yours, change your password after the lock ends.</p>
|
|
2059
|
+
<p style="color: #666; font-size: 12px;">This is an automated security notification.</p>
|
|
2060
|
+
</div>
|
|
2061
|
+
</body>
|
|
2062
|
+
</html>`,
|
|
2063
|
+
text: `Your account was temporarily locked
|
|
2064
|
+
|
|
2065
|
+
Hello {{user.username}},
|
|
2066
|
+
|
|
2067
|
+
There were several failed sign-in attempts for your account. To protect it, sign-in is locked for {{lock.minutes}} minutes, until {{lock.until}}.
|
|
2068
|
+
|
|
2069
|
+
If these attempts were not yours, change your password after the lock ends.`
|
|
2070
|
+
},
|
|
2071
|
+
newDevice: {
|
|
2072
|
+
subject: "New sign-in to your account",
|
|
2073
|
+
html: `<html>
|
|
2074
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
|
2075
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
2076
|
+
<h2>New sign-in to your account</h2>
|
|
2077
|
+
<p>Hello {{user.username}},</p>
|
|
2078
|
+
<p>Your account was just used on a device we have not seen before.</p>
|
|
2079
|
+
<ul>
|
|
2080
|
+
<li>Time: {{session.loginTime}}</li>
|
|
2081
|
+
<li>Device: {{device.browser}} on {{device.os}}</li>
|
|
2082
|
+
<li>Location: {{geo.city}}, {{geo.country}}</li>
|
|
2083
|
+
<li>IP address: {{session.ipAddress}}</li>
|
|
2084
|
+
</ul>
|
|
2085
|
+
<p>If this was you, you can ignore this email.</p>
|
|
2086
|
+
<p>If this was not you, <a href="{{link.notMe}}">sign this device out</a> and change your password.</p>
|
|
2087
|
+
<p style="color: #666; font-size: 12px;">The link works once and expires after 72 hours.</p>
|
|
2088
|
+
</div>
|
|
2089
|
+
</body>
|
|
2090
|
+
</html>`,
|
|
2091
|
+
text: `New sign-in to your account
|
|
2092
|
+
|
|
2093
|
+
Hello {{user.username}},
|
|
2094
|
+
|
|
2095
|
+
Your account was just used on a device we have not seen before.
|
|
2096
|
+
|
|
2097
|
+
Time: {{session.loginTime}}
|
|
2098
|
+
Device: {{device.browser}} on {{device.os}}
|
|
2099
|
+
Location: {{geo.city}}, {{geo.country}}
|
|
2100
|
+
IP address: {{session.ipAddress}}
|
|
2101
|
+
|
|
2102
|
+
If this was not you, sign this device out and change your password:
|
|
2103
|
+
{{link.notMe}}
|
|
2104
|
+
|
|
2105
|
+
The link works once and expires after 72 hours.`
|
|
2106
|
+
},
|
|
2107
|
+
impossibleTravel: {
|
|
2108
|
+
subject: "Unusual sign-in to your account",
|
|
2109
|
+
html: `<html>
|
|
2110
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
|
2111
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
2112
|
+
<h2>Unusual sign-in to your account</h2>
|
|
2113
|
+
<p>Hello {{user.username}},</p>
|
|
2114
|
+
<p>Your account was used about {{travel.distanceKm}} km away from your previous sign-in, sooner than anyone could travel that far.</p>
|
|
2115
|
+
<ul>
|
|
2116
|
+
<li>Time: {{session.loginTime}}</li>
|
|
2117
|
+
<li>Location: {{geo.city}}, {{geo.country}}</li>
|
|
2118
|
+
<li>Device: {{device.browser}} on {{device.os}}</li>
|
|
2119
|
+
</ul>
|
|
2120
|
+
<p>A VPN or a mobile network can cause this. If this was not you, <a href="{{link.notMe}}">sign this device out</a> and change your password.</p>
|
|
2121
|
+
<p style="color: #666; font-size: 12px;">The link works once and expires after 72 hours.</p>
|
|
2122
|
+
</div>
|
|
2123
|
+
</body>
|
|
2124
|
+
</html>`,
|
|
2125
|
+
text: `Unusual sign-in to your account
|
|
2126
|
+
|
|
2127
|
+
Hello {{user.username}},
|
|
2128
|
+
|
|
2129
|
+
Your account was used about {{travel.distanceKm}} km away from your previous sign-in, sooner than anyone could travel that far.
|
|
2130
|
+
|
|
2131
|
+
Time: {{session.loginTime}}
|
|
2132
|
+
Location: {{geo.city}}, {{geo.country}}
|
|
2133
|
+
Device: {{device.browser}} on {{device.os}}
|
|
2134
|
+
|
|
2135
|
+
A VPN or a mobile network can cause this. If this was not you, sign this device out and change your password:
|
|
2136
|
+
{{link.notMe}}
|
|
2137
|
+
|
|
2138
|
+
The link works once and expires after 72 hours.`
|
|
1379
2139
|
}
|
|
1380
2140
|
});
|
|
1381
2141
|
function fillMissingTemplates(templates) {
|
|
@@ -1395,6 +2155,156 @@ function fillMissingTemplates(templates) {
|
|
|
1395
2155
|
})
|
|
1396
2156
|
);
|
|
1397
2157
|
}
|
|
2158
|
+
const SIGNALS_FORM_DEFAULTS = Object.freeze({
|
|
2159
|
+
alertOnNewDevice: false,
|
|
2160
|
+
alertOnImpossibleTravel: false,
|
|
2161
|
+
impossibleTravelEnabled: false,
|
|
2162
|
+
impossibleTravelSpeedKmh: 1e3,
|
|
2163
|
+
impossibleTravelMinDistanceKm: 500,
|
|
2164
|
+
impossibleTravelAction: "alert",
|
|
2165
|
+
webhookEvents: Object.freeze([
|
|
2166
|
+
"login.suspicious",
|
|
2167
|
+
"login.new_location",
|
|
2168
|
+
"login.new_device",
|
|
2169
|
+
"login.impossible_travel",
|
|
2170
|
+
"lockout",
|
|
2171
|
+
"user.not_me"
|
|
2172
|
+
]),
|
|
2173
|
+
genericWebhookEnabled: false,
|
|
2174
|
+
// Read-only facts from the server: the URL and the secret are write-only.
|
|
2175
|
+
hasGenericWebhook: false,
|
|
2176
|
+
genericWebhookHint: null,
|
|
2177
|
+
hasGenericWebhookSecret: false,
|
|
2178
|
+
sessionIpAnonymize: false
|
|
2179
|
+
});
|
|
2180
|
+
const WEBHOOK_EVENT_OPTIONS = Object.freeze([
|
|
2181
|
+
["login.success", "settings.webhookEvents.loginSuccess", "Every successful sign-in"],
|
|
2182
|
+
["login.suspicious", "settings.webhookEvents.loginSuspicious", "Suspicious sign-in"],
|
|
2183
|
+
["login.new_location", "settings.webhookEvents.loginNewLocation", "Sign-in from a new country"],
|
|
2184
|
+
["login.new_device", "settings.webhookEvents.loginNewDevice", "Sign-in from a new device"],
|
|
2185
|
+
["login.impossible_travel", "settings.webhookEvents.impossibleTravel", "Impossible travel"],
|
|
2186
|
+
["login.failed", "settings.webhookEvents.loginFailed", "Failed sign-in"],
|
|
2187
|
+
["login.refused", "settings.webhookEvents.loginRefused", "Refused sign-in"],
|
|
2188
|
+
["lockout", "settings.webhookEvents.lockout", "IP address or account locked"],
|
|
2189
|
+
["lockout.lifted", "settings.webhookEvents.lockoutLifted", "Lock lifted by an admin"],
|
|
2190
|
+
["session.limit", "settings.webhookEvents.sessionLimit", "Session limit reached"],
|
|
2191
|
+
[
|
|
2192
|
+
"password.changed",
|
|
2193
|
+
"settings.webhookEvents.passwordChanged",
|
|
2194
|
+
"Sessions ended after a password change"
|
|
2195
|
+
],
|
|
2196
|
+
["user.not_me", "settings.webhookEvents.notMe", `"This wasn't me" used`]
|
|
2197
|
+
]);
|
|
2198
|
+
const SIGNALS_RANGES = Object.freeze({
|
|
2199
|
+
impossibleTravelSpeedKmh: Object.freeze({ min: 100, max: 5e3 }),
|
|
2200
|
+
impossibleTravelMinDistanceKm: Object.freeze({ min: 50, max: 2e4 })
|
|
2201
|
+
});
|
|
2202
|
+
const RETENTION_PRESETS = Object.freeze({
|
|
2203
|
+
minimal: Object.freeze({ retentionDays: 7, securityLogRetentionDays: 30 }),
|
|
2204
|
+
standard: Object.freeze({ retentionDays: 90, securityLogRetentionDays: 90 }),
|
|
2205
|
+
extended: Object.freeze({ retentionDays: 365, securityLogRetentionDays: 365 })
|
|
2206
|
+
});
|
|
2207
|
+
const message$1 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
|
|
2208
|
+
function currentRetentionPreset(settings) {
|
|
2209
|
+
const match = Object.entries(RETENTION_PRESETS).find(
|
|
2210
|
+
([, values]) => Number(settings?.retentionDays) === values.retentionDays && Number(settings?.securityLogRetentionDays) === values.securityLogRetentionDays
|
|
2211
|
+
);
|
|
2212
|
+
return match ? match[0] : "custom";
|
|
2213
|
+
}
|
|
2214
|
+
function isWebhookUrl(value) {
|
|
2215
|
+
if (typeof value !== "string" || value.length > 2048) return false;
|
|
2216
|
+
try {
|
|
2217
|
+
const url = new URL(value.trim());
|
|
2218
|
+
const host = url.hostname.toLowerCase();
|
|
2219
|
+
return url.protocol === "https:" && !url.username && !url.password && !!host && host !== "localhost" && !host.endsWith(".localhost") && !host.endsWith(".local");
|
|
2220
|
+
} catch {
|
|
2221
|
+
return false;
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
function validateSignalFields(settings) {
|
|
2225
|
+
const source = settings || {};
|
|
2226
|
+
const errors = {};
|
|
2227
|
+
for (const [key, { min, max }] of Object.entries(SIGNALS_RANGES)) {
|
|
2228
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
|
|
2229
|
+
const value = source[key];
|
|
2230
|
+
const number = Number(value);
|
|
2231
|
+
if (value === void 0 || value === null || value === "") {
|
|
2232
|
+
errors[key] = message$1("settings.validation.required", "Enter a value.");
|
|
2233
|
+
} else if (!Number.isInteger(number) || number < min || number > max) {
|
|
2234
|
+
errors[key] = message$1(
|
|
2235
|
+
"settings.validation.range",
|
|
2236
|
+
"Enter a whole number from {min} to {max}.",
|
|
2237
|
+
{
|
|
2238
|
+
min,
|
|
2239
|
+
max
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
if (typeof source.genericWebhookUrl === "string" && source.genericWebhookUrl && !isWebhookUrl(source.genericWebhookUrl)) {
|
|
2245
|
+
errors.genericWebhookUrl = message$1(
|
|
2246
|
+
"settings.validation.webhookUrl",
|
|
2247
|
+
"Enter an https address without a user name or password, for example https://hooks.example.com/sessions."
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
if (typeof source.genericWebhookSecret === "string" && source.genericWebhookSecret && !/^[\x21-\x7e]{32,256}$/.test(source.genericWebhookSecret)) {
|
|
2251
|
+
errors.genericWebhookSecret = message$1(
|
|
2252
|
+
"settings.validation.webhookSecret",
|
|
2253
|
+
"Use 32 to 256 characters without spaces, or generate one."
|
|
2254
|
+
);
|
|
2255
|
+
}
|
|
2256
|
+
return errors;
|
|
2257
|
+
}
|
|
2258
|
+
function generateWebhookSecret(cryptoApi = globalThis.crypto) {
|
|
2259
|
+
const bytes = cryptoApi.getRandomValues(new Uint8Array(48));
|
|
2260
|
+
let binary = "";
|
|
2261
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
2262
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2263
|
+
}
|
|
2264
|
+
function describeWebhookTest(result) {
|
|
2265
|
+
if (result?.ok) {
|
|
2266
|
+
return {
|
|
2267
|
+
...message$1("settings.signedWebhook.test.ok", "Delivered. The receiver answered {status}.", {
|
|
2268
|
+
status: result.status
|
|
2269
|
+
}),
|
|
2270
|
+
tone: "success"
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2273
|
+
const code = String(result?.code || "network_error");
|
|
2274
|
+
const known = {
|
|
2275
|
+
no_url: ["settings.signedWebhook.test.noUrl", "Save a URL first."],
|
|
2276
|
+
no_secret: ["settings.signedWebhook.test.noSecret", "Save a secret first."],
|
|
2277
|
+
invalid_url: [
|
|
2278
|
+
"settings.signedWebhook.test.invalidUrl",
|
|
2279
|
+
"The saved URL is not a valid https address."
|
|
2280
|
+
],
|
|
2281
|
+
dns_failed: ["settings.signedWebhook.test.dns", "The host name could not be resolved."],
|
|
2282
|
+
address_not_allowed: [
|
|
2283
|
+
"settings.signedWebhook.test.blocked",
|
|
2284
|
+
"Not sent: the host resolves to a private, local or reserved address."
|
|
2285
|
+
],
|
|
2286
|
+
timeout: [
|
|
2287
|
+
"settings.signedWebhook.test.timeout",
|
|
2288
|
+
"The receiver did not answer within 5 seconds."
|
|
2289
|
+
],
|
|
2290
|
+
redirect_not_followed: [
|
|
2291
|
+
"settings.signedWebhook.test.redirect",
|
|
2292
|
+
"The receiver answered with a redirect. Redirects are not followed; use the final URL."
|
|
2293
|
+
],
|
|
2294
|
+
network_error: ["settings.signedWebhook.test.network", "The connection failed."]
|
|
2295
|
+
};
|
|
2296
|
+
if (known[code]) return { ...message$1(known[code][0], known[code][1]), tone: "danger" };
|
|
2297
|
+
const status = /^http_(\d{3})$/.exec(code);
|
|
2298
|
+
if (status) {
|
|
2299
|
+
return {
|
|
2300
|
+
...message$1("settings.signedWebhook.test.http", "The receiver answered {status}.", {
|
|
2301
|
+
status: Number(status[1])
|
|
2302
|
+
}),
|
|
2303
|
+
tone: "danger"
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
return { ...message$1(known.network_error[0], known.network_error[1]), tone: "danger" };
|
|
2307
|
+
}
|
|
1398
2308
|
const SETTINGS_DEFAULTS = Object.freeze({
|
|
1399
2309
|
inactivityTimeout: 15,
|
|
1400
2310
|
cleanupInterval: 30,
|
|
@@ -1432,9 +2342,16 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
1432
2342
|
securityLogStoreIp: true,
|
|
1433
2343
|
securityLogAnonymizeIp: false,
|
|
1434
2344
|
securityLogGeoLookup: false,
|
|
1435
|
-
securityLogRetentionDays: 90
|
|
2345
|
+
securityLogRetentionDays: 90,
|
|
2346
|
+
...POLICY_FORM_DEFAULTS,
|
|
2347
|
+
...SIGNALS_FORM_DEFAULTS
|
|
1436
2348
|
});
|
|
1437
|
-
const WRITE_ONLY_SETTINGS_KEYS = Object.freeze([
|
|
2349
|
+
const WRITE_ONLY_SETTINGS_KEYS = Object.freeze([
|
|
2350
|
+
"discordWebhookUrl",
|
|
2351
|
+
"slackWebhookUrl",
|
|
2352
|
+
"genericWebhookUrl",
|
|
2353
|
+
"genericWebhookSecret"
|
|
2354
|
+
]);
|
|
1438
2355
|
const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
|
|
1439
2356
|
const WEBHOOK_HOSTS = Object.freeze({
|
|
1440
2357
|
discordWebhookUrl: ["discord.com", "discordapp.com"],
|
|
@@ -1455,6 +2372,9 @@ function normalizeSettings(loaded) {
|
|
|
1455
2372
|
...loaded,
|
|
1456
2373
|
allowedCountries: Array.isArray(loaded.allowedCountries) ? loaded.allowedCountries : [],
|
|
1457
2374
|
blockedCountries: Array.isArray(loaded.blockedCountries) ? loaded.blockedCountries : [],
|
|
2375
|
+
lockoutTrustedAddresses: Array.isArray(loaded.lockoutTrustedAddresses) ? loaded.lockoutTrustedAddresses : [],
|
|
2376
|
+
roleRules: Array.isArray(loaded.roleRules) ? loaded.roleRules : [],
|
|
2377
|
+
webhookEvents: Array.isArray(loaded.webhookEvents) ? loaded.webhookEvents : [...SIGNALS_FORM_DEFAULTS.webhookEvents],
|
|
1458
2378
|
emailTemplates: fillMissingTemplates(loaded.emailTemplates)
|
|
1459
2379
|
};
|
|
1460
2380
|
}
|
|
@@ -1504,6 +2424,8 @@ function validateSettings(settings) {
|
|
|
1504
2424
|
const source = settings || {};
|
|
1505
2425
|
const maxFailed = validateMaxFailedLogins(source.maxFailedLogins);
|
|
1506
2426
|
if (maxFailed) errors.maxFailedLogins = maxFailed;
|
|
2427
|
+
Object.assign(errors, validatePolicyFields(source));
|
|
2428
|
+
Object.assign(errors, validateSignalFields(source));
|
|
1507
2429
|
if (!isAllowedWebhookUrl(source.discordWebhookUrl, WEBHOOK_HOSTS.discordWebhookUrl)) {
|
|
1508
2430
|
errors.discordWebhookUrl = message(
|
|
1509
2431
|
"settings.validation.webhookDiscord",
|
|
@@ -1547,6 +2469,453 @@ function getAdjustedFields(submitted, stored, previous) {
|
|
|
1547
2469
|
(key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
|
|
1548
2470
|
);
|
|
1549
2471
|
}
|
|
2472
|
+
const TABLE_MIN_WIDTH = 640;
|
|
2473
|
+
const keepActionKeys = (event) => {
|
|
2474
|
+
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2475
|
+
};
|
|
2476
|
+
const LockTarget = ({ lock }) => {
|
|
2477
|
+
const { t } = useSettingsTranslate();
|
|
2478
|
+
if (lock.kind === "ip") {
|
|
2479
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2480
|
+
designSystem.Typography,
|
|
2481
|
+
{
|
|
2482
|
+
variant: "omega",
|
|
2483
|
+
textColor: "neutral800",
|
|
2484
|
+
tag: "p",
|
|
2485
|
+
style: { overflowWrap: "anywhere" },
|
|
2486
|
+
children: lock.ip || t("settings.lockouts.ipHidden", "IP address not stored")
|
|
2487
|
+
}
|
|
2488
|
+
);
|
|
2489
|
+
}
|
|
2490
|
+
if (!lock.user) {
|
|
2491
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.lockouts.unknownAccount", "Account that does not exist") });
|
|
2492
|
+
}
|
|
2493
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, minWidth: 0, width: "100%", children: [
|
|
2494
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2495
|
+
designSystem.Typography,
|
|
2496
|
+
{
|
|
2497
|
+
variant: "omega",
|
|
2498
|
+
fontWeight: "semiBold",
|
|
2499
|
+
textColor: "neutral800",
|
|
2500
|
+
tag: "p",
|
|
2501
|
+
style: { overflowWrap: "anywhere" },
|
|
2502
|
+
children: lock.user.username || lock.user.email
|
|
2503
|
+
}
|
|
2504
|
+
),
|
|
2505
|
+
lock.user.email && lock.user.username ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2506
|
+
designSystem.Typography,
|
|
2507
|
+
{
|
|
2508
|
+
variant: "pi",
|
|
2509
|
+
textColor: "neutral600",
|
|
2510
|
+
tag: "p",
|
|
2511
|
+
style: { overflowWrap: "anywhere" },
|
|
2512
|
+
children: lock.user.email
|
|
2513
|
+
}
|
|
2514
|
+
) : null
|
|
2515
|
+
] });
|
|
2516
|
+
};
|
|
2517
|
+
const KindBadge = ({ kind }) => {
|
|
2518
|
+
const { t } = useSettingsTranslate();
|
|
2519
|
+
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") });
|
|
2520
|
+
};
|
|
2521
|
+
const lockName = (lock, t) => {
|
|
2522
|
+
if (lock.kind === "ip")
|
|
2523
|
+
return lock.ip || t("settings.lockouts.ipHidden", "IP address not stored");
|
|
2524
|
+
if (lock.user) return lock.user.username || lock.user.email;
|
|
2525
|
+
return t("settings.lockouts.unknownAccount", "Account that does not exist");
|
|
2526
|
+
};
|
|
2527
|
+
const LockedNowCard = () => {
|
|
2528
|
+
const { t } = useSettingsTranslate();
|
|
2529
|
+
const { get, post } = StrapiAdmin.useFetchClient();
|
|
2530
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
2531
|
+
const { formatDate } = index.useSessionFormatters();
|
|
2532
|
+
const {
|
|
2533
|
+
isLoading: permissionsLoading,
|
|
2534
|
+
allowedActions: { canUnlock }
|
|
2535
|
+
} = StrapiAdmin.useRBAC(index.pluginPermissions.lockoutsUnlock);
|
|
2536
|
+
const [widthRef, width] = dashboardModel.useElementWidth();
|
|
2537
|
+
const [locks, setLocks] = react.useState(null);
|
|
2538
|
+
const [error, setError] = react.useState(false);
|
|
2539
|
+
const [refreshing, setRefreshing] = react.useState(false);
|
|
2540
|
+
const refreshRef = react.useRef(null);
|
|
2541
|
+
const requestRef = react.useRef(0);
|
|
2542
|
+
const apply = react.useCallback(async (request, pending) => {
|
|
2543
|
+
try {
|
|
2544
|
+
const { data } = await pending;
|
|
2545
|
+
if (request !== requestRef.current) return;
|
|
2546
|
+
if (!Array.isArray(data?.data)) throw new Error("Invalid lock list");
|
|
2547
|
+
setLocks(sortLocks(data.data));
|
|
2548
|
+
setError(false);
|
|
2549
|
+
} catch (err) {
|
|
2550
|
+
if (index.isCancelledRequest(err) || request !== requestRef.current) return;
|
|
2551
|
+
index.logSafeAdminError("lockouts", err);
|
|
2552
|
+
setError(true);
|
|
2553
|
+
} finally {
|
|
2554
|
+
if (request === requestRef.current) setRefreshing(false);
|
|
2555
|
+
}
|
|
2556
|
+
}, []);
|
|
2557
|
+
const load = react.useCallback(() => {
|
|
2558
|
+
const request = ++requestRef.current;
|
|
2559
|
+
setRefreshing(true);
|
|
2560
|
+
return apply(request, get(`/${index.pluginId}/lockouts`));
|
|
2561
|
+
}, [apply, get]);
|
|
2562
|
+
react.useEffect(() => {
|
|
2563
|
+
apply(++requestRef.current, get(`/${index.pluginId}/lockouts`));
|
|
2564
|
+
}, [apply, get]);
|
|
2565
|
+
const unlock = async (lock) => {
|
|
2566
|
+
try {
|
|
2567
|
+
await post(`/${index.pluginId}/lockouts/unlock`, { id: lock.id });
|
|
2568
|
+
toggleNotification({
|
|
2569
|
+
type: "success",
|
|
2570
|
+
message: t("settings.lockouts.unlocked", "{name} was unlocked.", {
|
|
2571
|
+
name: lockName(lock, t)
|
|
2572
|
+
})
|
|
2573
|
+
});
|
|
2574
|
+
} catch (err) {
|
|
2575
|
+
if (err?.response?.status === 404) {
|
|
2576
|
+
toggleNotification({
|
|
2577
|
+
type: "info",
|
|
2578
|
+
message: t("settings.lockouts.alreadyEnded", "This lock had already ended.")
|
|
2579
|
+
});
|
|
2580
|
+
} else {
|
|
2581
|
+
index.logSafeAdminError("lockouts", err);
|
|
2582
|
+
toggleNotification({
|
|
2583
|
+
type: "danger",
|
|
2584
|
+
message: t("settings.lockouts.unlockFailed", "The lock could not be lifted.")
|
|
2585
|
+
});
|
|
2586
|
+
throw err;
|
|
2587
|
+
}
|
|
2588
|
+
} finally {
|
|
2589
|
+
await load();
|
|
2590
|
+
}
|
|
2591
|
+
};
|
|
2592
|
+
const showActions = !permissionsLoading && canUnlock;
|
|
2593
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH;
|
|
2594
|
+
const unlockAction = (lock) => showActions ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2595
|
+
index.ConfirmAction,
|
|
2596
|
+
{
|
|
2597
|
+
fallbackFocusRef: refreshRef,
|
|
2598
|
+
title: t("settings.lockouts.confirm.title", "Unlock {name}?", { name: lockName(lock, t) }),
|
|
2599
|
+
body: lock.kind === "ip" ? t(
|
|
2600
|
+
"settings.lockouts.confirm.bodyIp",
|
|
2601
|
+
"Sign-ins from this address are allowed again at once, and its failed attempts are reset. This is recorded in the security log."
|
|
2602
|
+
) : t(
|
|
2603
|
+
"settings.lockouts.confirm.bodyAccount",
|
|
2604
|
+
"Sign-ins to this account are allowed again at once, and its failed attempts are reset. This is recorded in the security log."
|
|
2605
|
+
),
|
|
2606
|
+
confirmLabel: t("settings.lockouts.confirm.action", "Unlock"),
|
|
2607
|
+
variant: "default",
|
|
2608
|
+
onConfirm: () => unlock(lock),
|
|
2609
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2610
|
+
designSystem.IconButton,
|
|
2611
|
+
{
|
|
2612
|
+
variant: "ghost",
|
|
2613
|
+
label: t("settings.lockouts.unlockLabel", "Unlock {name}", { name: lockName(lock, t) }),
|
|
2614
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {})
|
|
2615
|
+
}
|
|
2616
|
+
)
|
|
2617
|
+
},
|
|
2618
|
+
lock.id
|
|
2619
|
+
) : null;
|
|
2620
|
+
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" }) });
|
|
2621
|
+
let content;
|
|
2622
|
+
if (locks === null && !error) {
|
|
2623
|
+
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…") }) });
|
|
2624
|
+
} else if (error && locks === null) {
|
|
2625
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2626
|
+
index.PersistentAlert,
|
|
2627
|
+
{
|
|
2628
|
+
variant: "danger",
|
|
2629
|
+
closeLabel: t("common.close", "Close"),
|
|
2630
|
+
title: t("settings.lockouts.error", "Locks could not be loaded."),
|
|
2631
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: load, children: t("common.tryAgain", "Try again") }),
|
|
2632
|
+
children: t("settings.lockouts.errorBody", "Sign-ins are still checked; only this list is missing.")
|
|
2633
|
+
}
|
|
2634
|
+
);
|
|
2635
|
+
} else if (locks.length === 0) {
|
|
2636
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2637
|
+
designSystem.EmptyStateLayout,
|
|
2638
|
+
{
|
|
2639
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyPermissions, { width: "16rem", height: "8rem" }),
|
|
2640
|
+
content: t(
|
|
2641
|
+
"settings.lockouts.empty",
|
|
2642
|
+
"Nothing is locked. Locked IP addresses and accounts appear here until their lock ends."
|
|
2643
|
+
)
|
|
2644
|
+
}
|
|
2645
|
+
);
|
|
2646
|
+
} else if (asTable) {
|
|
2647
|
+
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: [
|
|
2648
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
2649
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.locked", "Locked") }) }),
|
|
2650
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.kind", "Type") }) }),
|
|
2651
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.failures", "Failed sign-ins") }) }),
|
|
2652
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("settings.lockouts.col.until", "Locked until") }) }),
|
|
2653
|
+
showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("settings.lockouts.col.actions", "Actions") }) }) : null
|
|
2654
|
+
] }) }),
|
|
2655
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: locks.map((lock) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-lock-row": lock.kind, children: [
|
|
2656
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsxRuntime.jsx(LockTarget, { lock }) }),
|
|
2657
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }) }),
|
|
2658
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
|
|
2659
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: ends(lock) }),
|
|
2660
|
+
showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
|
|
2661
|
+
] }, lock.id)) })
|
|
2662
|
+
] }) });
|
|
2663
|
+
} else {
|
|
2664
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-locks-list": "", children: locks.map((lock) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2665
|
+
designSystem.Box,
|
|
2666
|
+
{
|
|
2667
|
+
tag: "li",
|
|
2668
|
+
padding: 4,
|
|
2669
|
+
hasRadius: true,
|
|
2670
|
+
borderColor: "neutral150",
|
|
2671
|
+
"data-lock-row": lock.kind,
|
|
2672
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
|
|
2673
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, minWidth: 0, children: [
|
|
2674
|
+
/* @__PURE__ */ jsxRuntime.jsx(LockTarget, { lock }),
|
|
2675
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
2676
|
+
/* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }),
|
|
2677
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.lockouts.summary", "{count} failed, until {time}", {
|
|
2678
|
+
count: lock.failures,
|
|
2679
|
+
time: formatDate(lock.until, { hour: "2-digit", minute: "2-digit" })
|
|
2680
|
+
}) })
|
|
2681
|
+
] })
|
|
2682
|
+
] }),
|
|
2683
|
+
/* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
|
|
2684
|
+
] })
|
|
2685
|
+
},
|
|
2686
|
+
lock.id
|
|
2687
|
+
)) });
|
|
2688
|
+
}
|
|
2689
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2690
|
+
SectionCard.SectionCard,
|
|
2691
|
+
{
|
|
2692
|
+
id: "locked-now",
|
|
2693
|
+
title: t("settings.lockouts.title", "Locked now"),
|
|
2694
|
+
subtitle: t(
|
|
2695
|
+
"settings.lockouts.intro",
|
|
2696
|
+
"IP addresses and accounts that are refused right now after failed sign-ins."
|
|
2697
|
+
),
|
|
2698
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2699
|
+
designSystem.Button,
|
|
2700
|
+
{
|
|
2701
|
+
ref: refreshRef,
|
|
2702
|
+
variant: "tertiary",
|
|
2703
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
|
|
2704
|
+
onClick: load,
|
|
2705
|
+
loading: refreshing && locks !== null,
|
|
2706
|
+
children: t("settings.lockouts.refresh", "Refresh")
|
|
2707
|
+
}
|
|
2708
|
+
),
|
|
2709
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: widthRef, "aria-live": "polite", children: [
|
|
2710
|
+
error && locks !== null ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2711
|
+
index.PersistentAlert,
|
|
2712
|
+
{
|
|
2713
|
+
variant: "warning",
|
|
2714
|
+
closeLabel: t("common.close", "Close"),
|
|
2715
|
+
title: t("settings.lockouts.refreshErrorTitle", "Not refreshed"),
|
|
2716
|
+
children: t(
|
|
2717
|
+
"settings.lockouts.refreshError",
|
|
2718
|
+
"The list could not be refreshed. It shows the last known locks."
|
|
2719
|
+
)
|
|
2720
|
+
}
|
|
2721
|
+
) }) : null,
|
|
2722
|
+
content,
|
|
2723
|
+
locks && locks.length > 0 && !showActions && !permissionsLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
2724
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Lock, { "aria-hidden": true, fill: "neutral600" }),
|
|
2725
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
2726
|
+
"settings.lockouts.noUnlock",
|
|
2727
|
+
'Unlocking needs the "Unlock locked sign-ins" permission.'
|
|
2728
|
+
) })
|
|
2729
|
+
] }) }) : null,
|
|
2730
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: locks ? t(
|
|
2731
|
+
"settings.lockouts.count",
|
|
2732
|
+
"{count, plural, =0 {No locks} one {# lock} other {# locks}}",
|
|
2733
|
+
{
|
|
2734
|
+
count: locks.length
|
|
2735
|
+
}
|
|
2736
|
+
) : null })
|
|
2737
|
+
] })
|
|
2738
|
+
}
|
|
2739
|
+
);
|
|
2740
|
+
};
|
|
2741
|
+
const TrustedAddressesField = ({ form, disabled = false }) => {
|
|
2742
|
+
const { t, tError } = useSettingsTranslate();
|
|
2743
|
+
const { settings, handleChange, errors, draftVersion } = form;
|
|
2744
|
+
const [text, setText] = react.useState(
|
|
2745
|
+
() => formatTrustedAddressText(settings.lockoutTrustedAddresses)
|
|
2746
|
+
);
|
|
2747
|
+
const [version, setVersion] = react.useState(draftVersion);
|
|
2748
|
+
if (version !== draftVersion) {
|
|
2749
|
+
setVersion(draftVersion);
|
|
2750
|
+
setText(formatTrustedAddressText(settings.lockoutTrustedAddresses));
|
|
2751
|
+
}
|
|
2752
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2753
|
+
FormField,
|
|
2754
|
+
{
|
|
2755
|
+
id: "lockout-trusted-addresses",
|
|
2756
|
+
name: "lockoutTrustedAddresses",
|
|
2757
|
+
label: t("settings.config.failed.trusted.label", "Trusted addresses"),
|
|
2758
|
+
description: t(
|
|
2759
|
+
"settings.config.failed.trusted.hint",
|
|
2760
|
+
"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."
|
|
2761
|
+
),
|
|
2762
|
+
error: tError(errors.lockoutTrustedAddresses),
|
|
2763
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2764
|
+
designSystem.Textarea,
|
|
2765
|
+
{
|
|
2766
|
+
value: text,
|
|
2767
|
+
placeholder: "192.0.2.0/24",
|
|
2768
|
+
disabled,
|
|
2769
|
+
onChange: (event) => {
|
|
2770
|
+
setText(event.target.value);
|
|
2771
|
+
handleChange("lockoutTrustedAddresses", parseTrustedAddressText(event.target.value));
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
)
|
|
2775
|
+
}
|
|
2776
|
+
);
|
|
2777
|
+
};
|
|
2778
|
+
const ImpossibleTravelCard = ({ form }) => {
|
|
2779
|
+
const { t, tError } = useSettingsTranslate();
|
|
2780
|
+
const { settings, handleChange, errors } = form;
|
|
2781
|
+
const lookupOff = !settings.enableGeolocation;
|
|
2782
|
+
const enabled = settings.impossibleTravelEnabled === true;
|
|
2783
|
+
const locked = form.canChangeProtected === false;
|
|
2784
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2785
|
+
SectionCard.SectionCard,
|
|
2786
|
+
{
|
|
2787
|
+
id: "impossible-travel",
|
|
2788
|
+
title: t("settings.config.travel.title", "Impossible travel"),
|
|
2789
|
+
subtitle: t(
|
|
2790
|
+
"settings.config.travel.intro",
|
|
2791
|
+
"Flags a sign-in that is farther from the user's previous sign-in than anyone could travel in the time between."
|
|
2792
|
+
),
|
|
2793
|
+
children: [
|
|
2794
|
+
lookupOff ? /* @__PURE__ */ jsxRuntime.jsx(RequiresGeolocation, {}) : null,
|
|
2795
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
2796
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2797
|
+
SettingsToggleRow,
|
|
2798
|
+
{
|
|
2799
|
+
id: "impossible-travel-enabled",
|
|
2800
|
+
title: t("settings.config.travel.enable.label", "Detect impossible travel"),
|
|
2801
|
+
description: t(
|
|
2802
|
+
"settings.config.travel.enable.hint",
|
|
2803
|
+
"Needs a location database with cities (coordinates). While this is on, the location of each sign-in is stored rounded to about 11 km. VPNs and mobile networks can cause false alarms."
|
|
2804
|
+
),
|
|
2805
|
+
checked: enabled,
|
|
2806
|
+
disabled: locked || lookupOff && !enabled,
|
|
2807
|
+
onChange: (checked) => handleChange("impossibleTravelEnabled", checked)
|
|
2808
|
+
}
|
|
2809
|
+
),
|
|
2810
|
+
enabled ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-travel-action": "", children: [
|
|
2811
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2812
|
+
designSystem.Typography,
|
|
2813
|
+
{
|
|
2814
|
+
id: "impossible-travel-action-label",
|
|
2815
|
+
variant: "pi",
|
|
2816
|
+
fontWeight: "bold",
|
|
2817
|
+
tag: "div",
|
|
2818
|
+
textColor: "neutral800",
|
|
2819
|
+
children: t("settings.config.travel.action.label", "Then")
|
|
2820
|
+
}
|
|
2821
|
+
),
|
|
2822
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2823
|
+
designSystem.Radio.Group,
|
|
2824
|
+
{
|
|
2825
|
+
"aria-labelledby": "impossible-travel-action-label",
|
|
2826
|
+
value: settings.impossibleTravelAction || "alert",
|
|
2827
|
+
disabled: locked,
|
|
2828
|
+
onValueChange: (value) => handleChange("impossibleTravelAction", value),
|
|
2829
|
+
children: [
|
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "alert", children: t("settings.config.travel.action.alert", "Record it and alert") }),
|
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { value: "reauthenticate", children: t("settings.config.travel.action.reauthenticate", "Require a new sign-in") })
|
|
2832
|
+
]
|
|
2833
|
+
}
|
|
2834
|
+
),
|
|
2835
|
+
settings.impossibleTravelAction === "reauthenticate" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2836
|
+
designSystem.Alert,
|
|
2837
|
+
{
|
|
2838
|
+
variant: "warning",
|
|
2839
|
+
closeLabel: t("common.close", "Close"),
|
|
2840
|
+
title: t("settings.config.travel.reauth.title", "Every session of the user ends"),
|
|
2841
|
+
children: t(
|
|
2842
|
+
"settings.config.travel.reauth.body",
|
|
2843
|
+
"The flagged sign-in gets 401 with the code REAUTHENTICATION_REQUIRED and all sessions of the user end. Signing in again from the new place works."
|
|
2844
|
+
)
|
|
2845
|
+
}
|
|
2846
|
+
) : null,
|
|
2847
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
2848
|
+
"settings.config.travel.alerts",
|
|
2849
|
+
"The email to the user and the webhook event are chosen under Alerts."
|
|
2850
|
+
) })
|
|
2851
|
+
] }) : null,
|
|
2852
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2853
|
+
AdvancedSection,
|
|
2854
|
+
{
|
|
2855
|
+
hasError: fieldHasError(errors, "impossibleTravelSpeedKmh") || fieldHasError(errors, "impossibleTravelMinDistanceKm"),
|
|
2856
|
+
disabled: !enabled,
|
|
2857
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
|
|
2858
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2859
|
+
FormField,
|
|
2860
|
+
{
|
|
2861
|
+
id: "impossible-travel-speed",
|
|
2862
|
+
name: "impossibleTravelSpeedKmh",
|
|
2863
|
+
label: t("settings.config.travel.speed.label", "Faster than"),
|
|
2864
|
+
description: t(
|
|
2865
|
+
"settings.config.travel.speed.hint",
|
|
2866
|
+
"From 100 to 5000. A plane flies at about 900 km/h."
|
|
2867
|
+
),
|
|
2868
|
+
suffix: t("settings.config.travel.speed.suffix", "km/h"),
|
|
2869
|
+
error: tError(errors.impossibleTravelSpeedKmh),
|
|
2870
|
+
required: true,
|
|
2871
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2872
|
+
designSystem.NumberInput,
|
|
2873
|
+
{
|
|
2874
|
+
value: settings.impossibleTravelSpeedKmh,
|
|
2875
|
+
disabled: locked,
|
|
2876
|
+
onValueChange: (value) => handleChange("impossibleTravelSpeedKmh", value ?? ""),
|
|
2877
|
+
min: SIGNALS_RANGES.impossibleTravelSpeedKmh.min,
|
|
2878
|
+
max: SIGNALS_RANGES.impossibleTravelSpeedKmh.max,
|
|
2879
|
+
step: 50
|
|
2880
|
+
},
|
|
2881
|
+
form.draftVersion
|
|
2882
|
+
)
|
|
2883
|
+
}
|
|
2884
|
+
),
|
|
2885
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2886
|
+
FormField,
|
|
2887
|
+
{
|
|
2888
|
+
id: "impossible-travel-distance",
|
|
2889
|
+
name: "impossibleTravelMinDistanceKm",
|
|
2890
|
+
label: t("settings.config.travel.distance.label", "Over at least"),
|
|
2891
|
+
description: t(
|
|
2892
|
+
"settings.config.travel.distance.hint",
|
|
2893
|
+
"Shorter distances are never flagged (location data is not precise)."
|
|
2894
|
+
),
|
|
2895
|
+
suffix: t("settings.config.travel.distance.suffix", "km"),
|
|
2896
|
+
error: tError(errors.impossibleTravelMinDistanceKm),
|
|
2897
|
+
required: true,
|
|
2898
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2899
|
+
designSystem.NumberInput,
|
|
2900
|
+
{
|
|
2901
|
+
value: settings.impossibleTravelMinDistanceKm,
|
|
2902
|
+
disabled: locked,
|
|
2903
|
+
onValueChange: (value) => handleChange("impossibleTravelMinDistanceKm", value ?? ""),
|
|
2904
|
+
min: SIGNALS_RANGES.impossibleTravelMinDistanceKm.min,
|
|
2905
|
+
max: SIGNALS_RANGES.impossibleTravelMinDistanceKm.max,
|
|
2906
|
+
step: 50
|
|
2907
|
+
},
|
|
2908
|
+
form.draftVersion
|
|
2909
|
+
)
|
|
2910
|
+
}
|
|
2911
|
+
)
|
|
2912
|
+
] })
|
|
2913
|
+
}
|
|
2914
|
+
)
|
|
2915
|
+
]
|
|
2916
|
+
}
|
|
2917
|
+
);
|
|
2918
|
+
};
|
|
1550
2919
|
const COUNTRIES = [
|
|
1551
2920
|
{ code: "DE", name: "Germany", flag: "🇩🇪" },
|
|
1552
2921
|
{ code: "AT", name: "Austria", flag: "🇦🇹" },
|
|
@@ -1942,20 +3311,59 @@ const CountryListEditor = ({ settings, handleChange }) => {
|
|
|
1942
3311
|
] })
|
|
1943
3312
|
] });
|
|
1944
3313
|
};
|
|
3314
|
+
const describeLockout = (t, { ip, account, window: window2, duration }) => {
|
|
3315
|
+
if (ip === 0 && account === 0) {
|
|
3316
|
+
return t(
|
|
3317
|
+
"settings.config.failed.lockout.offBoth",
|
|
3318
|
+
"The lockout is off. Failed sign-ins are not limited."
|
|
3319
|
+
);
|
|
3320
|
+
}
|
|
3321
|
+
const parts = [];
|
|
3322
|
+
if (ip > 0) {
|
|
3323
|
+
parts.push(
|
|
3324
|
+
t(
|
|
3325
|
+
"settings.config.failed.preview.ip",
|
|
3326
|
+
"{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}}.",
|
|
3327
|
+
{ count: ip, window: window2, duration }
|
|
3328
|
+
)
|
|
3329
|
+
);
|
|
3330
|
+
}
|
|
3331
|
+
if (account > 0) {
|
|
3332
|
+
parts.push(
|
|
3333
|
+
t(
|
|
3334
|
+
"settings.config.failed.preview.account",
|
|
3335
|
+
"{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.",
|
|
3336
|
+
{ count: account, window: window2, duration }
|
|
3337
|
+
)
|
|
3338
|
+
);
|
|
3339
|
+
}
|
|
3340
|
+
return parts.join(" ");
|
|
3341
|
+
};
|
|
1945
3342
|
const LoginProtectionTab = ({ form }) => {
|
|
1946
3343
|
const { t, tError } = useSettingsTranslate();
|
|
1947
3344
|
const { settings, handleChange, errors } = form;
|
|
1948
3345
|
const maxFailedError = tError(errors.maxFailedLogins);
|
|
1949
3346
|
const maxFailedValue = Number(settings.maxFailedLogins);
|
|
3347
|
+
const accountValue = Number(settings.maxFailedLoginsPerAccount) || 0;
|
|
3348
|
+
const accountByRole = (settings.roleRules || []).some(
|
|
3349
|
+
(rule) => rule.maxFailedLoginsPerAccount !== null && rule.maxFailedLoginsPerAccount !== void 0
|
|
3350
|
+
);
|
|
3351
|
+
const lockoutPreview = describeLockout(t, {
|
|
3352
|
+
ip: maxFailedValue,
|
|
3353
|
+
account: accountValue,
|
|
3354
|
+
window: Number(settings.lockoutWindowMinutes) || 15,
|
|
3355
|
+
duration: Number(settings.lockoutDurationMinutes) || 15
|
|
3356
|
+
});
|
|
1950
3357
|
const lookupOff = !settings.enableGeolocation;
|
|
1951
3358
|
const locked = form.canChangeProtected === false;
|
|
1952
|
-
const
|
|
1953
|
-
const
|
|
3359
|
+
const policyLocked = locked;
|
|
3360
|
+
const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
|
|
3361
|
+
const reject = dashboardModel.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
|
|
1954
3362
|
const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
|
|
1955
3363
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1956
3364
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
1957
3365
|
"settings.config.loginProtection.intro",
|
|
1958
|
-
"These rules check new sign-ins before they succeed. Existing sessions are not affected
|
|
3366
|
+
"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
3367
|
) }),
|
|
1960
3368
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1961
3369
|
SectionCard.SectionCard,
|
|
@@ -1963,63 +3371,180 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
1963
3371
|
title: t("settings.config.failed.title", "Failed sign-ins"),
|
|
1964
3372
|
subtitle: t(
|
|
1965
3373
|
"settings.config.failed.intro",
|
|
1966
|
-
"Slows down password guessing
|
|
3374
|
+
"Slows down password guessing. Counts are shared by every server process."
|
|
1967
3375
|
),
|
|
1968
3376
|
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
|
-
|
|
3377
|
+
policyLocked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
3378
|
+
/* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
|
|
3379
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3380
|
+
FormField,
|
|
3381
|
+
{
|
|
3382
|
+
id: "max-failed-logins",
|
|
3383
|
+
name: "maxFailedLogins",
|
|
3384
|
+
label: t("settings.config.failed.lockout.label", "Lock an IP address after"),
|
|
3385
|
+
description: t(
|
|
3386
|
+
"settings.config.failed.lockout.hint",
|
|
3387
|
+
"A whole number from 0 to 100. 0 turns the IP lockout off."
|
|
3388
|
+
),
|
|
3389
|
+
suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
|
|
3390
|
+
error: maxFailedError,
|
|
3391
|
+
required: true,
|
|
3392
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3393
|
+
designSystem.NumberInput,
|
|
3394
|
+
{
|
|
3395
|
+
value: settings.maxFailedLogins,
|
|
3396
|
+
onValueChange: (value) => handleChange("maxFailedLogins", value),
|
|
3397
|
+
min: MAX_FAILED_LOGINS_RANGE.min,
|
|
3398
|
+
max: MAX_FAILED_LOGINS_RANGE.max,
|
|
3399
|
+
step: 1
|
|
3400
|
+
},
|
|
3401
|
+
form.draftVersion
|
|
3402
|
+
)
|
|
3403
|
+
}
|
|
3404
|
+
),
|
|
3405
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3406
|
+
FormField,
|
|
3407
|
+
{
|
|
3408
|
+
id: "max-failed-logins-account",
|
|
3409
|
+
name: "maxFailedLoginsPerAccount",
|
|
3410
|
+
label: t("settings.config.failed.account.label", "Lock an account after"),
|
|
3411
|
+
description: t(
|
|
3412
|
+
"settings.config.failed.account.hint",
|
|
3413
|
+
"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."
|
|
3414
|
+
),
|
|
3415
|
+
suffix: t("settings.config.failed.lockout.suffix", "failed sign-ins"),
|
|
3416
|
+
error: tError(errors.maxFailedLoginsPerAccount),
|
|
3417
|
+
required: true,
|
|
3418
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3419
|
+
designSystem.NumberInput,
|
|
3420
|
+
{
|
|
3421
|
+
value: settings.maxFailedLoginsPerAccount,
|
|
3422
|
+
onValueChange: (value) => handleChange("maxFailedLoginsPerAccount", value ?? ""),
|
|
3423
|
+
disabled: policyLocked,
|
|
3424
|
+
min: POLICY_RANGES.maxFailedLoginsPerAccount.min,
|
|
3425
|
+
max: POLICY_RANGES.maxFailedLoginsPerAccount.max,
|
|
3426
|
+
step: 1
|
|
3427
|
+
},
|
|
3428
|
+
form.draftVersion
|
|
3429
|
+
)
|
|
3430
|
+
}
|
|
3431
|
+
),
|
|
3432
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3433
|
+
FormField,
|
|
3434
|
+
{
|
|
3435
|
+
id: "lockout-window",
|
|
3436
|
+
name: "lockoutWindowMinutes",
|
|
3437
|
+
label: t("settings.config.failed.window.label", "Count failed sign-ins within"),
|
|
3438
|
+
description: t(
|
|
3439
|
+
"settings.config.failed.window.hint",
|
|
3440
|
+
"Failures older than this no longer count."
|
|
3441
|
+
),
|
|
3442
|
+
suffix: t("settings.config.failed.minutes.suffix", "minutes"),
|
|
3443
|
+
error: tError(errors.lockoutWindowMinutes),
|
|
3444
|
+
required: true,
|
|
3445
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3446
|
+
designSystem.NumberInput,
|
|
3447
|
+
{
|
|
3448
|
+
value: settings.lockoutWindowMinutes,
|
|
3449
|
+
onValueChange: (value) => handleChange("lockoutWindowMinutes", value ?? ""),
|
|
3450
|
+
disabled: policyLocked,
|
|
3451
|
+
min: POLICY_RANGES.lockoutWindowMinutes.min,
|
|
3452
|
+
max: POLICY_RANGES.lockoutWindowMinutes.max,
|
|
3453
|
+
step: 1
|
|
3454
|
+
},
|
|
3455
|
+
form.draftVersion
|
|
3456
|
+
)
|
|
3457
|
+
}
|
|
3458
|
+
),
|
|
3459
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3460
|
+
FormField,
|
|
3461
|
+
{
|
|
3462
|
+
id: "lockout-duration",
|
|
3463
|
+
name: "lockoutDurationMinutes",
|
|
3464
|
+
label: t("settings.config.failed.duration.label", "Lock for"),
|
|
3465
|
+
description: t(
|
|
3466
|
+
"settings.config.failed.duration.hint",
|
|
3467
|
+
"A locked IP address or account is refused for this long. Admins can unlock it earlier."
|
|
3468
|
+
),
|
|
3469
|
+
suffix: t("settings.config.failed.minutes.suffix", "minutes"),
|
|
3470
|
+
error: tError(errors.lockoutDurationMinutes),
|
|
3471
|
+
required: true,
|
|
3472
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3473
|
+
designSystem.NumberInput,
|
|
3474
|
+
{
|
|
3475
|
+
value: settings.lockoutDurationMinutes,
|
|
3476
|
+
onValueChange: (value) => handleChange("lockoutDurationMinutes", value ?? ""),
|
|
3477
|
+
disabled: policyLocked,
|
|
3478
|
+
min: POLICY_RANGES.lockoutDurationMinutes.min,
|
|
3479
|
+
max: POLICY_RANGES.lockoutDurationMinutes.max,
|
|
3480
|
+
step: 1
|
|
3481
|
+
},
|
|
3482
|
+
form.draftVersion
|
|
3483
|
+
)
|
|
3484
|
+
}
|
|
3485
|
+
)
|
|
3486
|
+
] }),
|
|
3487
|
+
!maxFailedError && !errors.maxFailedLoginsPerAccount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1996
3488
|
designSystem.Box,
|
|
1997
3489
|
{
|
|
1998
3490
|
padding: 3,
|
|
1999
|
-
background: maxFailedValue === 0 ? "warning100" : "neutral100",
|
|
3491
|
+
background: maxFailedValue === 0 && accountValue === 0 ? "warning100" : "neutral100",
|
|
2000
3492
|
hasRadius: true,
|
|
2001
3493
|
"aria-live": "polite",
|
|
2002
3494
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2003
3495
|
index.ReadableParagraphs,
|
|
2004
3496
|
{
|
|
2005
3497
|
variant: "pi",
|
|
2006
|
-
textColor: maxFailedValue === 0 ? "warning700" : "neutral700",
|
|
3498
|
+
textColor: maxFailedValue === 0 && accountValue === 0 ? "warning700" : "neutral700",
|
|
2007
3499
|
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
|
-
)
|
|
3500
|
+
text: lockoutPreview
|
|
2016
3501
|
}
|
|
2017
3502
|
)
|
|
2018
3503
|
}
|
|
2019
|
-
) : null
|
|
3504
|
+
) : null,
|
|
3505
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3506
|
+
SettingsToggleRow,
|
|
3507
|
+
{
|
|
3508
|
+
id: "lockout-notify-user",
|
|
3509
|
+
title: t(
|
|
3510
|
+
"settings.config.failed.notify.label",
|
|
3511
|
+
"Email the user when their account is locked"
|
|
3512
|
+
),
|
|
3513
|
+
description: t(
|
|
3514
|
+
"settings.config.failed.notify.hint",
|
|
3515
|
+
"Sent through Strapi's email plugin (and Magic Mail when installed). The text is in Alerts, Email templates."
|
|
3516
|
+
),
|
|
3517
|
+
checked: !!settings.lockoutNotifyUser,
|
|
3518
|
+
disabled: policyLocked || accountValue === 0 && !accountByRole,
|
|
3519
|
+
onChange: (checked) => handleChange("lockoutNotifyUser", checked)
|
|
3520
|
+
}
|
|
3521
|
+
),
|
|
3522
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3523
|
+
SettingsToggleRow,
|
|
3524
|
+
{
|
|
3525
|
+
id: "record-user-sign-in-events",
|
|
3526
|
+
title: t("settings.config.failed.record.label", "Record failed and refused sign-ins"),
|
|
3527
|
+
description: t(
|
|
3528
|
+
"settings.config.failed.record.hint",
|
|
3529
|
+
"Writes failed sign-ins, refused sign-ins and locks to the security log, with the IP address as the log stores it."
|
|
3530
|
+
),
|
|
3531
|
+
checked: settings.recordUserSignInEvents !== false,
|
|
3532
|
+
disabled: policyLocked,
|
|
3533
|
+
onChange: (checked) => handleChange("recordUserSignInEvents", checked)
|
|
3534
|
+
}
|
|
3535
|
+
),
|
|
3536
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3537
|
+
AdvancedSection,
|
|
3538
|
+
{
|
|
3539
|
+
label: t("settings.config.failed.trusted.section", "Trusted addresses"),
|
|
3540
|
+
hasError: fieldHasError(errors, "lockoutTrustedAddresses"),
|
|
3541
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(TrustedAddressesField, { form, disabled: policyLocked })
|
|
3542
|
+
}
|
|
3543
|
+
)
|
|
2020
3544
|
]
|
|
2021
3545
|
}
|
|
2022
3546
|
),
|
|
3547
|
+
/* @__PURE__ */ jsxRuntime.jsx(LockedNowCard, {}),
|
|
2023
3548
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2024
3549
|
SectionCard.SectionCard,
|
|
2025
3550
|
{
|
|
@@ -2120,6 +3645,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
2120
3645
|
]
|
|
2121
3646
|
}
|
|
2122
3647
|
),
|
|
3648
|
+
/* @__PURE__ */ jsxRuntime.jsx(ImpossibleTravelCard, { form }),
|
|
2123
3649
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2124
3650
|
SectionCard.SectionCard,
|
|
2125
3651
|
{
|
|
@@ -2153,7 +3679,18 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
2153
3679
|
{
|
|
2154
3680
|
id: "lockout",
|
|
2155
3681
|
term: t("settings.config.refused.lockout.response", "429 with Retry-After"),
|
|
2156
|
-
description: t(
|
|
3682
|
+
description: t(
|
|
3683
|
+
"settings.config.refused.lockout.cause",
|
|
3684
|
+
"Locked IP address or account after failed sign-ins"
|
|
3685
|
+
)
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
id: "limit",
|
|
3689
|
+
term: t("settings.config.refused.limit.response", "403 SESSION_LIMIT_REACHED"),
|
|
3690
|
+
description: t(
|
|
3691
|
+
"settings.config.refused.limit.cause",
|
|
3692
|
+
'Session limit reached with "Refuse the new sign-in"'
|
|
3693
|
+
)
|
|
2157
3694
|
},
|
|
2158
3695
|
{
|
|
2159
3696
|
id: "rule",
|
|
@@ -2177,7 +3714,10 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
2177
3714
|
]
|
|
2178
3715
|
}
|
|
2179
3716
|
),
|
|
2180
|
-
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
3717
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
3718
|
+
"settings.config.refused.log",
|
|
3719
|
+
'Refused sign-ins are written to the security log while "Record failed and refused sign-ins" is on.'
|
|
3720
|
+
) })
|
|
2181
3721
|
] })
|
|
2182
3722
|
] });
|
|
2183
3723
|
};
|
|
@@ -2530,7 +4070,7 @@ const RiskDataCard = ({ form }) => {
|
|
|
2530
4070
|
const { t } = useSettingsTranslate();
|
|
2531
4071
|
const { settings, geoIp } = form;
|
|
2532
4072
|
const lookupOff = !settings.enableGeolocation;
|
|
2533
|
-
const risk =
|
|
4073
|
+
const risk = dashboardModel.getRiskAvailability(geoIp.status);
|
|
2534
4074
|
const sourceLabels = {
|
|
2535
4075
|
"anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
|
|
2536
4076
|
"asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
|
|
@@ -2597,8 +4137,8 @@ const RiskDataCard = ({ form }) => {
|
|
|
2597
4137
|
const LocationDataTab = ({ form }) => {
|
|
2598
4138
|
const { t } = useSettingsTranslate();
|
|
2599
4139
|
const { settings, handleChange } = form;
|
|
2600
|
-
const risk =
|
|
2601
|
-
const scoring =
|
|
4140
|
+
const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
|
|
4141
|
+
const scoring = dashboardModel.riskDependentControl(settings.enableSecurityScoring, risk.state);
|
|
2602
4142
|
const locked = form.canChangeProtected === false;
|
|
2603
4143
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
2604
4144
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
@@ -2729,7 +4269,10 @@ const PreviewFrame = styled__default.default.iframe`
|
|
|
2729
4269
|
const TEMPLATE_TAB_LABELS = {
|
|
2730
4270
|
suspiciousLogin: ["settings.email.templates.tab.suspicious", "Suspicious sign-in"],
|
|
2731
4271
|
newLocation: ["settings.email.templates.tab.newLocation", "New country"],
|
|
2732
|
-
vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"]
|
|
4272
|
+
vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"],
|
|
4273
|
+
accountLocked: ["settings.email.templates.tab.accountLocked", "Account locked"],
|
|
4274
|
+
newDevice: ["settings.email.templates.tab.newDevice", "New device"],
|
|
4275
|
+
impossibleTravel: ["settings.email.templates.tab.impossibleTravel", "Impossible travel"]
|
|
2733
4276
|
};
|
|
2734
4277
|
const BlockLabel = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", tag: "div", textColor: "neutral800", children });
|
|
2735
4278
|
const TemplateEditor = ({ templateKey, template, templates, handleChange, copyValue, errors }) => {
|
|
@@ -3077,6 +4620,299 @@ const WebhookUrlField = ({
|
|
|
3077
4620
|
stored ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", size: "S", onClick: cancel, children: t("settings.webhooks.cancelReplace", "Keep the saved URL") }) }) : null
|
|
3078
4621
|
] }) });
|
|
3079
4622
|
};
|
|
4623
|
+
const WriteOnlyField = ({
|
|
4624
|
+
field,
|
|
4625
|
+
saved,
|
|
4626
|
+
form,
|
|
4627
|
+
label,
|
|
4628
|
+
hint,
|
|
4629
|
+
type,
|
|
4630
|
+
placeholder,
|
|
4631
|
+
savedHint = null,
|
|
4632
|
+
disabled = false,
|
|
4633
|
+
extra
|
|
4634
|
+
}) => {
|
|
4635
|
+
const { t, tError } = useSettingsTranslate();
|
|
4636
|
+
const { settings, handleChange, errors } = form;
|
|
4637
|
+
const draft = settings[field];
|
|
4638
|
+
const [editing, setEditing] = react.useState(false);
|
|
4639
|
+
const removing = draft === "";
|
|
4640
|
+
const showInput = editing || !saved || typeof draft === "string" && draft !== "";
|
|
4641
|
+
if (!showInput) {
|
|
4642
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormField, { id: `generic-${field}`, name: field, label, description: hint, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
|
|
4643
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: removing ? "danger600" : "neutral800", children: removing ? t("settings.signedWebhook.removed", "Removed when you save.") : t("settings.signedWebhook.saved", "Saved. It is never shown again.") }),
|
|
4644
|
+
savedHint && !removing ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: savedHint }) : null,
|
|
4645
|
+
!removing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4646
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4647
|
+
designSystem.Button,
|
|
4648
|
+
{
|
|
4649
|
+
variant: "tertiary",
|
|
4650
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}),
|
|
4651
|
+
disabled,
|
|
4652
|
+
onClick: () => setEditing(true),
|
|
4653
|
+
children: t("settings.signedWebhook.replace", "Replace")
|
|
4654
|
+
}
|
|
4655
|
+
),
|
|
4656
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4657
|
+
designSystem.Button,
|
|
4658
|
+
{
|
|
4659
|
+
variant: "danger-light",
|
|
4660
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
|
|
4661
|
+
disabled,
|
|
4662
|
+
onClick: () => handleChange(field, ""),
|
|
4663
|
+
children: t("settings.signedWebhook.remove", "Remove")
|
|
4664
|
+
}
|
|
4665
|
+
)
|
|
4666
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
4667
|
+
designSystem.Button,
|
|
4668
|
+
{
|
|
4669
|
+
variant: "tertiary",
|
|
4670
|
+
disabled,
|
|
4671
|
+
onClick: () => handleChange(field, void 0),
|
|
4672
|
+
children: t("settings.signedWebhook.keep", "Keep it")
|
|
4673
|
+
}
|
|
4674
|
+
)
|
|
4675
|
+
] }) });
|
|
4676
|
+
}
|
|
4677
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4678
|
+
FormField,
|
|
4679
|
+
{
|
|
4680
|
+
id: `generic-${field}`,
|
|
4681
|
+
name: field,
|
|
4682
|
+
label,
|
|
4683
|
+
description: hint,
|
|
4684
|
+
error: tError(errors[field]),
|
|
4685
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
4686
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4687
|
+
designSystem.TextInput,
|
|
4688
|
+
{
|
|
4689
|
+
type,
|
|
4690
|
+
value: typeof draft === "string" ? draft : "",
|
|
4691
|
+
placeholder,
|
|
4692
|
+
disabled,
|
|
4693
|
+
autoComplete: "off",
|
|
4694
|
+
spellCheck: false,
|
|
4695
|
+
onChange: (event) => handleChange(field, event.target.value || void 0)
|
|
4696
|
+
}
|
|
4697
|
+
),
|
|
4698
|
+
extra || saved ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
4699
|
+
extra,
|
|
4700
|
+
saved ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4701
|
+
designSystem.Button,
|
|
4702
|
+
{
|
|
4703
|
+
variant: "tertiary",
|
|
4704
|
+
onClick: () => {
|
|
4705
|
+
handleChange(field, void 0);
|
|
4706
|
+
setEditing(false);
|
|
4707
|
+
},
|
|
4708
|
+
children: t("settings.signedWebhook.keepSaved", "Keep the saved value")
|
|
4709
|
+
}
|
|
4710
|
+
) : null
|
|
4711
|
+
] }) : null
|
|
4712
|
+
] })
|
|
4713
|
+
}
|
|
4714
|
+
);
|
|
4715
|
+
};
|
|
4716
|
+
const SignedWebhookCard = ({ form }) => {
|
|
4717
|
+
const { t } = useSettingsTranslate();
|
|
4718
|
+
const { post } = StrapiAdmin.useFetchClient();
|
|
4719
|
+
const { settings, handleChange } = form;
|
|
4720
|
+
const [testing, setTesting] = react.useState(false);
|
|
4721
|
+
const [result, setResult] = react.useState(null);
|
|
4722
|
+
const locked = form.canChangeProtected === false;
|
|
4723
|
+
const pendingWriteOnly = settings.genericWebhookUrl !== void 0 || settings.genericWebhookSecret !== void 0;
|
|
4724
|
+
const sendTest = async () => {
|
|
4725
|
+
setTesting(true);
|
|
4726
|
+
setResult(null);
|
|
4727
|
+
try {
|
|
4728
|
+
const { data } = await post(`/${index.pluginId}/webhook/test`, {});
|
|
4729
|
+
setResult(describeWebhookTest(data?.data));
|
|
4730
|
+
} catch (err) {
|
|
4731
|
+
index.logSafeAdminError("webhook-test", err);
|
|
4732
|
+
setResult({
|
|
4733
|
+
messageId: "settings.signedWebhook.test.failed",
|
|
4734
|
+
defaultMessage: "The test could not be started.",
|
|
4735
|
+
tone: "danger"
|
|
4736
|
+
});
|
|
4737
|
+
} finally {
|
|
4738
|
+
setTesting(false);
|
|
4739
|
+
}
|
|
4740
|
+
};
|
|
4741
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4742
|
+
SectionCard.SectionCard,
|
|
4743
|
+
{
|
|
4744
|
+
id: "signed-webhook",
|
|
4745
|
+
title: t("settings.signedWebhook.title", "Signed webhook"),
|
|
4746
|
+
subtitle: t(
|
|
4747
|
+
"settings.signedWebhook.intro",
|
|
4748
|
+
"Sends the selected events as signed JSON to your own endpoint, for example a SIEM. Only https; private and local addresses are refused, redirects are not followed."
|
|
4749
|
+
),
|
|
4750
|
+
children: [
|
|
4751
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4752
|
+
SettingsToggleRow,
|
|
4753
|
+
{
|
|
4754
|
+
id: "generic-webhook-enabled",
|
|
4755
|
+
title: t("settings.signedWebhook.enable.label", "Send to the signed webhook"),
|
|
4756
|
+
description: t(
|
|
4757
|
+
"settings.signedWebhook.enable.hint",
|
|
4758
|
+
"Failed deliveries are retried twice (after 2 and 10 seconds). Data sent: user documentId, IP as the security log stores it, browser, country and city, and the event details. No email addresses."
|
|
4759
|
+
),
|
|
4760
|
+
checked: settings.genericWebhookEnabled === true,
|
|
4761
|
+
disabled: locked,
|
|
4762
|
+
onChange: (checked) => handleChange("genericWebhookEnabled", checked)
|
|
4763
|
+
}
|
|
4764
|
+
),
|
|
4765
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
4766
|
+
/* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
|
|
4767
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4768
|
+
WriteOnlyField,
|
|
4769
|
+
{
|
|
4770
|
+
field: "genericWebhookUrl",
|
|
4771
|
+
saved: settings.hasGenericWebhook === true,
|
|
4772
|
+
savedHint: settings.genericWebhookHint,
|
|
4773
|
+
disabled: locked,
|
|
4774
|
+
form,
|
|
4775
|
+
type: "url",
|
|
4776
|
+
label: t("settings.signedWebhook.url.label", "Webhook URL"),
|
|
4777
|
+
hint: t(
|
|
4778
|
+
"settings.signedWebhook.url.hint",
|
|
4779
|
+
"https only. Treat it like a password: it may contain a token."
|
|
4780
|
+
),
|
|
4781
|
+
placeholder: "https://hooks.example.com/sessions"
|
|
4782
|
+
}
|
|
4783
|
+
),
|
|
4784
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4785
|
+
WriteOnlyField,
|
|
4786
|
+
{
|
|
4787
|
+
field: "genericWebhookSecret",
|
|
4788
|
+
saved: settings.hasGenericWebhookSecret === true,
|
|
4789
|
+
disabled: locked,
|
|
4790
|
+
form,
|
|
4791
|
+
type: "text",
|
|
4792
|
+
label: t("settings.signedWebhook.secret.label", "Signing secret"),
|
|
4793
|
+
hint: t(
|
|
4794
|
+
"settings.signedWebhook.secret.hint",
|
|
4795
|
+
"Your endpoint uses it to verify the signature. Copy it before you save: it is never shown again."
|
|
4796
|
+
),
|
|
4797
|
+
extra: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4798
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4799
|
+
designSystem.Button,
|
|
4800
|
+
{
|
|
4801
|
+
variant: "secondary",
|
|
4802
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {}),
|
|
4803
|
+
disabled: locked,
|
|
4804
|
+
onClick: () => handleChange("genericWebhookSecret", generateWebhookSecret()),
|
|
4805
|
+
children: t("settings.signedWebhook.generate", "Generate")
|
|
4806
|
+
}
|
|
4807
|
+
),
|
|
4808
|
+
typeof settings.genericWebhookSecret === "string" && settings.genericWebhookSecret ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4809
|
+
designSystem.Button,
|
|
4810
|
+
{
|
|
4811
|
+
variant: "tertiary",
|
|
4812
|
+
onClick: () => form.copyValue(
|
|
4813
|
+
settings.genericWebhookSecret,
|
|
4814
|
+
t("settings.signedWebhook.copied", "Secret copied."),
|
|
4815
|
+
"webhook-secret"
|
|
4816
|
+
),
|
|
4817
|
+
children: t("settings.signedWebhook.copy", "Copy")
|
|
4818
|
+
}
|
|
4819
|
+
) : null
|
|
4820
|
+
] })
|
|
4821
|
+
}
|
|
4822
|
+
)
|
|
4823
|
+
] }),
|
|
4824
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
4825
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4826
|
+
designSystem.Button,
|
|
4827
|
+
{
|
|
4828
|
+
variant: "secondary",
|
|
4829
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
|
|
4830
|
+
loading: testing,
|
|
4831
|
+
disabled: locked || pendingWriteOnly || !settings.hasGenericWebhook,
|
|
4832
|
+
onClick: sendTest,
|
|
4833
|
+
children: t("settings.signedWebhook.test.action", "Send test")
|
|
4834
|
+
}
|
|
4835
|
+
),
|
|
4836
|
+
pendingWriteOnly ? /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
4837
|
+
"settings.signedWebhook.test.saveFirst",
|
|
4838
|
+
"Save first: the test uses the saved URL and secret."
|
|
4839
|
+
) }) : null,
|
|
4840
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { "aria-live": "polite", "data-webhook-test-result": "", children: result ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4841
|
+
designSystem.Typography,
|
|
4842
|
+
{
|
|
4843
|
+
variant: "pi",
|
|
4844
|
+
textColor: result.tone === "success" ? "success600" : "danger600",
|
|
4845
|
+
children: t(result.messageId, result.defaultMessage, result.values)
|
|
4846
|
+
}
|
|
4847
|
+
) : null })
|
|
4848
|
+
] })
|
|
4849
|
+
]
|
|
4850
|
+
}
|
|
4851
|
+
);
|
|
4852
|
+
};
|
|
4853
|
+
const EventGrid = styled__default.default.div`
|
|
4854
|
+
container-type: inline-size;
|
|
4855
|
+
min-width: 0;
|
|
4856
|
+
|
|
4857
|
+
& > ul {
|
|
4858
|
+
display: grid;
|
|
4859
|
+
grid-template-columns: minmax(0, 1fr);
|
|
4860
|
+
gap: ${({ theme }) => theme.spaces[3]};
|
|
4861
|
+
align-items: center;
|
|
4862
|
+
margin: 0;
|
|
4863
|
+
padding: 0;
|
|
4864
|
+
list-style: none;
|
|
4865
|
+
}
|
|
4866
|
+
|
|
4867
|
+
/* Every item starts on the row line (an inherited li + li margin
|
|
4868
|
+
offset the second column). */
|
|
4869
|
+
& > ul > li {
|
|
4870
|
+
margin: 0;
|
|
4871
|
+
}
|
|
4872
|
+
|
|
4873
|
+
@container (min-width: 520px) {
|
|
4874
|
+
& > ul {
|
|
4875
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
`;
|
|
4879
|
+
const WebhookEventsCard = ({ form }) => {
|
|
4880
|
+
const { t } = useSettingsTranslate();
|
|
4881
|
+
const { settings, handleChange } = form;
|
|
4882
|
+
const locked = form.canChangeProtected === false;
|
|
4883
|
+
const selected = Array.isArray(settings.webhookEvents) ? settings.webhookEvents : [];
|
|
4884
|
+
const toggle = (event, checked) => {
|
|
4885
|
+
const next = checked ? [.../* @__PURE__ */ new Set([...selected, event])] : selected.filter((value) => value !== event);
|
|
4886
|
+
handleChange(
|
|
4887
|
+
"webhookEvents",
|
|
4888
|
+
WEBHOOK_EVENT_OPTIONS.map(([value]) => value).filter((value) => next.includes(value))
|
|
4889
|
+
);
|
|
4890
|
+
};
|
|
4891
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4892
|
+
SectionCard.SectionCard,
|
|
4893
|
+
{
|
|
4894
|
+
id: "webhook-events",
|
|
4895
|
+
title: t("settings.webhookEvents.title", "Events to send"),
|
|
4896
|
+
subtitle: t(
|
|
4897
|
+
"settings.webhookEvents.intro",
|
|
4898
|
+
"Applies to Discord, Slack and the signed webhook. Every successful sign-in is usually too much; choose the events your team acts on."
|
|
4899
|
+
),
|
|
4900
|
+
children: [
|
|
4901
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
4902
|
+
/* @__PURE__ */ jsxRuntime.jsx(EventGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": t("settings.webhookEvents.title", "Events to send"), children: WEBHOOK_EVENT_OPTIONS.map(([event, id, label]) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { alignItems: "center", minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4903
|
+
designSystem.Checkbox,
|
|
4904
|
+
{
|
|
4905
|
+
checked: selected.includes(event),
|
|
4906
|
+
disabled: locked,
|
|
4907
|
+
onCheckedChange: (checked) => toggle(event, checked === true),
|
|
4908
|
+
"data-webhook-event": event,
|
|
4909
|
+
children: t(id, label)
|
|
4910
|
+
}
|
|
4911
|
+
) }) }, event)) }) })
|
|
4912
|
+
]
|
|
4913
|
+
}
|
|
4914
|
+
);
|
|
4915
|
+
};
|
|
3080
4916
|
const WEBHOOK_EVENTS = Object.freeze({
|
|
3081
4917
|
suspicious: "login.suspicious",
|
|
3082
4918
|
newLocation: "login.new_location",
|
|
@@ -3112,13 +4948,19 @@ const AlertTypeCell = ({ checked, disabled, children }) => /* @__PURE__ */ jsxRu
|
|
|
3112
4948
|
const AlertsTab = ({ form }) => {
|
|
3113
4949
|
const { t, tError } = useSettingsTranslate();
|
|
3114
4950
|
const { settings, handleChange, errors } = form;
|
|
3115
|
-
const hintIds = {
|
|
4951
|
+
const hintIds = {
|
|
4952
|
+
suspicious: react.useId(),
|
|
4953
|
+
newCountry: react.useId(),
|
|
4954
|
+
vpnProxy: react.useId(),
|
|
4955
|
+
newDevice: react.useId(),
|
|
4956
|
+
travel: react.useId()
|
|
4957
|
+
};
|
|
3116
4958
|
const lookupOff = !settings.enableGeolocation;
|
|
3117
4959
|
const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
|
|
3118
4960
|
const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
|
|
3119
4961
|
const locked = form.canChangeProtected === false;
|
|
3120
4962
|
const templateErrors = fieldHasError(errors, "emailTemplates");
|
|
3121
|
-
const risk =
|
|
4963
|
+
const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
|
|
3122
4964
|
const emailTypes = [
|
|
3123
4965
|
{
|
|
3124
4966
|
field: "alertOnSuspiciousLogin",
|
|
@@ -3148,6 +4990,25 @@ const AlertsTab = ({ form }) => {
|
|
|
3148
4990
|
"settings.config.email.vpnProxy.hint",
|
|
3149
4991
|
"Sign-in from a VPN, or from a public or residential proxy."
|
|
3150
4992
|
)
|
|
4993
|
+
},
|
|
4994
|
+
{
|
|
4995
|
+
field: "alertOnNewDevice",
|
|
4996
|
+
hintId: hintIds.newDevice,
|
|
4997
|
+
label: t("settings.config.email.newDevice.label", "Sign-in from a new device"),
|
|
4998
|
+
hint: t(
|
|
4999
|
+
"settings.config.email.newDevice.hint",
|
|
5000
|
+
`Browser and system not seen in the user's last 50 sessions. With a "This wasn't me" link that signs that device out.`
|
|
5001
|
+
)
|
|
5002
|
+
},
|
|
5003
|
+
{
|
|
5004
|
+
field: "alertOnImpossibleTravel",
|
|
5005
|
+
hintId: hintIds.travel,
|
|
5006
|
+
needsTravel: true,
|
|
5007
|
+
label: t("settings.config.email.travel.label", "Impossible travel"),
|
|
5008
|
+
hint: t(
|
|
5009
|
+
"settings.config.email.travel.hint",
|
|
5010
|
+
`Farther from the previous sign-in than anyone could travel. With a "This wasn't me" link.`
|
|
5011
|
+
)
|
|
3151
5012
|
}
|
|
3152
5013
|
];
|
|
3153
5014
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
@@ -3185,9 +5046,10 @@ const AlertsTab = ({ form }) => {
|
|
|
3185
5046
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
|
|
3186
5047
|
/* @__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
5048
|
!lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
|
|
3188
|
-
/* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
|
|
3189
|
-
const control = needsRiskData ?
|
|
3190
|
-
const
|
|
5049
|
+
/* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, needsTravel, hintId, label, hint }) => {
|
|
5050
|
+
const control = needsRiskData ? dashboardModel.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
|
|
5051
|
+
const travelOff = needsTravel && settings.impossibleTravelEnabled !== true;
|
|
5052
|
+
const disabled = emailTypesDisabled || control.disabled || travelOff;
|
|
3191
5053
|
return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
|
|
3192
5054
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3193
5055
|
designSystem.Checkbox,
|
|
@@ -3200,7 +5062,8 @@ const AlertsTab = ({ form }) => {
|
|
|
3200
5062
|
}
|
|
3201
5063
|
),
|
|
3202
5064
|
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint }),
|
|
3203
|
-
!lookupOff && control.disabled ? /* @__PURE__ */ jsxRuntime.jsx(RiskSourceNotice, { savedOn: control.savedOnButInactive }) : null
|
|
5065
|
+
!lookupOff && control.disabled ? /* @__PURE__ */ jsxRuntime.jsx(RiskSourceNotice, { savedOn: control.savedOnButInactive }) : null,
|
|
5066
|
+
travelOff ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: "login-protection", children: t("settings.config.requires.travel", "Requires Detect impossible travel") }) : null
|
|
3204
5067
|
] }, field);
|
|
3205
5068
|
}) }) })
|
|
3206
5069
|
] }),
|
|
@@ -3228,7 +5091,7 @@ const AlertsTab = ({ form }) => {
|
|
|
3228
5091
|
title: t("settings.config.webhooks.title", "Team notifications (webhooks)"),
|
|
3229
5092
|
subtitle: t(
|
|
3230
5093
|
"settings.config.webhooks.intro",
|
|
3231
|
-
"Posts
|
|
5094
|
+
"Posts the selected events to Discord or Slack."
|
|
3232
5095
|
),
|
|
3233
5096
|
children: [
|
|
3234
5097
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3238,7 +5101,7 @@ const AlertsTab = ({ form }) => {
|
|
|
3238
5101
|
title: t("settings.config.webhooks.enable.label", "Send team notifications"),
|
|
3239
5102
|
description: t(
|
|
3240
5103
|
"settings.config.webhooks.enable.hint",
|
|
3241
|
-
"
|
|
5104
|
+
"A sign-in is sent as {suspicious}, otherwise {newLocation}, otherwise {success}, when that event is selected below.",
|
|
3242
5105
|
WEBHOOK_EVENTS
|
|
3243
5106
|
),
|
|
3244
5107
|
checked: settings.enableWebhooks,
|
|
@@ -3301,7 +5164,9 @@ const AlertsTab = ({ form }) => {
|
|
|
3301
5164
|
] })
|
|
3302
5165
|
]
|
|
3303
5166
|
}
|
|
3304
|
-
)
|
|
5167
|
+
),
|
|
5168
|
+
/* @__PURE__ */ jsxRuntime.jsx(WebhookEventsCard, { form }),
|
|
5169
|
+
/* @__PURE__ */ jsxRuntime.jsx(SignedWebhookCard, { form })
|
|
3305
5170
|
] });
|
|
3306
5171
|
};
|
|
3307
5172
|
const DangerButton = styled__default.default(designSystem.Button)`
|
|
@@ -3312,27 +5177,97 @@ const DataRetentionTab = ({ form }) => {
|
|
|
3312
5177
|
const { t } = useSettingsTranslate();
|
|
3313
5178
|
const units = useOptionLabels();
|
|
3314
5179
|
const { settings, handleChange, handleCleanInactive } = form;
|
|
5180
|
+
const {
|
|
5181
|
+
allowedActions: { canRead: canReadLog }
|
|
5182
|
+
} = StrapiAdmin.useRBAC(index.pluginPermissions.adminActivityRead);
|
|
5183
|
+
const locked = form.canChangeProtected === false;
|
|
5184
|
+
const canChangeLogRetention = canReadLog && !locked;
|
|
5185
|
+
const preset = currentRetentionPreset(settings);
|
|
5186
|
+
const applyPreset = (key) => {
|
|
5187
|
+
const values = RETENTION_PRESETS[key];
|
|
5188
|
+
if (!values) return;
|
|
5189
|
+
handleChange("retentionDays", values.retentionDays);
|
|
5190
|
+
if (canChangeLogRetention) {
|
|
5191
|
+
handleChange("securityLogRetentionDays", values.securityLogRetentionDays);
|
|
5192
|
+
}
|
|
5193
|
+
};
|
|
3315
5194
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
3316
5195
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
3317
5196
|
"settings.config.retention.intro",
|
|
3318
5197
|
"Ended sessions stay in the history until they are deleted. The tokens of deleted sessions stay revoked."
|
|
3319
5198
|
) }),
|
|
3320
|
-
/* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { title: t("settings.config.retention.title", "History retention"), children: /* @__PURE__ */ jsxRuntime.
|
|
3321
|
-
|
|
5199
|
+
/* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { title: t("settings.config.retention.title", "History retention"), children: /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
|
|
5200
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5201
|
+
FormField,
|
|
5202
|
+
{
|
|
5203
|
+
id: "retention-preset",
|
|
5204
|
+
name: "retentionPreset",
|
|
5205
|
+
label: t("settings.config.retention.preset.label", "Retention preset"),
|
|
5206
|
+
description: canChangeLogRetention ? t(
|
|
5207
|
+
"settings.config.retention.preset.hint",
|
|
5208
|
+
"Sets how long ended sessions and security events are kept. You can still change each value."
|
|
5209
|
+
) : t(
|
|
5210
|
+
"settings.config.retention.preset.hintSessionsOnly",
|
|
5211
|
+
'Sets how long ended sessions are kept. The security log retention needs "View admin activity" and "Change protected settings".'
|
|
5212
|
+
),
|
|
5213
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: preset, onChange: (value) => applyPreset(value), children: [
|
|
5214
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "minimal", children: t("settings.config.retention.preset.minimal", "Minimal: 7 days, events 30 days") }),
|
|
5215
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "standard", children: t(
|
|
5216
|
+
"settings.config.retention.preset.standard",
|
|
5217
|
+
"Standard: 90 days, events 90 days"
|
|
5218
|
+
) }),
|
|
5219
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "extended", children: t(
|
|
5220
|
+
"settings.config.retention.preset.extended",
|
|
5221
|
+
"Extended: 365 days, events 365 days"
|
|
5222
|
+
) }),
|
|
5223
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "custom", disabled: true, children: t("settings.config.retention.preset.custom", "Custom values") })
|
|
5224
|
+
] })
|
|
5225
|
+
}
|
|
5226
|
+
),
|
|
5227
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5228
|
+
PresetSelect,
|
|
5229
|
+
{
|
|
5230
|
+
id: "session-retention-period",
|
|
5231
|
+
name: "retentionDays",
|
|
5232
|
+
label: t("settings.config.retention.keep.label", "Keep ended sessions for"),
|
|
5233
|
+
description: t(
|
|
5234
|
+
"settings.config.retention.keep.hint",
|
|
5235
|
+
"Checked once a day, the first time about 24 hours after the server starts. Open sessions are never deleted by retention. 'Forever' keeps them."
|
|
5236
|
+
),
|
|
5237
|
+
value: settings.retentionDays,
|
|
5238
|
+
presets: SELECT_PRESETS.retentionDays,
|
|
5239
|
+
format: units.retentionDays,
|
|
5240
|
+
onChange: (value) => handleChange("retentionDays", value)
|
|
5241
|
+
}
|
|
5242
|
+
)
|
|
5243
|
+
] }) }),
|
|
5244
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5245
|
+
SectionCard.SectionCard,
|
|
3322
5246
|
{
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
"settings.config.retention.keep.hint",
|
|
3328
|
-
"Checked once a day, the first time about 24 hours after the server starts. Open sessions are never deleted by retention. 'Forever' keeps them."
|
|
5247
|
+
title: t("settings.config.privacy.title", "Privacy"),
|
|
5248
|
+
subtitle: t(
|
|
5249
|
+
"settings.config.privacy.intro",
|
|
5250
|
+
"What Session Manager records about app users. The README has a fact sheet for data protection and works councils."
|
|
3329
5251
|
),
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
5252
|
+
children: [
|
|
5253
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5254
|
+
SettingsToggleRow,
|
|
5255
|
+
{
|
|
5256
|
+
id: "session-ip-anonymize",
|
|
5257
|
+
title: t("settings.config.privacy.shortIp.label", "Shorten IP addresses of sessions"),
|
|
5258
|
+
description: t(
|
|
5259
|
+
"settings.config.privacy.shortIp.hint",
|
|
5260
|
+
"Stores 203.0.113.0 instead of 203.0.113.42 (IPv6: the first 48 bits) for new sessions. Country rules and lockouts still use the full address while the request runs. Existing sessions are not changed."
|
|
5261
|
+
),
|
|
5262
|
+
checked: settings.sessionIpAnonymize === true,
|
|
5263
|
+
disabled: locked,
|
|
5264
|
+
onChange: (checked) => handleChange("sessionIpAnonymize", checked)
|
|
5265
|
+
}
|
|
5266
|
+
),
|
|
5267
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null
|
|
5268
|
+
]
|
|
3334
5269
|
}
|
|
3335
|
-
)
|
|
5270
|
+
),
|
|
3336
5271
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3337
5272
|
SectionCard.SectionCard,
|
|
3338
5273
|
{
|