strapi-plugin-magic-sessionmanager 4.22.0 → 4.23.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 +80 -0
- package/README.md +163 -119
- package/dist/admin/ActiveImpersonationsCard-CbyOAlrL.mjs +396 -0
- package/dist/admin/ActiveImpersonationsCard-D1CVmV-w.js +395 -0
- package/dist/admin/{Analytics-WbCUmkQQ.mjs → Analytics-DGAHD19E.mjs} +1 -1
- package/dist/admin/{Analytics-DeDLGiCe.js → Analytics-_WA68oHb.js} +1 -1
- package/dist/admin/{App-Bkv-W0Sv.js → App-CfhAQ17e.js} +304 -104
- package/dist/admin/{App-C4bihk2K.mjs → App-VB66H73A.mjs} +276 -76
- package/dist/admin/ImpersonationTabBanner-B6Ps5-oe.mjs +244 -0
- package/dist/admin/ImpersonationTabBanner-DdwXNmh4.js +244 -0
- package/dist/admin/{OnlineUsersWidget-q0Z6nbbO.mjs → OnlineUsersWidget-2u-fYMb7.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-CSvNe2rC.js → OnlineUsersWidget-CmBqFLAA.js} +1 -1
- package/dist/admin/{Settings-xokFI5LO.js → Settings-BBs2FDp7.js} +87 -266
- package/dist/admin/{Settings-avD0DbXP.mjs → Settings-CKDNGJhl.mjs} +79 -258
- package/dist/admin/{de-BQlEdBMr.mjs → de-CK-HuY41.mjs} +48 -7
- package/dist/admin/{de-HcJ19LKI.js → de-CSRQPn6F.js} +48 -7
- package/dist/admin/{en-DI-98CPM.js → en-DCtAgGEa.js} +48 -7
- package/dist/admin/{en-DzuXWL1W.mjs → en-KZ5ajaAR.mjs} +48 -7
- package/dist/admin/{es-BfyED9YI.mjs → es-B7k8taWV.mjs} +48 -7
- package/dist/admin/{es-Cm0Eklav.js → es-CKT00l4K.js} +48 -7
- package/dist/admin/{fr-C3nzszsI.js → fr-B2EdBFSb.js} +48 -7
- package/dist/admin/{fr-CzFNGWq0.mjs → fr-Q2gmYqCn.mjs} +48 -7
- package/dist/admin/{index-6zc5D8eb.mjs → index-BPbs1GyP.mjs} +386 -61
- package/dist/admin/{index-Dk5Jqe5U.js → index-Cho0XGZ1.js} +340 -15
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-BPZ6chPT.js → pt-CcMUcqDy.js} +48 -7
- package/dist/admin/{pt-DmyQnGI_.mjs → pt-CmxZTaf2.mjs} +48 -7
- package/dist/admin/useBreakpoint-CoBfu0Ov.js +62 -0
- package/dist/admin/useBreakpoint-CuyIc2qy.mjs +63 -0
- package/dist/server/index.js +1809 -400
- package/dist/server/index.mjs +1809 -400
- package/package.json +9 -4
- package/dist/admin/dashboardModel-BBNRgcEr.mjs +0 -170
- package/dist/admin/dashboardModel-D4389iIV.js +0 -169
|
@@ -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-Cho0XGZ1.js");
|
|
10
10
|
require("react-intl");
|
|
11
11
|
const SectionCard = require("./SectionCard-BlWv8CRt.js");
|
|
12
|
-
const
|
|
12
|
+
const ActiveImpersonationsCard = require("./ActiveImpersonationsCard-D1CVmV-w.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);
|
|
@@ -571,6 +571,7 @@ const ROLE_RULE_RANGES = Object.freeze({
|
|
|
571
571
|
});
|
|
572
572
|
const ROLE_RULE_FIELDS = Object.freeze(Object.keys(ROLE_RULE_RANGES));
|
|
573
573
|
const MAX_TRUSTED_ADDRESSES = 100;
|
|
574
|
+
const MAX_TRUSTED_PROXIES = 50;
|
|
574
575
|
const message$2 = (messageId, defaultMessage, values) => ({ messageId, defaultMessage, values });
|
|
575
576
|
function validateWholeNumber(value, { min, max }) {
|
|
576
577
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -613,17 +614,24 @@ function validatePolicyFields(settings) {
|
|
|
613
614
|
const error = validateWholeNumber(source[key], range);
|
|
614
615
|
if (error) errors[key] = error;
|
|
615
616
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
for (const [field, max] of [
|
|
618
|
+
["lockoutTrustedAddresses", MAX_TRUSTED_ADDRESSES],
|
|
619
|
+
["trustedProxies", MAX_TRUSTED_PROXIES]
|
|
620
|
+
]) {
|
|
621
|
+
const entries = Array.isArray(source[field]) ? source[field] : [];
|
|
622
|
+
if (entries.length > max) {
|
|
623
|
+
errors[field] = message$2(
|
|
624
|
+
"settings.validation.trustedTooMany",
|
|
625
|
+
"Enter at most {max} addresses.",
|
|
626
|
+
{
|
|
627
|
+
max
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
624
632
|
const invalid = entries.find((entry) => !isTrustedAddressLine(entry));
|
|
625
633
|
if (invalid !== void 0) {
|
|
626
|
-
errors
|
|
634
|
+
errors[field] = message$2(
|
|
627
635
|
"settings.validation.trustedAddress",
|
|
628
636
|
'"{value}" is not an IP address or CIDR range. Use for example 192.0.2.10 or 192.0.2.0/24.',
|
|
629
637
|
{ value: String(invalid).slice(0, 64) }
|
|
@@ -682,9 +690,9 @@ function sortLocks(locks) {
|
|
|
682
690
|
return Number.isFinite(until) && until !== 0 ? until : String(a.id).localeCompare(b.id);
|
|
683
691
|
});
|
|
684
692
|
}
|
|
685
|
-
const TABLE_MIN_WIDTH$
|
|
686
|
-
const keepActionKeys$
|
|
687
|
-
if (
|
|
693
|
+
const TABLE_MIN_WIDTH$1 = 640;
|
|
694
|
+
const keepActionKeys$1 = (event) => {
|
|
695
|
+
if (ActiveImpersonationsCard.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
688
696
|
};
|
|
689
697
|
const EMPTY_DRAFT = Object.freeze({
|
|
690
698
|
role: "",
|
|
@@ -770,10 +778,10 @@ const RoleRulesSection = ({ form }) => {
|
|
|
770
778
|
};
|
|
771
779
|
const fieldError = (key) => showErrors ? tError(draftErrors[key]) : void 0;
|
|
772
780
|
const availableRoles = (roles || []).filter((role) => !taken.includes(role.documentId));
|
|
773
|
-
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$
|
|
781
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
|
|
774
782
|
const actions = (rule) => {
|
|
775
783
|
const name = roleName(rule.role);
|
|
776
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
784
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ActiveImpersonationsCard.RowActions, { onKeyDown: keepActionKeys$1, children: [
|
|
777
785
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
778
786
|
designSystem.IconButton,
|
|
779
787
|
{
|
|
@@ -2072,7 +2080,8 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
2072
2080
|
sessionCreationGraceMs: 5e3,
|
|
2073
2081
|
cleanupUseDbDirect: false,
|
|
2074
2082
|
strictSessionEnforcement: false,
|
|
2075
|
-
|
|
2083
|
+
// Proxy addresses or CIDR ranges (4.22.1); empty = Strapi's server.proxy settings.
|
|
2084
|
+
trustedProxies: [],
|
|
2076
2085
|
enableGeolocation: true,
|
|
2077
2086
|
enableSecurityScoring: true,
|
|
2078
2087
|
blockSuspiciousSessions: false,
|
|
@@ -2133,6 +2142,7 @@ function normalizeSettings(loaded) {
|
|
|
2133
2142
|
allowedCountries: Array.isArray(loaded.allowedCountries) ? loaded.allowedCountries : [],
|
|
2134
2143
|
blockedCountries: Array.isArray(loaded.blockedCountries) ? loaded.blockedCountries : [],
|
|
2135
2144
|
lockoutTrustedAddresses: Array.isArray(loaded.lockoutTrustedAddresses) ? loaded.lockoutTrustedAddresses : [],
|
|
2145
|
+
trustedProxies: Array.isArray(loaded.trustedProxies) ? loaded.trustedProxies : [],
|
|
2136
2146
|
roleRules: Array.isArray(loaded.roleRules) ? loaded.roleRules : [],
|
|
2137
2147
|
webhookEvents: Array.isArray(loaded.webhookEvents) ? loaded.webhookEvents : [...SIGNALS_FORM_DEFAULTS.webhookEvents],
|
|
2138
2148
|
emailTemplates: fillMissingTemplates(loaded.emailTemplates)
|
|
@@ -2229,9 +2239,9 @@ function getAdjustedFields(submitted, stored, previous) {
|
|
|
2229
2239
|
(key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
|
|
2230
2240
|
);
|
|
2231
2241
|
}
|
|
2232
|
-
const TABLE_MIN_WIDTH
|
|
2233
|
-
const keepActionKeys
|
|
2234
|
-
if (
|
|
2242
|
+
const TABLE_MIN_WIDTH = 640;
|
|
2243
|
+
const keepActionKeys = (event) => {
|
|
2244
|
+
if (ActiveImpersonationsCard.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2235
2245
|
};
|
|
2236
2246
|
const LockTarget = ({ lock }) => {
|
|
2237
2247
|
const { t } = index.useSettingsTranslate();
|
|
@@ -2350,7 +2360,7 @@ const LockedNowCard = () => {
|
|
|
2350
2360
|
}
|
|
2351
2361
|
};
|
|
2352
2362
|
const showActions = !permissionsLoading && canUnlock;
|
|
2353
|
-
const asTable = width === 0 || width >= TABLE_MIN_WIDTH
|
|
2363
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH;
|
|
2354
2364
|
const unlockAction = (lock) => showActions ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2355
2365
|
index.ConfirmAction,
|
|
2356
2366
|
{
|
|
@@ -2417,7 +2427,7 @@ const LockedNowCard = () => {
|
|
|
2417
2427
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }) }),
|
|
2418
2428
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
|
|
2419
2429
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: ends(lock) }),
|
|
2420
|
-
showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2430
|
+
showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
|
|
2421
2431
|
] }, lock.id)) })
|
|
2422
2432
|
] }) });
|
|
2423
2433
|
} else {
|
|
@@ -2440,7 +2450,7 @@ const LockedNowCard = () => {
|
|
|
2440
2450
|
}) })
|
|
2441
2451
|
] })
|
|
2442
2452
|
] }),
|
|
2443
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2453
|
+
/* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
|
|
2444
2454
|
] })
|
|
2445
2455
|
},
|
|
2446
2456
|
lock.id
|
|
@@ -2498,37 +2508,43 @@ const LockedNowCard = () => {
|
|
|
2498
2508
|
}
|
|
2499
2509
|
);
|
|
2500
2510
|
};
|
|
2501
|
-
const TrustedAddressesField = ({
|
|
2511
|
+
const TrustedAddressesField = ({
|
|
2512
|
+
form,
|
|
2513
|
+
disabled = false,
|
|
2514
|
+
field = "lockoutTrustedAddresses",
|
|
2515
|
+
id = "lockout-trusted-addresses",
|
|
2516
|
+
label,
|
|
2517
|
+
description,
|
|
2518
|
+
placeholder = "192.0.2.0/24"
|
|
2519
|
+
}) => {
|
|
2502
2520
|
const { t, tError } = index.useSettingsTranslate();
|
|
2503
2521
|
const { settings, handleChange, errors, draftVersion } = form;
|
|
2504
|
-
const [text, setText] = react.useState(
|
|
2505
|
-
() => formatTrustedAddressText(settings.lockoutTrustedAddresses)
|
|
2506
|
-
);
|
|
2522
|
+
const [text, setText] = react.useState(() => formatTrustedAddressText(settings[field]));
|
|
2507
2523
|
const [version, setVersion] = react.useState(draftVersion);
|
|
2508
2524
|
if (version !== draftVersion) {
|
|
2509
2525
|
setVersion(draftVersion);
|
|
2510
|
-
setText(formatTrustedAddressText(settings
|
|
2526
|
+
setText(formatTrustedAddressText(settings[field]));
|
|
2511
2527
|
}
|
|
2512
2528
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2513
2529
|
FormField,
|
|
2514
2530
|
{
|
|
2515
|
-
id
|
|
2516
|
-
name:
|
|
2517
|
-
label: t("settings.config.failed.trusted.label", "Trusted addresses"),
|
|
2518
|
-
description: t(
|
|
2531
|
+
id,
|
|
2532
|
+
name: field,
|
|
2533
|
+
label: label ?? t("settings.config.failed.trusted.label", "Trusted addresses"),
|
|
2534
|
+
description: description ?? t(
|
|
2519
2535
|
"settings.config.failed.trusted.hint",
|
|
2520
2536
|
"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."
|
|
2521
2537
|
),
|
|
2522
|
-
error: tError(errors
|
|
2538
|
+
error: tError(errors[field]),
|
|
2523
2539
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2524
2540
|
designSystem.Textarea,
|
|
2525
2541
|
{
|
|
2526
2542
|
value: text,
|
|
2527
|
-
placeholder
|
|
2543
|
+
placeholder,
|
|
2528
2544
|
disabled,
|
|
2529
2545
|
onChange: (event) => {
|
|
2530
2546
|
setText(event.target.value);
|
|
2531
|
-
handleChange(
|
|
2547
|
+
handleChange(field, parseTrustedAddressText(event.target.value));
|
|
2532
2548
|
}
|
|
2533
2549
|
}
|
|
2534
2550
|
)
|
|
@@ -3117,8 +3133,8 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3117
3133
|
const lookupOff = !settings.enableGeolocation;
|
|
3118
3134
|
const locked = form.canChangeProtected === false;
|
|
3119
3135
|
const policyLocked = locked;
|
|
3120
|
-
const risk =
|
|
3121
|
-
const reject =
|
|
3136
|
+
const risk = ActiveImpersonationsCard.getRiskAvailability(form.geoIp.status);
|
|
3137
|
+
const reject = ActiveImpersonationsCard.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
|
|
3122
3138
|
const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
|
|
3123
3139
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
3124
3140
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
@@ -3152,6 +3168,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3152
3168
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3153
3169
|
designSystem.NumberInput,
|
|
3154
3170
|
{
|
|
3171
|
+
disabled: policyLocked,
|
|
3155
3172
|
value: settings.maxFailedLogins,
|
|
3156
3173
|
onValueChange: (value) => handleChange("maxFailedLogins", value),
|
|
3157
3174
|
min: MAX_FAILED_LOGINS_RANGE.min,
|
|
@@ -3305,7 +3322,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3305
3322
|
}
|
|
3306
3323
|
),
|
|
3307
3324
|
/* @__PURE__ */ jsxRuntime.jsx(LockedNowCard, {}),
|
|
3308
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3325
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3309
3326
|
SectionCard.SectionCard,
|
|
3310
3327
|
{
|
|
3311
3328
|
id: "client-ip-address",
|
|
@@ -3314,19 +3331,24 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
3314
3331
|
"settings.config.clientIp.intro",
|
|
3315
3332
|
"All IP-based rules depend on reading the real client address."
|
|
3316
3333
|
),
|
|
3317
|
-
children:
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
"
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3334
|
+
children: [
|
|
3335
|
+
policyLocked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
3336
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3337
|
+
TrustedAddressesField,
|
|
3338
|
+
{
|
|
3339
|
+
form,
|
|
3340
|
+
disabled: policyLocked,
|
|
3341
|
+
field: "trustedProxies",
|
|
3342
|
+
id: "trusted-proxies",
|
|
3343
|
+
placeholder: "10.0.0.0/8",
|
|
3344
|
+
label: t("settings.config.clientIp.trustProxy.label", "Trusted proxies"),
|
|
3345
|
+
description: t(
|
|
3346
|
+
"settings.config.clientIp.trustProxy.hint",
|
|
3347
|
+
"Leave empty to use Strapi's server.proxy settings (koa, ipHeader, maxIpsCount). Otherwise list your proxies, one IP address or CIDR range per line: only a request that comes from a listed proxy has its X-Forwarded-For read, and the client is the right-most address that is not listed. Affects the recorded IP address, the IP lockout and location lookups."
|
|
3348
|
+
)
|
|
3349
|
+
}
|
|
3350
|
+
)
|
|
3351
|
+
]
|
|
3330
3352
|
}
|
|
3331
3353
|
),
|
|
3332
3354
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3830,7 +3852,7 @@ const RiskDataCard = ({ form }) => {
|
|
|
3830
3852
|
const { t } = index.useSettingsTranslate();
|
|
3831
3853
|
const { settings, geoIp } = form;
|
|
3832
3854
|
const lookupOff = !settings.enableGeolocation;
|
|
3833
|
-
const risk =
|
|
3855
|
+
const risk = ActiveImpersonationsCard.getRiskAvailability(geoIp.status);
|
|
3834
3856
|
const sourceLabels = {
|
|
3835
3857
|
"anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
|
|
3836
3858
|
"asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
|
|
@@ -3897,8 +3919,8 @@ const RiskDataCard = ({ form }) => {
|
|
|
3897
3919
|
const LocationDataTab = ({ form }) => {
|
|
3898
3920
|
const { t } = index.useSettingsTranslate();
|
|
3899
3921
|
const { settings, handleChange } = form;
|
|
3900
|
-
const risk =
|
|
3901
|
-
const scoring =
|
|
3922
|
+
const risk = ActiveImpersonationsCard.getRiskAvailability(form.geoIp.status);
|
|
3923
|
+
const scoring = ActiveImpersonationsCard.riskDependentControl(settings.enableSecurityScoring, risk.state);
|
|
3902
3924
|
const locked = form.canChangeProtected === false;
|
|
3903
3925
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
3904
3926
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
@@ -4720,7 +4742,7 @@ const AlertsTab = ({ form }) => {
|
|
|
4720
4742
|
const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
|
|
4721
4743
|
const locked = form.canChangeProtected === false;
|
|
4722
4744
|
const templateErrors = index.fieldHasError(errors, "emailTemplates");
|
|
4723
|
-
const risk =
|
|
4745
|
+
const risk = ActiveImpersonationsCard.getRiskAvailability(form.geoIp.status);
|
|
4724
4746
|
const emailTypes = [
|
|
4725
4747
|
{
|
|
4726
4748
|
field: "alertOnSuspiciousLogin",
|
|
@@ -4807,7 +4829,7 @@ const AlertsTab = ({ form }) => {
|
|
|
4807
4829
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
|
|
4808
4830
|
!lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
|
|
4809
4831
|
/* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, needsTravel, hintId, label, hint }) => {
|
|
4810
|
-
const control = needsRiskData ?
|
|
4832
|
+
const control = needsRiskData ? ActiveImpersonationsCard.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
|
|
4811
4833
|
const travelOff = needsTravel && settings.impossibleTravelEnabled !== true;
|
|
4812
4834
|
const disabled = emailTypesDisabled || control.disabled || travelOff;
|
|
4813
4835
|
return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
|
|
@@ -4827,12 +4849,13 @@ const AlertsTab = ({ form }) => {
|
|
|
4827
4849
|
] }, field);
|
|
4828
4850
|
}) }) })
|
|
4829
4851
|
] }),
|
|
4852
|
+
locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
|
|
4830
4853
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4831
4854
|
AdvancedSection,
|
|
4832
4855
|
{
|
|
4833
4856
|
label: t("settings.config.email.templates.label", "Edit email templates"),
|
|
4834
4857
|
hasError: templateErrors,
|
|
4835
|
-
disabled: emailTypesDisabled,
|
|
4858
|
+
disabled: emailTypesDisabled || locked,
|
|
4836
4859
|
children: [
|
|
4837
4860
|
/* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: "warning", closeLabel: t("common.close", "Close"), title: "", children: t(
|
|
4838
4861
|
"settings.config.email.templates.warning",
|
|
@@ -5202,220 +5225,18 @@ const AdminActivityTab = ({ form }) => {
|
|
|
5202
5225
|
)
|
|
5203
5226
|
] });
|
|
5204
5227
|
};
|
|
5205
|
-
const TABLE_MIN_WIDTH = 720;
|
|
5206
|
-
const keepActionKeys = (event) => {
|
|
5207
|
-
if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
5208
|
-
};
|
|
5209
|
-
const ActiveImpersonationsCard = () => {
|
|
5210
|
-
const { t } = index.useSettingsTranslate();
|
|
5211
|
-
const { get, post } = StrapiAdmin.useFetchClient();
|
|
5212
|
-
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
5213
|
-
const { formatDate } = index.useSessionFormatters();
|
|
5214
|
-
const [widthRef, width] = index.useElementWidth();
|
|
5215
|
-
const [rows, setRows] = react.useState(null);
|
|
5216
|
-
const [error, setError] = react.useState(false);
|
|
5217
|
-
const [refreshing, setRefreshing] = react.useState(false);
|
|
5218
|
-
const refreshRef = react.useRef(null);
|
|
5219
|
-
const requestRef = react.useRef(0);
|
|
5220
|
-
const apply = react.useCallback(async (request, pending) => {
|
|
5221
|
-
try {
|
|
5222
|
-
const { data } = await pending;
|
|
5223
|
-
if (request !== requestRef.current) return;
|
|
5224
|
-
if (!Array.isArray(data?.data)) throw new Error("Invalid impersonation list");
|
|
5225
|
-
setRows(data.data);
|
|
5226
|
-
setError(false);
|
|
5227
|
-
} catch (err) {
|
|
5228
|
-
if (index.isCancelledRequest(err) || request !== requestRef.current) return;
|
|
5229
|
-
index.logSafeAdminError("impersonation.list", err);
|
|
5230
|
-
setError(true);
|
|
5231
|
-
} finally {
|
|
5232
|
-
if (request === requestRef.current) setRefreshing(false);
|
|
5233
|
-
}
|
|
5234
|
-
}, []);
|
|
5235
|
-
const load = react.useCallback(() => {
|
|
5236
|
-
const request = ++requestRef.current;
|
|
5237
|
-
setRefreshing(true);
|
|
5238
|
-
return apply(request, get(`/${index.pluginId}/impersonation/active`));
|
|
5239
|
-
}, [apply, get]);
|
|
5240
|
-
react.useEffect(() => {
|
|
5241
|
-
apply(++requestRef.current, get(`/${index.pluginId}/impersonation/active`));
|
|
5242
|
-
}, [apply, get]);
|
|
5243
|
-
const end = async (row) => {
|
|
5244
|
-
try {
|
|
5245
|
-
await post(`/${index.pluginId}/impersonation/${row.id}/end`, {});
|
|
5246
|
-
toggleNotification({
|
|
5247
|
-
type: "success",
|
|
5248
|
-
message: t("impersonation.ended", "Impersonation ended.")
|
|
5249
|
-
});
|
|
5250
|
-
} catch (err) {
|
|
5251
|
-
index.logSafeAdminError("impersonation.end", err);
|
|
5252
|
-
toggleNotification({
|
|
5253
|
-
type: "danger",
|
|
5254
|
-
message: t("impersonation.error.end", "The impersonation could not be ended.")
|
|
5255
|
-
});
|
|
5256
|
-
throw err;
|
|
5257
|
-
} finally {
|
|
5258
|
-
await load();
|
|
5259
|
-
}
|
|
5260
|
-
};
|
|
5261
|
-
const endAction = (row) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5262
|
-
index.ConfirmAction,
|
|
5263
|
-
{
|
|
5264
|
-
fallbackFocusRef: refreshRef,
|
|
5265
|
-
title: t("impersonation.confirm.title", "End the impersonation of {user}?", {
|
|
5266
|
-
user: label(row)
|
|
5267
|
-
}),
|
|
5268
|
-
body: t(
|
|
5269
|
-
"impersonation.confirm.body",
|
|
5270
|
-
"The short-lived sign-in stops working at once. This is recorded in the security log."
|
|
5271
|
-
),
|
|
5272
|
-
confirmLabel: t("impersonation.end", "End impersonation"),
|
|
5273
|
-
onConfirm: () => end(row),
|
|
5274
|
-
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5275
|
-
designSystem.IconButton,
|
|
5276
|
-
{
|
|
5277
|
-
variant: "ghost",
|
|
5278
|
-
label: t("impersonation.endLabel", "End impersonation of {user}", {
|
|
5279
|
-
user: label(row)
|
|
5280
|
-
}),
|
|
5281
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {})
|
|
5282
|
-
}
|
|
5283
|
-
)
|
|
5284
|
-
},
|
|
5285
|
-
row.id
|
|
5286
|
-
);
|
|
5287
|
-
const label = (row) => row.targetLabel || (row.targetType === "admin" ? t("impersonation.list.adminFallback", "Admin #{id}", { id: row.targetId }) : row.targetId);
|
|
5288
|
-
const kind = (row) => row.targetType === "admin" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "primary100", textColor: "neutral800", children: t("impersonation.list.kind.admin", "Admin, view only") }) : null;
|
|
5289
|
-
const time = (iso) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: iso, variant: "omega", textColor: "neutral800", children: formatDate(iso, { hour: "2-digit", minute: "2-digit" }) });
|
|
5290
|
-
const startedBy = (row) => row.startedByYou ? t("impersonation.list.you", "You") : row.actorLabel || "—";
|
|
5291
|
-
let content;
|
|
5292
|
-
if (rows === null && !error) {
|
|
5293
|
-
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("impersonation.list.loading", "Loading impersonations…") }) });
|
|
5294
|
-
} else if (error && rows === null) {
|
|
5295
|
-
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
5296
|
-
index.PersistentAlert,
|
|
5297
|
-
{
|
|
5298
|
-
variant: "danger",
|
|
5299
|
-
closeLabel: t("common.close", "Close"),
|
|
5300
|
-
title: t("impersonation.list.error", "Impersonations could not be loaded."),
|
|
5301
|
-
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: load, children: t("common.tryAgain", "Try again") }),
|
|
5302
|
-
children: t(
|
|
5303
|
-
"impersonation.list.errorBody",
|
|
5304
|
-
"Running impersonations still end on time; only this list is missing."
|
|
5305
|
-
)
|
|
5306
|
-
}
|
|
5307
|
-
);
|
|
5308
|
-
} else if (rows.length === 0) {
|
|
5309
|
-
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
5310
|
-
designSystem.EmptyStateLayout,
|
|
5311
|
-
{
|
|
5312
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyPermissions, { width: "16rem", height: "8rem" }),
|
|
5313
|
-
content: t(
|
|
5314
|
-
"impersonation.list.empty",
|
|
5315
|
-
"No impersonation is running. Start one from a user’s entry in the Content Manager."
|
|
5316
|
-
)
|
|
5317
|
-
}
|
|
5318
|
-
);
|
|
5319
|
-
} else if (width === 0 || width >= TABLE_MIN_WIDTH) {
|
|
5320
|
-
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", "data-impersonations-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: rows.length + 1, "aria-busy": refreshing, children: [
|
|
5321
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
5322
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.user", "User") }) }),
|
|
5323
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.startedBy", "Started by") }) }),
|
|
5324
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.reason", "Reason") }) }),
|
|
5325
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.ends", "Ends") }) }),
|
|
5326
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("impersonation.list.col.actions", "Actions") }) })
|
|
5327
|
-
] }) }),
|
|
5328
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-impersonation-row": "", children: [
|
|
5329
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
|
|
5330
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: label(row) }),
|
|
5331
|
-
kind(row)
|
|
5332
|
-
] }) }),
|
|
5333
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: startedBy(row) }) }),
|
|
5334
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5335
|
-
designSystem.Typography,
|
|
5336
|
-
{
|
|
5337
|
-
variant: "omega",
|
|
5338
|
-
textColor: "neutral800",
|
|
5339
|
-
tag: "p",
|
|
5340
|
-
style: { overflowWrap: "anywhere" },
|
|
5341
|
-
children: row.reason
|
|
5342
|
-
}
|
|
5343
|
-
) }),
|
|
5344
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: time(row.expiresAt) }),
|
|
5345
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: endAction(row) }) })
|
|
5346
|
-
] }, row.id)) })
|
|
5347
|
-
] }) });
|
|
5348
|
-
} else {
|
|
5349
|
-
content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-impersonations-list": "", children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "li", padding: 4, hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
|
|
5350
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
5351
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", alignItems: "center", children: [
|
|
5352
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: label(row) }),
|
|
5353
|
-
kind(row)
|
|
5354
|
-
] }),
|
|
5355
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5356
|
-
designSystem.Typography,
|
|
5357
|
-
{
|
|
5358
|
-
variant: "pi",
|
|
5359
|
-
textColor: "neutral800",
|
|
5360
|
-
tag: "p",
|
|
5361
|
-
style: { overflowWrap: "anywhere" },
|
|
5362
|
-
children: row.reason
|
|
5363
|
-
}
|
|
5364
|
-
),
|
|
5365
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("impersonation.list.summary", "{admin}, until {time}", {
|
|
5366
|
-
admin: startedBy(row),
|
|
5367
|
-
time: formatDate(row.expiresAt, { hour: "2-digit", minute: "2-digit" })
|
|
5368
|
-
}) })
|
|
5369
|
-
] }),
|
|
5370
|
-
/* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: endAction(row) })
|
|
5371
|
-
] }) }, row.id)) });
|
|
5372
|
-
}
|
|
5373
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5374
|
-
SectionCard.SectionCard,
|
|
5375
|
-
{
|
|
5376
|
-
id: "active-impersonations",
|
|
5377
|
-
title: t("impersonation.list.title", "Active impersonations"),
|
|
5378
|
-
subtitle: t(
|
|
5379
|
-
"impersonation.list.intro",
|
|
5380
|
-
"Each one ends by itself at the time shown. End stops it at once."
|
|
5381
|
-
),
|
|
5382
|
-
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5383
|
-
designSystem.Button,
|
|
5384
|
-
{
|
|
5385
|
-
ref: refreshRef,
|
|
5386
|
-
variant: "tertiary",
|
|
5387
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
|
|
5388
|
-
onClick: load,
|
|
5389
|
-
loading: refreshing && rows !== null,
|
|
5390
|
-
children: t("impersonation.list.refresh", "Refresh")
|
|
5391
|
-
}
|
|
5392
|
-
),
|
|
5393
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: widthRef, "aria-live": "polite", children: [
|
|
5394
|
-
error && rows !== null ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5395
|
-
index.PersistentAlert,
|
|
5396
|
-
{
|
|
5397
|
-
variant: "warning",
|
|
5398
|
-
closeLabel: t("common.close", "Close"),
|
|
5399
|
-
title: t("impersonation.list.refreshErrorTitle", "Not refreshed"),
|
|
5400
|
-
children: t(
|
|
5401
|
-
"impersonation.list.refreshError",
|
|
5402
|
-
"The list could not be refreshed. It shows the last known impersonations."
|
|
5403
|
-
)
|
|
5404
|
-
}
|
|
5405
|
-
) }) : null,
|
|
5406
|
-
content
|
|
5407
|
-
] })
|
|
5408
|
-
}
|
|
5409
|
-
);
|
|
5410
|
-
};
|
|
5411
5228
|
const ImpersonationTab = ({ form }) => {
|
|
5412
5229
|
const { t } = index.useSettingsTranslate();
|
|
5413
5230
|
const { settings, handleChange } = form;
|
|
5414
5231
|
const locked = form.canChangeProtected === false;
|
|
5415
5232
|
const {
|
|
5416
5233
|
isLoading,
|
|
5417
|
-
allowedActions: { canUsers, canAdmins }
|
|
5418
|
-
} = StrapiAdmin.useRBAC([
|
|
5234
|
+
allowedActions: { canUsers, canAdmins, canSignIn }
|
|
5235
|
+
} = StrapiAdmin.useRBAC([
|
|
5236
|
+
...index.pluginPermissions.impersonateUsers,
|
|
5237
|
+
...index.pluginPermissions.impersonateAdmins,
|
|
5238
|
+
...index.pluginPermissions.signInAsAdmin
|
|
5239
|
+
]);
|
|
5419
5240
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
5420
5241
|
/* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
|
|
5421
5242
|
"settings.impersonation.intro",
|
|
@@ -5440,7 +5261,7 @@ const ImpersonationTab = ({ form }) => {
|
|
|
5440
5261
|
) })
|
|
5441
5262
|
}
|
|
5442
5263
|
) }),
|
|
5443
|
-
!isLoading && (canUsers || canAdmins) ? /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard, {}) : null
|
|
5264
|
+
!isLoading && (canUsers || canAdmins || canSignIn) ? /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard.ActiveImpersonationsCard, {}) : null
|
|
5444
5265
|
] });
|
|
5445
5266
|
};
|
|
5446
5267
|
const INITIAL_SETTINGS = { ...SETTINGS_DEFAULTS, emailTemplates: fillMissingTemplates({}) };
|