strapi-plugin-magic-sessionmanager 4.17.0 → 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 +35 -0
- package/README.md +78 -18
- package/dist/admin/{Analytics-BTIByTUY.js → Analytics-C8fV6LDV.js} +1 -1
- package/dist/admin/{Analytics-B-p2Q7th.mjs → Analytics-CBspdl1I.mjs} +1 -1
- package/dist/admin/{App-CH6635JB.js → App-D92MTQmn.js} +2 -2
- package/dist/admin/{App-DmesuM2g.mjs → App-PLwqaRSQ.mjs} +2 -2
- package/dist/admin/{OnlineUsersWidget-TlOp8nie.js → OnlineUsersWidget-CiKapC1B.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-CuqeQ0tb.mjs → OnlineUsersWidget-CwfBJdIX.mjs} +1 -1
- package/dist/admin/{Settings-C4IgGBjQ.mjs → Settings-CMgL-Aub.mjs} +866 -38
- package/dist/admin/{Settings-DtP_H4JS.js → Settings-Duil_4jv.js} +866 -38
- package/dist/admin/{dashboardModel-0ROcWcB1.mjs → dashboardModel-BhUonEqc.mjs} +1 -1
- package/dist/admin/{dashboardModel-BSJhZdXI.js → dashboardModel-sksvIc1c.js} +1 -1
- package/dist/admin/{de-C_ooq6EF.js → de-CnInuvMY.js} +87 -3
- package/dist/admin/{de-BoahnYIP.mjs → de-D2BqfY1f.mjs} +87 -3
- package/dist/admin/{en-DHme92L-.mjs → en-BPy208we.mjs} +87 -3
- package/dist/admin/{en-CuUVE2K0.js → en-KnmmYHTF.js} +87 -3
- package/dist/admin/{es-CjcTgS9Z.mjs → es-B4VNeT0A.mjs} +87 -3
- package/dist/admin/{es-lbDNXcQi.js → es-D1NGCAJK.js} +87 -3
- package/dist/admin/{fr-BPwnrSaC.mjs → fr-AwhLN1BC.mjs} +87 -3
- package/dist/admin/{fr-RtypjgGp.js → fr-D1KNyogi.js} +87 -3
- package/dist/admin/{index-B102RF2H.mjs → index-BmnC2BPs.mjs} +9 -9
- package/dist/admin/{index-w0OuPYFm.js → index-Bnt0Jq6O.js} +9 -9
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-D5FHSP2y.mjs → pt-D6m1TijL.mjs} +87 -3
- package/dist/admin/{pt-BMCAKRQ4.js → pt-EKThRXPY.js} +87 -3
- package/dist/server/index.js +1686 -26
- package/dist/server/index.mjs +1686 -26
- package/package.json +1 -1
|
@@ -6,10 +6,10 @@ 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 dashboardModel = require("./dashboardModel-
|
|
12
|
+
const dashboardModel = require("./dashboardModel-sksvIc1c.js");
|
|
13
13
|
const symbols = require("@strapi/icons/symbols");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -53,6 +53,10 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
|
53
53
|
"lockoutTrustedAddresses",
|
|
54
54
|
"lockoutNotifyUser",
|
|
55
55
|
"recordUserSignInEvents",
|
|
56
|
+
"impossibleTravelEnabled",
|
|
57
|
+
"impossibleTravelSpeedKmh",
|
|
58
|
+
"impossibleTravelMinDistanceKm",
|
|
59
|
+
"impossibleTravelAction",
|
|
56
60
|
"trustedProxies",
|
|
57
61
|
"blockSuspiciousSessions",
|
|
58
62
|
"geoLookupFailureMode",
|
|
@@ -74,9 +78,15 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
|
74
78
|
"emailTemplates",
|
|
75
79
|
"enableWebhooks",
|
|
76
80
|
"discordWebhookUrl",
|
|
77
|
-
"slackWebhookUrl"
|
|
81
|
+
"slackWebhookUrl",
|
|
82
|
+
"alertOnNewDevice",
|
|
83
|
+
"alertOnImpossibleTravel",
|
|
84
|
+
"webhookEvents",
|
|
85
|
+
"genericWebhookEnabled",
|
|
86
|
+
"genericWebhookUrl",
|
|
87
|
+
"genericWebhookSecret"
|
|
78
88
|
],
|
|
79
|
-
"data-retention": ["retentionDays"],
|
|
89
|
+
"data-retention": ["retentionDays", "sessionIpAnonymize"],
|
|
80
90
|
"admin-activity": [
|
|
81
91
|
"adminSignInHistory",
|
|
82
92
|
"adminContentActivity",
|
|
@@ -122,6 +132,17 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
|
|
|
122
132
|
"End other sessions after a password change"
|
|
123
133
|
],
|
|
124
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"],
|
|
125
146
|
trustedProxies: ["settings.config.clientIp.trustProxy.label", "Trust proxy headers"],
|
|
126
147
|
blockSuspiciousSessions: [
|
|
127
148
|
"settings.config.suspicious.reject.label",
|
|
@@ -792,14 +813,14 @@ const ROLE_RULE_RANGES = Object.freeze({
|
|
|
792
813
|
});
|
|
793
814
|
const ROLE_RULE_FIELDS = Object.freeze(Object.keys(ROLE_RULE_RANGES));
|
|
794
815
|
const MAX_TRUSTED_ADDRESSES = 100;
|
|
795
|
-
const message$
|
|
816
|
+
const message$2 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
|
|
796
817
|
function validateWholeNumber(value, { min, max }) {
|
|
797
818
|
if (value === void 0 || value === null || value === "") {
|
|
798
|
-
return message$
|
|
819
|
+
return message$2("settings.validation.required", "Enter a value.");
|
|
799
820
|
}
|
|
800
821
|
const number = Number(value);
|
|
801
822
|
if (!Number.isInteger(number) || number < min || number > max) {
|
|
802
|
-
return message$
|
|
823
|
+
return message$2("settings.validation.range", "Enter a whole number from {min} to {max}.", {
|
|
803
824
|
min,
|
|
804
825
|
max
|
|
805
826
|
});
|
|
@@ -836,7 +857,7 @@ function validatePolicyFields(settings) {
|
|
|
836
857
|
}
|
|
837
858
|
const entries = Array.isArray(source.lockoutTrustedAddresses) ? source.lockoutTrustedAddresses : [];
|
|
838
859
|
if (entries.length > MAX_TRUSTED_ADDRESSES) {
|
|
839
|
-
errors.lockoutTrustedAddresses = message$
|
|
860
|
+
errors.lockoutTrustedAddresses = message$2(
|
|
840
861
|
"settings.validation.trustedTooMany",
|
|
841
862
|
"Enter at most {max} addresses.",
|
|
842
863
|
{ max: MAX_TRUSTED_ADDRESSES }
|
|
@@ -844,7 +865,7 @@ function validatePolicyFields(settings) {
|
|
|
844
865
|
} else {
|
|
845
866
|
const invalid = entries.find((entry) => !isTrustedAddressLine(entry));
|
|
846
867
|
if (invalid !== void 0) {
|
|
847
|
-
errors.lockoutTrustedAddresses = message$
|
|
868
|
+
errors.lockoutTrustedAddresses = message$2(
|
|
848
869
|
"settings.validation.trustedAddress",
|
|
849
870
|
'"{value}" is not an IP address or CIDR range. Use for example 192.0.2.10 or 192.0.2.0/24.',
|
|
850
871
|
{ value: String(invalid).slice(0, 64) }
|
|
@@ -856,9 +877,9 @@ function validatePolicyFields(settings) {
|
|
|
856
877
|
function validateRoleRule(draft, takenRoles = []) {
|
|
857
878
|
const errors = {};
|
|
858
879
|
if (!draft?.role) {
|
|
859
|
-
errors.role = message$
|
|
880
|
+
errors.role = message$2("settings.roleRules.validation.role", "Choose a role.");
|
|
860
881
|
} else if (takenRoles.includes(draft.role)) {
|
|
861
|
-
errors.role = message$
|
|
882
|
+
errors.role = message$2(
|
|
862
883
|
"settings.roleRules.validation.duplicate",
|
|
863
884
|
"This role already has a rule."
|
|
864
885
|
);
|
|
@@ -872,7 +893,7 @@ function validateRoleRule(draft, takenRoles = []) {
|
|
|
872
893
|
else values += 1;
|
|
873
894
|
}
|
|
874
895
|
if (values === 0 && !ROLE_RULE_FIELDS.some((field) => errors[field])) {
|
|
875
|
-
errors.form = message$
|
|
896
|
+
errors.form = message$2(
|
|
876
897
|
"settings.roleRules.validation.empty",
|
|
877
898
|
"Set at least one value. Empty fields use the general setting."
|
|
878
899
|
);
|
|
@@ -1606,7 +1627,9 @@ const TEMPLATE_KEYS = Object.freeze([
|
|
|
1606
1627
|
"suspiciousLogin",
|
|
1607
1628
|
"newLocation",
|
|
1608
1629
|
"vpnProxy",
|
|
1609
|
-
"accountLocked"
|
|
1630
|
+
"accountLocked",
|
|
1631
|
+
"newDevice",
|
|
1632
|
+
"impossibleTravel"
|
|
1610
1633
|
]);
|
|
1611
1634
|
const TEMPLATE_LIMITS = Object.freeze({ subject: 200, html: 1e4, text: 5e3 });
|
|
1612
1635
|
const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
|
|
@@ -1665,6 +1688,22 @@ const TEMPLATE_VARIABLE_DEFINITIONS = Object.freeze({
|
|
|
1665
1688
|
"{{lock.until}}": {
|
|
1666
1689
|
messageId: "settings.email.templates.variable.lockUntil",
|
|
1667
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)"
|
|
1668
1707
|
}
|
|
1669
1708
|
});
|
|
1670
1709
|
const TEMPLATE_VARIABLES = Object.freeze({
|
|
@@ -1703,7 +1742,29 @@ const TEMPLATE_VARIABLES = Object.freeze({
|
|
|
1703
1742
|
"{{reason.isVpn}}",
|
|
1704
1743
|
"{{reason.isProxy}}"
|
|
1705
1744
|
],
|
|
1706
|
-
accountLocked: ["{{user.email}}", "{{user.username}}", "{{lock.minutes}}", "{{lock.until}}"]
|
|
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}}"
|
|
1767
|
+
]
|
|
1707
1768
|
});
|
|
1708
1769
|
const TEMPLATE_PREVIEW_VALUES = Object.freeze({
|
|
1709
1770
|
"{{user.email}}": "jane.doe@example.com",
|
|
@@ -1719,7 +1780,11 @@ const TEMPLATE_PREVIEW_VALUES = Object.freeze({
|
|
|
1719
1780
|
"{{reason.isThreat}}": "false",
|
|
1720
1781
|
"{{reason.securityScore}}": "35",
|
|
1721
1782
|
"{{lock.minutes}}": "15",
|
|
1722
|
-
"{{lock.until}}": "Fri, 06 Nov 2026 09:56:00 GMT"
|
|
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"
|
|
1723
1788
|
});
|
|
1724
1789
|
function updateEmailTemplate(templates, templateKey, field, value) {
|
|
1725
1790
|
return { ...templates, [templateKey]: { ...templates[templateKey], [field]: value } };
|
|
@@ -2002,6 +2067,75 @@ Hello {{user.username}},
|
|
|
2002
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}}.
|
|
2003
2068
|
|
|
2004
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.`
|
|
2005
2139
|
}
|
|
2006
2140
|
});
|
|
2007
2141
|
function fillMissingTemplates(templates) {
|
|
@@ -2021,6 +2155,156 @@ function fillMissingTemplates(templates) {
|
|
|
2021
2155
|
})
|
|
2022
2156
|
);
|
|
2023
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
|
+
}
|
|
2024
2308
|
const SETTINGS_DEFAULTS = Object.freeze({
|
|
2025
2309
|
inactivityTimeout: 15,
|
|
2026
2310
|
cleanupInterval: 30,
|
|
@@ -2059,9 +2343,15 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
2059
2343
|
securityLogAnonymizeIp: false,
|
|
2060
2344
|
securityLogGeoLookup: false,
|
|
2061
2345
|
securityLogRetentionDays: 90,
|
|
2062
|
-
...POLICY_FORM_DEFAULTS
|
|
2346
|
+
...POLICY_FORM_DEFAULTS,
|
|
2347
|
+
...SIGNALS_FORM_DEFAULTS
|
|
2063
2348
|
});
|
|
2064
|
-
const WRITE_ONLY_SETTINGS_KEYS = Object.freeze([
|
|
2349
|
+
const WRITE_ONLY_SETTINGS_KEYS = Object.freeze([
|
|
2350
|
+
"discordWebhookUrl",
|
|
2351
|
+
"slackWebhookUrl",
|
|
2352
|
+
"genericWebhookUrl",
|
|
2353
|
+
"genericWebhookSecret"
|
|
2354
|
+
]);
|
|
2065
2355
|
const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
|
|
2066
2356
|
const WEBHOOK_HOSTS = Object.freeze({
|
|
2067
2357
|
discordWebhookUrl: ["discord.com", "discordapp.com"],
|
|
@@ -2084,6 +2374,7 @@ function normalizeSettings(loaded) {
|
|
|
2084
2374
|
blockedCountries: Array.isArray(loaded.blockedCountries) ? loaded.blockedCountries : [],
|
|
2085
2375
|
lockoutTrustedAddresses: Array.isArray(loaded.lockoutTrustedAddresses) ? loaded.lockoutTrustedAddresses : [],
|
|
2086
2376
|
roleRules: Array.isArray(loaded.roleRules) ? loaded.roleRules : [],
|
|
2377
|
+
webhookEvents: Array.isArray(loaded.webhookEvents) ? loaded.webhookEvents : [...SIGNALS_FORM_DEFAULTS.webhookEvents],
|
|
2087
2378
|
emailTemplates: fillMissingTemplates(loaded.emailTemplates)
|
|
2088
2379
|
};
|
|
2089
2380
|
}
|
|
@@ -2134,6 +2425,7 @@ function validateSettings(settings) {
|
|
|
2134
2425
|
const maxFailed = validateMaxFailedLogins(source.maxFailedLogins);
|
|
2135
2426
|
if (maxFailed) errors.maxFailedLogins = maxFailed;
|
|
2136
2427
|
Object.assign(errors, validatePolicyFields(source));
|
|
2428
|
+
Object.assign(errors, validateSignalFields(source));
|
|
2137
2429
|
if (!isAllowedWebhookUrl(source.discordWebhookUrl, WEBHOOK_HOSTS.discordWebhookUrl)) {
|
|
2138
2430
|
errors.discordWebhookUrl = message(
|
|
2139
2431
|
"settings.validation.webhookDiscord",
|
|
@@ -2483,6 +2775,147 @@ const TrustedAddressesField = ({ form, disabled = false }) => {
|
|
|
2483
2775
|
}
|
|
2484
2776
|
);
|
|
2485
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
|
+
};
|
|
2486
2919
|
const COUNTRIES = [
|
|
2487
2920
|
{ code: "DE", name: "Germany", flag: "🇩🇪" },
|
|
2488
2921
|
{ code: "AT", name: "Austria", flag: "🇦🇹" },
|
|
@@ -3212,6 +3645,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3212
3645
|
]
|
|
3213
3646
|
}
|
|
3214
3647
|
),
|
|
3648
|
+
/* @__PURE__ */ jsxRuntime.jsx(ImpossibleTravelCard, { form }),
|
|
3215
3649
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3216
3650
|
SectionCard.SectionCard,
|
|
3217
3651
|
{
|
|
@@ -3836,7 +4270,9 @@ const TEMPLATE_TAB_LABELS = {
|
|
|
3836
4270
|
suspiciousLogin: ["settings.email.templates.tab.suspicious", "Suspicious sign-in"],
|
|
3837
4271
|
newLocation: ["settings.email.templates.tab.newLocation", "New country"],
|
|
3838
4272
|
vpnProxy: ["settings.email.templates.tab.vpnProxy", "VPN or proxy"],
|
|
3839
|
-
accountLocked: ["settings.email.templates.tab.accountLocked", "Account locked"]
|
|
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"]
|
|
3840
4276
|
};
|
|
3841
4277
|
const BlockLabel = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", tag: "div", textColor: "neutral800", children });
|
|
3842
4278
|
const TemplateEditor = ({ templateKey, template, templates, handleChange, copyValue, errors }) => {
|
|
@@ -4184,6 +4620,299 @@ const WebhookUrlField = ({
|
|
|
4184
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
|
|
4185
4621
|
] }) });
|
|
4186
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
|
+
};
|
|
4187
4916
|
const WEBHOOK_EVENTS = Object.freeze({
|
|
4188
4917
|
suspicious: "login.suspicious",
|
|
4189
4918
|
newLocation: "login.new_location",
|
|
@@ -4219,7 +4948,13 @@ const AlertTypeCell = ({ checked, disabled, children }) => /* @__PURE__ */ jsxRu
|
|
|
4219
4948
|
const AlertsTab = ({ form }) => {
|
|
4220
4949
|
const { t, tError } = useSettingsTranslate();
|
|
4221
4950
|
const { settings, handleChange, errors } = form;
|
|
4222
|
-
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
|
+
};
|
|
4223
4958
|
const lookupOff = !settings.enableGeolocation;
|
|
4224
4959
|
const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
|
|
4225
4960
|
const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
|
|
@@ -4255,6 +4990,25 @@ const AlertsTab = ({ form }) => {
|
|
|
4255
4990
|
"settings.config.email.vpnProxy.hint",
|
|
4256
4991
|
"Sign-in from a VPN, or from a public or residential proxy."
|
|
4257
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
|
+
)
|
|
4258
5012
|
}
|
|
4259
5013
|
];
|
|
4260
5014
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
@@ -4292,9 +5046,10 @@ const AlertsTab = ({ form }) => {
|
|
|
4292
5046
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
|
|
4293
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") }),
|
|
4294
5048
|
!lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
|
|
4295
|
-
/* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
|
|
5049
|
+
/* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, needsTravel, hintId, label, hint }) => {
|
|
4296
5050
|
const control = needsRiskData ? dashboardModel.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
|
|
4297
|
-
const
|
|
5051
|
+
const travelOff = needsTravel && settings.impossibleTravelEnabled !== true;
|
|
5052
|
+
const disabled = emailTypesDisabled || control.disabled || travelOff;
|
|
4298
5053
|
return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
|
|
4299
5054
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4300
5055
|
designSystem.Checkbox,
|
|
@@ -4307,7 +5062,8 @@ const AlertsTab = ({ form }) => {
|
|
|
4307
5062
|
}
|
|
4308
5063
|
),
|
|
4309
5064
|
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint }),
|
|
4310
|
-
!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
|
|
4311
5067
|
] }, field);
|
|
4312
5068
|
}) }) })
|
|
4313
5069
|
] }),
|
|
@@ -4335,7 +5091,7 @@ const AlertsTab = ({ form }) => {
|
|
|
4335
5091
|
title: t("settings.config.webhooks.title", "Team notifications (webhooks)"),
|
|
4336
5092
|
subtitle: t(
|
|
4337
5093
|
"settings.config.webhooks.intro",
|
|
4338
|
-
"Posts
|
|
5094
|
+
"Posts the selected events to Discord or Slack."
|
|
4339
5095
|
),
|
|
4340
5096
|
children: [
|
|
4341
5097
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4345,7 +5101,7 @@ const AlertsTab = ({ form }) => {
|
|
|
4345
5101
|
title: t("settings.config.webhooks.enable.label", "Send team notifications"),
|
|
4346
5102
|
description: t(
|
|
4347
5103
|
"settings.config.webhooks.enable.hint",
|
|
4348
|
-
"
|
|
5104
|
+
"A sign-in is sent as {suspicious}, otherwise {newLocation}, otherwise {success}, when that event is selected below.",
|
|
4349
5105
|
WEBHOOK_EVENTS
|
|
4350
5106
|
),
|
|
4351
5107
|
checked: settings.enableWebhooks,
|
|
@@ -4408,7 +5164,9 @@ const AlertsTab = ({ form }) => {
|
|
|
4408
5164
|
] })
|
|
4409
5165
|
]
|
|
4410
5166
|
}
|
|
4411
|
-
)
|
|
5167
|
+
),
|
|
5168
|
+
/* @__PURE__ */ jsxRuntime.jsx(WebhookEventsCard, { form }),
|
|
5169
|
+
/* @__PURE__ */ jsxRuntime.jsx(SignedWebhookCard, { form })
|
|
4412
5170
|
] });
|
|
4413
5171
|
};
|
|
4414
5172
|
const DangerButton = styled__default.default(designSystem.Button)`
|
|
@@ -4419,27 +5177,97 @@ const DataRetentionTab = ({ form }) => {
|
|
|
4419
5177
|
const { t } = useSettingsTranslate();
|
|
4420
5178
|
const units = useOptionLabels();
|
|
4421
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
|
+
};
|
|
4422
5194
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
4423
5195
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
4424
5196
|
"settings.config.retention.intro",
|
|
4425
5197
|
"Ended sessions stay in the history until they are deleted. The tokens of deleted sessions stay revoked."
|
|
4426
5198
|
) }),
|
|
4427
|
-
/* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { title: t("settings.config.retention.title", "History retention"), children: /* @__PURE__ */ jsxRuntime.
|
|
4428
|
-
|
|
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,
|
|
4429
5246
|
{
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
"settings.config.retention.keep.hint",
|
|
4435
|
-
"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."
|
|
4436
5251
|
),
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
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
|
+
]
|
|
4441
5269
|
}
|
|
4442
|
-
)
|
|
5270
|
+
),
|
|
4443
5271
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4444
5272
|
SectionCard.SectionCard,
|
|
4445
5273
|
{
|