strapi-plugin-magic-sessionmanager 4.19.0 → 4.20.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 +38 -0
- package/README.md +136 -1
- package/dist/admin/{Analytics-DSXe9BPn.mjs → Analytics-B-MVQ6dQ.mjs} +1 -1
- package/dist/admin/{Analytics-AzG-hPvn.js → Analytics-B5GnwMtH.js} +1 -1
- package/dist/admin/{App-7UDfLwMK.mjs → App-DzbP5VPQ.mjs} +107 -58
- package/dist/admin/{App-D08oGxy4.js → App-xBOmg4g9.js} +140 -91
- package/dist/admin/{OnlineUsersWidget-DIhJZ77w.mjs → OnlineUsersWidget-Bf3BICmx.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-CK0_o7Jk.js → OnlineUsersWidget-FuPPPCCV.js} +1 -1
- package/dist/admin/{Settings-DnNBDP1I.js → Settings-WRIXHLDa.js} +315 -330
- package/dist/admin/{Settings-CneNJppG.mjs → Settings-hpkloyO6.mjs} +250 -265
- package/dist/admin/{de-DvYUwhjB.mjs → de-Bzd14FzX.mjs} +64 -1
- package/dist/admin/{de-CJZtJdhC.js → de-Uqb30N5n.js} +64 -1
- package/dist/admin/{en-BZ2YkNIU.js → en-CDBcocLk.js} +64 -1
- package/dist/admin/{en-B8m9k-qd.mjs → en-DovyVwa5.mjs} +64 -1
- package/dist/admin/{es-DBH36rrX.mjs → es-BygJxl1J.mjs} +64 -1
- package/dist/admin/{es-BBsMtof1.js → es-DA1X0RPv.js} +64 -1
- package/dist/admin/{fr-Cw6nc38j.js → fr-CPPA27jW.js} +64 -1
- package/dist/admin/{fr-CLvB1rGe.mjs → fr-DONxL73-.mjs} +64 -1
- package/dist/admin/{index-5Zb3GVml.mjs → index-DsaGGK7x.mjs} +627 -61
- package/dist/admin/{index-BSUrdxxt.js → index-Q_D-5LlE.js} +612 -46
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-CjnMe7Z-.js → pt-BMuwyaan.js} +64 -1
- package/dist/admin/{pt-CVht14if.mjs → pt-D2yGNz2N.mjs} +64 -1
- package/dist/admin/settingsTabs--7IsqMdn.mjs +437 -0
- package/dist/admin/settingsTabs-Dxlevody.js +436 -0
- package/dist/server/index.js +1485 -19
- package/dist/server/index.mjs +1485 -19
- package/package.json +1 -1
- package/dist/admin/dashboardModel-CjU0V7Sx.js +0 -188
- package/dist/admin/dashboardModel-OyQ_39aF.mjs +0 -189
|
@@ -1,244 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, createContext, useContext, useMemo, useId, Fragment, useRef, useEffect, useCallback, useLayoutEffect } from "react";
|
|
3
3
|
import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSelect, SingleSelectOption, Accordion, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Modal, NumberInput, IconButton, Alert, Badge, Radio, Loader, EmptyStateLayout, Textarea, Dialog, Tag, Combobox, ComboboxOption, Divider, Tabs, Checkbox } from "@strapi/design-system";
|
|
4
4
|
import { useFetchClient, useNotification, useRBAC, ConfirmDialog, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
|
|
5
|
-
import { EyeStriked, Eye, Key, Duplicate, Plus, Pencil, Trash, Lock, ArrowClockwise, Cross, Download, Check } from "@strapi/icons";
|
|
5
|
+
import { EyeStriked, Eye, Key, Duplicate, Plus, Pencil, Trash, Lock, ArrowClockwise, Cross, Download, Check, SignOut } from "@strapi/icons";
|
|
6
6
|
import styled from "styled-components";
|
|
7
|
-
import { y as ReadableParagraphs,
|
|
8
|
-
import
|
|
7
|
+
import { y as ReadableParagraphs, z as useSettingsTranslate, l as logSafeAdminError, R as ReadableText, f as pluginId, n as isCancelledRequest, h as PersistentAlert, A as EqualGrid, u as useSessionFormatters, j as pluginPermissions, C as ConfirmAction, P as PropertyList, B as formatSessionDate, F as refocusIfLost, G as copyText, H as requireSuccessfulMutation, q as PageShell } from "./index-DsaGGK7x.mjs";
|
|
8
|
+
import "react-intl";
|
|
9
|
+
import { v as buildTabSearch, x as buildSelectOptions, u as useElementWidth, b as RowActions, s as shouldIsolateActionKey, y as SELECT_PRESETS, z as fieldHasError, B as getRiskAvailability, C as riskDependentControl, E as usesLocalDatabase, F as getErrorTab, G as buildSavePayload, q as SETTINGS_FIELD_LABELS, H as getVisibleSettingsTabs, I as resolveSettingsTab, J as getRevealScrollDelta, t as SETTINGS_TAB_LABELS } from "./settingsTabs--7IsqMdn.mjs";
|
|
9
10
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
10
|
-
import { u as useElementWidth, b as RowActions, s as shouldIsolateActionKey, o as getRiskAvailability, q as riskDependentControl } from "./dashboardModel-OyQ_39aF.mjs";
|
|
11
11
|
import { EmptyPermissions } from "@strapi/icons/symbols";
|
|
12
|
-
const SETTINGS_TAB_IDS = Object.freeze([
|
|
13
|
-
"sessions",
|
|
14
|
-
"login-protection",
|
|
15
|
-
"location-data",
|
|
16
|
-
"alerts",
|
|
17
|
-
"data-retention",
|
|
18
|
-
"admin-activity"
|
|
19
|
-
]);
|
|
20
|
-
const PERMISSION_GATED_TABS = Object.freeze(["admin-activity"]);
|
|
21
|
-
const DEFAULT_SETTINGS_TAB = "sessions";
|
|
22
|
-
const SETTINGS_TAB_LABELS = Object.freeze({
|
|
23
|
-
sessions: ["settings.config.tab.sessions", "Sessions"],
|
|
24
|
-
"login-protection": ["settings.config.tab.loginProtection", "Login protection"],
|
|
25
|
-
"location-data": ["settings.config.tab.locationData", "Location data"],
|
|
26
|
-
alerts: ["settings.config.tab.alerts", "Alerts"],
|
|
27
|
-
"data-retention": ["settings.config.tab.dataRetention", "Data and retention"],
|
|
28
|
-
"admin-activity": ["settings.config.tab.adminActivity", "Admin activity"]
|
|
29
|
-
});
|
|
30
|
-
const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
31
|
-
sessions: [
|
|
32
|
-
"inactivityTimeout",
|
|
33
|
-
"maxSessionAgeDays",
|
|
34
|
-
"lastSeenRateLimit",
|
|
35
|
-
"cleanupInterval",
|
|
36
|
-
"cleanupUseDbDirect",
|
|
37
|
-
"strictSessionEnforcement",
|
|
38
|
-
"sessionCreationGraceMs",
|
|
39
|
-
"maxSessionsPerUser",
|
|
40
|
-
"sessionLimitPolicy",
|
|
41
|
-
"endOtherSessionsOnPasswordChange",
|
|
42
|
-
"roleRules"
|
|
43
|
-
],
|
|
44
|
-
"login-protection": [
|
|
45
|
-
"maxFailedLogins",
|
|
46
|
-
"maxFailedLoginsPerAccount",
|
|
47
|
-
"lockoutWindowMinutes",
|
|
48
|
-
"lockoutDurationMinutes",
|
|
49
|
-
"lockoutTrustedAddresses",
|
|
50
|
-
"lockoutNotifyUser",
|
|
51
|
-
"recordUserSignInEvents",
|
|
52
|
-
"impossibleTravelEnabled",
|
|
53
|
-
"impossibleTravelSpeedKmh",
|
|
54
|
-
"impossibleTravelMinDistanceKm",
|
|
55
|
-
"impossibleTravelAction",
|
|
56
|
-
"trustedProxies",
|
|
57
|
-
"blockSuspiciousSessions",
|
|
58
|
-
"geoLookupFailureMode",
|
|
59
|
-
"enableGeofencing",
|
|
60
|
-
"allowedCountries",
|
|
61
|
-
"blockedCountries"
|
|
62
|
-
],
|
|
63
|
-
"location-data": [
|
|
64
|
-
"enableGeolocation",
|
|
65
|
-
"enableSecurityScoring",
|
|
66
|
-
"geoIpProvider",
|
|
67
|
-
"geoIpDatabasePath"
|
|
68
|
-
],
|
|
69
|
-
alerts: [
|
|
70
|
-
"enableEmailAlerts",
|
|
71
|
-
"alertOnSuspiciousLogin",
|
|
72
|
-
"alertOnNewLocation",
|
|
73
|
-
"alertOnVpnProxy",
|
|
74
|
-
"emailTemplates",
|
|
75
|
-
"enableWebhooks",
|
|
76
|
-
"discordWebhookUrl",
|
|
77
|
-
"slackWebhookUrl",
|
|
78
|
-
"alertOnNewDevice",
|
|
79
|
-
"alertOnImpossibleTravel",
|
|
80
|
-
"webhookEvents",
|
|
81
|
-
"genericWebhookEnabled",
|
|
82
|
-
"genericWebhookUrl",
|
|
83
|
-
"genericWebhookSecret"
|
|
84
|
-
],
|
|
85
|
-
"data-retention": ["retentionDays", "sessionIpAnonymize"],
|
|
86
|
-
"admin-activity": [
|
|
87
|
-
"adminSignInHistory",
|
|
88
|
-
"adminContentActivity",
|
|
89
|
-
"securityLogStoreIp",
|
|
90
|
-
"securityLogAnonymizeIp",
|
|
91
|
-
"securityLogGeoLookup",
|
|
92
|
-
"securityLogRetentionDays"
|
|
93
|
-
]
|
|
94
|
-
});
|
|
95
|
-
const PRESERVED_SETTINGS_KEYS = Object.freeze([
|
|
96
|
-
"rateLimitWriteMax",
|
|
97
|
-
"rateLimitReadMax",
|
|
98
|
-
"rateLimitWindowSeconds"
|
|
99
|
-
]);
|
|
100
|
-
const SETTINGS_FIELD_LABELS = Object.freeze({
|
|
101
|
-
inactivityTimeout: ["settings.config.sessions.inactivity.label", "Inactivity timeout"],
|
|
102
|
-
maxSessionAgeDays: ["settings.config.sessions.maxAge.label", "Maximum session age"],
|
|
103
|
-
lastSeenRateLimit: [
|
|
104
|
-
"settings.config.sessions.lastSeen.label",
|
|
105
|
-
'Update "Last active" at most every'
|
|
106
|
-
],
|
|
107
|
-
cleanupInterval: ["settings.config.sessions.idleCheck.label", "Run idle check every"],
|
|
108
|
-
cleanupUseDbDirect: ["settings.config.sessions.idleMethod.label", "Idle check method"],
|
|
109
|
-
strictSessionEnforcement: ["settings.config.token.check.label", "Strict token check"],
|
|
110
|
-
sessionCreationGraceMs: ["settings.config.token.grace.label", "Grace period after sign-in"],
|
|
111
|
-
maxFailedLogins: ["settings.config.failed.lockout.label", "Lock an IP address after"],
|
|
112
|
-
maxFailedLoginsPerAccount: ["settings.config.failed.account.label", "Lock an account after"],
|
|
113
|
-
lockoutWindowMinutes: ["settings.config.failed.window.label", "Count failed sign-ins within"],
|
|
114
|
-
lockoutDurationMinutes: ["settings.config.failed.duration.label", "Lock for"],
|
|
115
|
-
lockoutTrustedAddresses: ["settings.config.failed.trusted.label", "Trusted addresses"],
|
|
116
|
-
lockoutNotifyUser: [
|
|
117
|
-
"settings.config.failed.notify.label",
|
|
118
|
-
"Email the user when their account is locked"
|
|
119
|
-
],
|
|
120
|
-
recordUserSignInEvents: [
|
|
121
|
-
"settings.config.failed.record.label",
|
|
122
|
-
"Record failed and refused sign-ins"
|
|
123
|
-
],
|
|
124
|
-
maxSessionsPerUser: ["settings.config.sessionLimit.max.label", "Open sessions per user"],
|
|
125
|
-
sessionLimitPolicy: ["settings.config.sessionLimit.policy.label", "When the limit is reached"],
|
|
126
|
-
endOtherSessionsOnPasswordChange: [
|
|
127
|
-
"settings.config.passwordChange.label",
|
|
128
|
-
"End other sessions after a password change"
|
|
129
|
-
],
|
|
130
|
-
roleRules: ["settings.roleRules.title", "Different rules for some roles"],
|
|
131
|
-
impossibleTravelEnabled: ["settings.config.travel.enable.label", "Detect impossible travel"],
|
|
132
|
-
impossibleTravelSpeedKmh: ["settings.config.travel.speed.label", "Faster than"],
|
|
133
|
-
impossibleTravelMinDistanceKm: ["settings.config.travel.distance.label", "Over at least"],
|
|
134
|
-
impossibleTravelAction: ["settings.config.travel.action.label", "Then"],
|
|
135
|
-
alertOnNewDevice: ["settings.config.email.newDevice.label", "Sign-in from a new device"],
|
|
136
|
-
alertOnImpossibleTravel: ["settings.config.email.travel.label", "Impossible travel"],
|
|
137
|
-
webhookEvents: ["settings.webhookEvents.title", "Events to send"],
|
|
138
|
-
genericWebhookEnabled: ["settings.signedWebhook.enable.label", "Send to the signed webhook"],
|
|
139
|
-
genericWebhookUrl: ["settings.signedWebhook.url.label", "Webhook URL"],
|
|
140
|
-
genericWebhookSecret: ["settings.signedWebhook.secret.label", "Signing secret"],
|
|
141
|
-
sessionIpAnonymize: ["settings.config.privacy.shortIp.label", "Shorten IP addresses of sessions"],
|
|
142
|
-
trustedProxies: ["settings.config.clientIp.trustProxy.label", "Trust proxy headers"],
|
|
143
|
-
blockSuspiciousSessions: [
|
|
144
|
-
"settings.config.suspicious.reject.label",
|
|
145
|
-
"Reject suspicious sign-ins"
|
|
146
|
-
],
|
|
147
|
-
geoLookupFailureMode: [
|
|
148
|
-
"settings.config.suspicious.failureMode.label",
|
|
149
|
-
"If the location cannot be determined"
|
|
150
|
-
],
|
|
151
|
-
enableGeofencing: ["settings.config.countries.enable.label", "Use country rules"],
|
|
152
|
-
allowedCountries: ["settings.config.countries.list.label", "Countries"],
|
|
153
|
-
blockedCountries: ["settings.config.countries.list.label", "Countries"],
|
|
154
|
-
enableGeolocation: ["settings.config.lookup.enable.label", "IP location lookup"],
|
|
155
|
-
enableSecurityScoring: ["settings.config.lookup.scoring.label", "Security scoring"],
|
|
156
|
-
geoIpProvider: ["settings.config.provider.label", "Provider"],
|
|
157
|
-
geoIpDatabasePath: ["settings.config.database.fileName.label", "Database file name"],
|
|
158
|
-
enableEmailAlerts: ["settings.config.email.enable.label", "Send security emails"],
|
|
159
|
-
alertOnSuspiciousLogin: ["settings.config.email.suspicious.label", "Suspicious sign-in"],
|
|
160
|
-
alertOnNewLocation: ["settings.config.email.newCountry.label", "Sign-in from a new country"],
|
|
161
|
-
alertOnVpnProxy: ["settings.config.email.vpnProxy.label", "VPN or proxy"],
|
|
162
|
-
emailTemplates: ["settings.config.email.templates.field", "Email templates"],
|
|
163
|
-
enableWebhooks: ["settings.config.webhooks.enable.label", "Send team notifications"],
|
|
164
|
-
discordWebhookUrl: ["settings.config.webhooks.discord.label", "Discord webhook URL"],
|
|
165
|
-
slackWebhookUrl: ["settings.config.webhooks.slack.label", "Slack webhook URL"],
|
|
166
|
-
retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"],
|
|
167
|
-
adminSignInHistory: ["settings.config.adminActivity.signIns.label", "Record admin sign-ins"],
|
|
168
|
-
adminContentActivity: [
|
|
169
|
-
"settings.config.adminActivity.content.label",
|
|
170
|
-
"Record Content Manager activity"
|
|
171
|
-
],
|
|
172
|
-
securityLogStoreIp: ["settings.config.adminActivity.storeIp.label", "Store IP addresses"],
|
|
173
|
-
securityLogAnonymizeIp: [
|
|
174
|
-
"settings.config.adminActivity.anonymize.label",
|
|
175
|
-
"Anonymise the last part of IP addresses"
|
|
176
|
-
],
|
|
177
|
-
securityLogGeoLookup: [
|
|
178
|
-
"settings.config.adminActivity.geoLookup.label",
|
|
179
|
-
"Look up the location of security events"
|
|
180
|
-
],
|
|
181
|
-
securityLogRetentionDays: [
|
|
182
|
-
"settings.config.adminActivity.retention.label",
|
|
183
|
-
"Keep security events for"
|
|
184
|
-
]
|
|
185
|
-
});
|
|
186
|
-
const SELECT_PRESETS = Object.freeze({
|
|
187
|
-
inactivityTimeout: Object.freeze([5, 10, 15, 30, 60, 120]),
|
|
188
|
-
maxSessionAgeDays: Object.freeze([1, 7, 14, 30, 60, 90, 180, 365]),
|
|
189
|
-
lastSeenRateLimit: Object.freeze([10, 30, 60, 120, 300]),
|
|
190
|
-
cleanupInterval: Object.freeze([15, 30, 60, 120]),
|
|
191
|
-
sessionCreationGraceMs: Object.freeze([0, 2e3, 5e3, 1e4, 3e4]),
|
|
192
|
-
retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1]),
|
|
193
|
-
securityLogRetentionDays: Object.freeze([7, 30, 90, 180, 365])
|
|
194
|
-
});
|
|
195
|
-
function resolveSettingsTab(value, tabs = SETTINGS_TAB_IDS) {
|
|
196
|
-
const candidate = Array.isArray(value) ? value[0] : value;
|
|
197
|
-
return tabs.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
|
|
198
|
-
}
|
|
199
|
-
function getVisibleSettingsTabs(canViewAdminActivity) {
|
|
200
|
-
return SETTINGS_TAB_IDS.filter(
|
|
201
|
-
(tab) => canViewAdminActivity || !PERMISSION_GATED_TABS.includes(tab)
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
function buildTabSearch(search, tab) {
|
|
205
|
-
const params = new URLSearchParams(typeof search === "string" ? search : "");
|
|
206
|
-
params.set("tab", resolveSettingsTab(tab));
|
|
207
|
-
return `?${params.toString()}`;
|
|
208
|
-
}
|
|
209
|
-
function fieldHasError(errors, field) {
|
|
210
|
-
return Object.keys(errors || {}).some((path) => path === field || path.startsWith(`${field}.`));
|
|
211
|
-
}
|
|
212
|
-
function tabHasFieldErrors(errors, tab) {
|
|
213
|
-
return (SETTINGS_TAB_FIELDS[tab] || []).some((field) => fieldHasError(errors, field));
|
|
214
|
-
}
|
|
215
|
-
function getErrorTab(errors) {
|
|
216
|
-
return SETTINGS_TAB_IDS.find((tab) => tabHasFieldErrors(errors, tab));
|
|
217
|
-
}
|
|
218
|
-
function buildSelectOptions(presets, current) {
|
|
219
|
-
const options = presets.map((value) => ({ value, custom: false }));
|
|
220
|
-
const number = typeof current === "number" ? current : Number.parseInt(String(current ?? ""), 10);
|
|
221
|
-
if (Number.isInteger(number) && !presets.includes(number)) {
|
|
222
|
-
options.push({ value: number, custom: true });
|
|
223
|
-
}
|
|
224
|
-
return options;
|
|
225
|
-
}
|
|
226
|
-
function buildSavePayload(draft, saved) {
|
|
227
|
-
const payload = { ...draft || {} };
|
|
228
|
-
for (const key of PRESERVED_SETTINGS_KEYS) {
|
|
229
|
-
if (saved && Object.prototype.hasOwnProperty.call(saved, key)) payload[key] = saved[key];
|
|
230
|
-
}
|
|
231
|
-
return payload;
|
|
232
|
-
}
|
|
233
|
-
function usesLocalDatabase(provider) {
|
|
234
|
-
return provider === void 0 || provider === null || provider === "" || provider === "auto" || provider === "local-mmdb";
|
|
235
|
-
}
|
|
236
|
-
function getRevealScrollDelta(listRect, tabRect) {
|
|
237
|
-
if (!listRect || !tabRect) return 0;
|
|
238
|
-
if (tabRect.left < listRect.left - 0.5) return Math.round(tabRect.left - listRect.left);
|
|
239
|
-
if (tabRect.right > listRect.right + 0.5) return Math.round(tabRect.right - listRect.right);
|
|
240
|
-
return 0;
|
|
241
|
-
}
|
|
242
12
|
const FieldFrame = styled.div`
|
|
243
13
|
width: 100%;
|
|
244
14
|
min-width: 0;
|
|
@@ -516,18 +286,6 @@ const SecretTextInput = ({
|
|
|
516
286
|
}
|
|
517
287
|
);
|
|
518
288
|
};
|
|
519
|
-
function useSettingsTranslate() {
|
|
520
|
-
const { formatMessage, locale } = useIntl();
|
|
521
|
-
const t = useCallback(
|
|
522
|
-
(id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values),
|
|
523
|
-
[formatMessage]
|
|
524
|
-
);
|
|
525
|
-
const tError = useCallback(
|
|
526
|
-
(descriptor) => descriptor ? t(descriptor.messageId, descriptor.defaultMessage, descriptor.values) : void 0,
|
|
527
|
-
[t]
|
|
528
|
-
);
|
|
529
|
-
return { t, tError, locale };
|
|
530
|
-
}
|
|
531
289
|
const EnvPreview = styled(Box)`
|
|
532
290
|
overflow-wrap: anywhere;
|
|
533
291
|
|
|
@@ -920,8 +678,8 @@ function sortLocks(locks) {
|
|
|
920
678
|
return Number.isFinite(until) && until !== 0 ? until : String(a.id).localeCompare(b.id);
|
|
921
679
|
});
|
|
922
680
|
}
|
|
923
|
-
const TABLE_MIN_WIDTH$
|
|
924
|
-
const keepActionKeys$
|
|
681
|
+
const TABLE_MIN_WIDTH$2 = 640;
|
|
682
|
+
const keepActionKeys$2 = (event) => {
|
|
925
683
|
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
926
684
|
};
|
|
927
685
|
const EMPTY_DRAFT = Object.freeze({
|
|
@@ -1008,10 +766,10 @@ const RoleRulesSection = ({ form }) => {
|
|
|
1008
766
|
};
|
|
1009
767
|
const fieldError = (key) => showErrors ? tError(draftErrors[key]) : void 0;
|
|
1010
768
|
const availableRoles = (roles || []).filter((role) => !taken.includes(role.documentId));
|
|
1011
|
-
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$
|
|
769
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$2;
|
|
1012
770
|
const actions = (rule) => {
|
|
1013
771
|
const name = roleName(rule.role);
|
|
1014
|
-
return /* @__PURE__ */ jsxs(RowActions, { onKeyDown: keepActionKeys$
|
|
772
|
+
return /* @__PURE__ */ jsxs(RowActions, { onKeyDown: keepActionKeys$2, children: [
|
|
1015
773
|
/* @__PURE__ */ jsx(
|
|
1016
774
|
IconButton,
|
|
1017
775
|
{
|
|
@@ -2340,7 +2098,9 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
2340
2098
|
securityLogGeoLookup: false,
|
|
2341
2099
|
securityLogRetentionDays: 90,
|
|
2342
2100
|
...POLICY_FORM_DEFAULTS,
|
|
2343
|
-
...SIGNALS_FORM_DEFAULTS
|
|
2101
|
+
...SIGNALS_FORM_DEFAULTS,
|
|
2102
|
+
// Impersonation of app users (4.20), off by default.
|
|
2103
|
+
impersonationEnabled: false
|
|
2344
2104
|
});
|
|
2345
2105
|
const WRITE_ONLY_SETTINGS_KEYS = Object.freeze([
|
|
2346
2106
|
"discordWebhookUrl",
|
|
@@ -2465,8 +2225,8 @@ function getAdjustedFields(submitted, stored, previous) {
|
|
|
2465
2225
|
(key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
|
|
2466
2226
|
);
|
|
2467
2227
|
}
|
|
2468
|
-
const TABLE_MIN_WIDTH = 640;
|
|
2469
|
-
const keepActionKeys = (event) => {
|
|
2228
|
+
const TABLE_MIN_WIDTH$1 = 640;
|
|
2229
|
+
const keepActionKeys$1 = (event) => {
|
|
2470
2230
|
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2471
2231
|
};
|
|
2472
2232
|
const LockTarget = ({ lock }) => {
|
|
@@ -2586,7 +2346,7 @@ const LockedNowCard = () => {
|
|
|
2586
2346
|
}
|
|
2587
2347
|
};
|
|
2588
2348
|
const showActions = !permissionsLoading && canUnlock;
|
|
2589
|
-
const asTable = width === 0 || width >= TABLE_MIN_WIDTH;
|
|
2349
|
+
const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
|
|
2590
2350
|
const unlockAction = (lock) => showActions ? /* @__PURE__ */ jsx(
|
|
2591
2351
|
ConfirmAction,
|
|
2592
2352
|
{
|
|
@@ -2653,7 +2413,7 @@ const LockedNowCard = () => {
|
|
|
2653
2413
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(KindBadge, { kind: lock.kind }) }),
|
|
2654
2414
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
|
|
2655
2415
|
/* @__PURE__ */ jsx(Td, { children: ends(lock) }),
|
|
2656
|
-
showActions ? /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
|
|
2416
|
+
showActions ? /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(RowActions, { onKeyDown: keepActionKeys$1, children: unlockAction(lock) }) }) : null
|
|
2657
2417
|
] }, lock.id)) })
|
|
2658
2418
|
] }) });
|
|
2659
2419
|
} else {
|
|
@@ -2676,7 +2436,7 @@ const LockedNowCard = () => {
|
|
|
2676
2436
|
}) })
|
|
2677
2437
|
] })
|
|
2678
2438
|
] }),
|
|
2679
|
-
/* @__PURE__ */ jsx(RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
|
|
2439
|
+
/* @__PURE__ */ jsx(RowActions, { onKeyDown: keepActionKeys$1, children: unlockAction(lock) })
|
|
2680
2440
|
] })
|
|
2681
2441
|
},
|
|
2682
2442
|
lock.id
|
|
@@ -5438,15 +5198,239 @@ const AdminActivityTab = ({ form }) => {
|
|
|
5438
5198
|
)
|
|
5439
5199
|
] });
|
|
5440
5200
|
};
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5201
|
+
const TABLE_MIN_WIDTH = 720;
|
|
5202
|
+
const keepActionKeys = (event) => {
|
|
5203
|
+
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
5204
|
+
};
|
|
5205
|
+
const ActiveImpersonationsCard = () => {
|
|
5206
|
+
const { t } = useSettingsTranslate();
|
|
5207
|
+
const { get, post } = useFetchClient();
|
|
5208
|
+
const { toggleNotification } = useNotification();
|
|
5209
|
+
const { formatDate } = useSessionFormatters();
|
|
5210
|
+
const [widthRef, width] = useElementWidth();
|
|
5211
|
+
const [rows, setRows] = useState(null);
|
|
5212
|
+
const [error, setError] = useState(false);
|
|
5213
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
5214
|
+
const refreshRef = useRef(null);
|
|
5215
|
+
const requestRef = useRef(0);
|
|
5216
|
+
const apply = useCallback(async (request, pending) => {
|
|
5217
|
+
try {
|
|
5218
|
+
const { data } = await pending;
|
|
5219
|
+
if (request !== requestRef.current) return;
|
|
5220
|
+
if (!Array.isArray(data?.data)) throw new Error("Invalid impersonation list");
|
|
5221
|
+
setRows(data.data);
|
|
5222
|
+
setError(false);
|
|
5223
|
+
} catch (err) {
|
|
5224
|
+
if (isCancelledRequest(err) || request !== requestRef.current) return;
|
|
5225
|
+
logSafeAdminError("impersonation.list", err);
|
|
5226
|
+
setError(true);
|
|
5227
|
+
} finally {
|
|
5228
|
+
if (request === requestRef.current) setRefreshing(false);
|
|
5229
|
+
}
|
|
5230
|
+
}, []);
|
|
5231
|
+
const load = useCallback(() => {
|
|
5232
|
+
const request = ++requestRef.current;
|
|
5233
|
+
setRefreshing(true);
|
|
5234
|
+
return apply(request, get(`/${pluginId}/impersonation/active`));
|
|
5235
|
+
}, [apply, get]);
|
|
5236
|
+
useEffect(() => {
|
|
5237
|
+
apply(++requestRef.current, get(`/${pluginId}/impersonation/active`));
|
|
5238
|
+
}, [apply, get]);
|
|
5239
|
+
const end = async (row) => {
|
|
5240
|
+
try {
|
|
5241
|
+
await post(`/${pluginId}/impersonation/${row.id}/end`, {});
|
|
5242
|
+
toggleNotification({
|
|
5243
|
+
type: "success",
|
|
5244
|
+
message: t("impersonation.ended", "Impersonation ended.")
|
|
5245
|
+
});
|
|
5246
|
+
} catch (err) {
|
|
5247
|
+
logSafeAdminError("impersonation.end", err);
|
|
5248
|
+
toggleNotification({
|
|
5249
|
+
type: "danger",
|
|
5250
|
+
message: t("impersonation.error.end", "The impersonation could not be ended.")
|
|
5251
|
+
});
|
|
5252
|
+
throw err;
|
|
5253
|
+
} finally {
|
|
5254
|
+
await load();
|
|
5255
|
+
}
|
|
5256
|
+
};
|
|
5257
|
+
const endAction = (row) => /* @__PURE__ */ jsx(
|
|
5258
|
+
ConfirmAction,
|
|
5259
|
+
{
|
|
5260
|
+
fallbackFocusRef: refreshRef,
|
|
5261
|
+
title: t("impersonation.confirm.title", "End the impersonation of {user}?", {
|
|
5262
|
+
user: row.targetLabel
|
|
5263
|
+
}),
|
|
5264
|
+
body: t(
|
|
5265
|
+
"impersonation.confirm.body",
|
|
5266
|
+
"The short-lived sign-in stops working at once. This is recorded in the security log."
|
|
5267
|
+
),
|
|
5268
|
+
confirmLabel: t("impersonation.end", "End impersonation"),
|
|
5269
|
+
onConfirm: () => end(row),
|
|
5270
|
+
trigger: /* @__PURE__ */ jsx(
|
|
5271
|
+
IconButton,
|
|
5272
|
+
{
|
|
5273
|
+
variant: "ghost",
|
|
5274
|
+
label: t("impersonation.endLabel", "End impersonation of {user}", {
|
|
5275
|
+
user: row.targetLabel
|
|
5276
|
+
}),
|
|
5277
|
+
children: /* @__PURE__ */ jsx(SignOut, {})
|
|
5278
|
+
}
|
|
5279
|
+
)
|
|
5280
|
+
},
|
|
5281
|
+
row.id
|
|
5282
|
+
);
|
|
5283
|
+
const time = (iso) => /* @__PURE__ */ jsx(Typography, { tag: "time", dateTime: iso, variant: "omega", textColor: "neutral800", children: formatDate(iso, { hour: "2-digit", minute: "2-digit" }) });
|
|
5284
|
+
const startedBy = (row) => row.startedByYou ? t("impersonation.list.you", "You") : row.actorLabel || "—";
|
|
5285
|
+
let content;
|
|
5286
|
+
if (rows === null && !error) {
|
|
5287
|
+
content = /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("impersonation.list.loading", "Loading impersonations…") }) });
|
|
5288
|
+
} else if (error && rows === null) {
|
|
5289
|
+
content = /* @__PURE__ */ jsx(
|
|
5290
|
+
PersistentAlert,
|
|
5291
|
+
{
|
|
5292
|
+
variant: "danger",
|
|
5293
|
+
closeLabel: t("common.close", "Close"),
|
|
5294
|
+
title: t("impersonation.list.error", "Impersonations could not be loaded."),
|
|
5295
|
+
action: /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: load, children: t("common.tryAgain", "Try again") }),
|
|
5296
|
+
children: t(
|
|
5297
|
+
"impersonation.list.errorBody",
|
|
5298
|
+
"Running impersonations still end on time; only this list is missing."
|
|
5299
|
+
)
|
|
5300
|
+
}
|
|
5301
|
+
);
|
|
5302
|
+
} else if (rows.length === 0) {
|
|
5303
|
+
content = /* @__PURE__ */ jsx(
|
|
5304
|
+
EmptyStateLayout,
|
|
5305
|
+
{
|
|
5306
|
+
icon: /* @__PURE__ */ jsx(EmptyPermissions, { width: "16rem", height: "8rem" }),
|
|
5307
|
+
content: t(
|
|
5308
|
+
"impersonation.list.empty",
|
|
5309
|
+
"No impersonation is running. Start one from a user’s entry in the Content Manager."
|
|
5310
|
+
)
|
|
5311
|
+
}
|
|
5312
|
+
);
|
|
5313
|
+
} else if (width === 0 || width >= TABLE_MIN_WIDTH) {
|
|
5314
|
+
content = /* @__PURE__ */ jsx(Box, { hasRadius: true, borderColor: "neutral150", "data-impersonations-table": "", children: /* @__PURE__ */ jsxs(Table, { colCount: 5, rowCount: rows.length + 1, "aria-busy": refreshing, children: [
|
|
5315
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
5316
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.user", "User") }) }),
|
|
5317
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.startedBy", "Started by") }) }),
|
|
5318
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.reason", "Reason") }) }),
|
|
5319
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.ends", "Ends") }) }),
|
|
5320
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: t("impersonation.list.col.actions", "Actions") }) })
|
|
5321
|
+
] }) }),
|
|
5322
|
+
/* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxs(Tr, { "data-impersonation-row": "", children: [
|
|
5323
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }) }),
|
|
5324
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: startedBy(row) }) }),
|
|
5325
|
+
/* @__PURE__ */ jsx(Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsx(
|
|
5326
|
+
Typography,
|
|
5327
|
+
{
|
|
5328
|
+
variant: "omega",
|
|
5329
|
+
textColor: "neutral800",
|
|
5330
|
+
tag: "p",
|
|
5331
|
+
style: { overflowWrap: "anywhere" },
|
|
5332
|
+
children: row.reason
|
|
5333
|
+
}
|
|
5334
|
+
) }),
|
|
5335
|
+
/* @__PURE__ */ jsx(Td, { children: time(row.expiresAt) }),
|
|
5336
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(RowActions, { onKeyDown: keepActionKeys, children: endAction(row) }) })
|
|
5337
|
+
] }, row.id)) })
|
|
5338
|
+
] }) });
|
|
5339
|
+
} else {
|
|
5340
|
+
content = /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-impersonations-list": "", children: rows.map((row) => /* @__PURE__ */ jsx(Box, { tag: "li", padding: 4, hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
|
|
5341
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
5342
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }),
|
|
5343
|
+
/* @__PURE__ */ jsx(
|
|
5344
|
+
Typography,
|
|
5345
|
+
{
|
|
5346
|
+
variant: "pi",
|
|
5347
|
+
textColor: "neutral800",
|
|
5348
|
+
tag: "p",
|
|
5349
|
+
style: { overflowWrap: "anywhere" },
|
|
5350
|
+
children: row.reason
|
|
5351
|
+
}
|
|
5352
|
+
),
|
|
5353
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("impersonation.list.summary", "{admin}, until {time}", {
|
|
5354
|
+
admin: startedBy(row),
|
|
5355
|
+
time: formatDate(row.expiresAt, { hour: "2-digit", minute: "2-digit" })
|
|
5356
|
+
}) })
|
|
5357
|
+
] }),
|
|
5358
|
+
/* @__PURE__ */ jsx(RowActions, { onKeyDown: keepActionKeys, children: endAction(row) })
|
|
5359
|
+
] }) }, row.id)) });
|
|
5447
5360
|
}
|
|
5448
|
-
|
|
5449
|
-
|
|
5361
|
+
return /* @__PURE__ */ jsx(
|
|
5362
|
+
SectionCard,
|
|
5363
|
+
{
|
|
5364
|
+
id: "active-impersonations",
|
|
5365
|
+
title: t("impersonation.list.title", "Active impersonations"),
|
|
5366
|
+
subtitle: t(
|
|
5367
|
+
"impersonation.list.intro",
|
|
5368
|
+
"Each one ends by itself at the time shown. End stops it at once."
|
|
5369
|
+
),
|
|
5370
|
+
action: /* @__PURE__ */ jsx(
|
|
5371
|
+
Button,
|
|
5372
|
+
{
|
|
5373
|
+
ref: refreshRef,
|
|
5374
|
+
variant: "tertiary",
|
|
5375
|
+
startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}),
|
|
5376
|
+
onClick: load,
|
|
5377
|
+
loading: refreshing && rows !== null,
|
|
5378
|
+
children: t("impersonation.list.refresh", "Refresh")
|
|
5379
|
+
}
|
|
5380
|
+
),
|
|
5381
|
+
children: /* @__PURE__ */ jsxs("div", { ref: widthRef, "aria-live": "polite", children: [
|
|
5382
|
+
error && rows !== null ? /* @__PURE__ */ jsx(Box, { paddingBottom: 3, children: /* @__PURE__ */ jsx(
|
|
5383
|
+
PersistentAlert,
|
|
5384
|
+
{
|
|
5385
|
+
variant: "warning",
|
|
5386
|
+
closeLabel: t("common.close", "Close"),
|
|
5387
|
+
title: t("impersonation.list.refreshErrorTitle", "Not refreshed"),
|
|
5388
|
+
children: t(
|
|
5389
|
+
"impersonation.list.refreshError",
|
|
5390
|
+
"The list could not be refreshed. It shows the last known impersonations."
|
|
5391
|
+
)
|
|
5392
|
+
}
|
|
5393
|
+
) }) : null,
|
|
5394
|
+
content
|
|
5395
|
+
] })
|
|
5396
|
+
}
|
|
5397
|
+
);
|
|
5398
|
+
};
|
|
5399
|
+
const ImpersonationTab = ({ form }) => {
|
|
5400
|
+
const { t } = useSettingsTranslate();
|
|
5401
|
+
const { settings, handleChange } = form;
|
|
5402
|
+
const locked = form.canChangeProtected === false;
|
|
5403
|
+
const {
|
|
5404
|
+
isLoading,
|
|
5405
|
+
allowedActions: { canUsers }
|
|
5406
|
+
} = useRBAC(pluginPermissions.impersonateUsers);
|
|
5407
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
5408
|
+
/* @__PURE__ */ jsx(IntroText, { children: t(
|
|
5409
|
+
"settings.impersonation.intro",
|
|
5410
|
+
"Support staff can act as an app user for up to an hour to reproduce a problem, with a reason that is recorded. Who may do this is set per role under Settings > Roles > Session Manager."
|
|
5411
|
+
) }),
|
|
5412
|
+
locked ? /* @__PURE__ */ jsx(ProtectedNotice, {}) : null,
|
|
5413
|
+
/* @__PURE__ */ jsx(SectionCard, { title: t("settings.impersonation.title", "Impersonation of app users"), children: /* @__PURE__ */ jsx(
|
|
5414
|
+
SettingsToggleRow,
|
|
5415
|
+
{
|
|
5416
|
+
id: "impersonation-enabled",
|
|
5417
|
+
title: t("settings.impersonation.enable.label", "Allow impersonation"),
|
|
5418
|
+
description: t(
|
|
5419
|
+
"settings.impersonation.enable.hint",
|
|
5420
|
+
"Off by default. Turning it off ends every running impersonation at once."
|
|
5421
|
+
),
|
|
5422
|
+
checked: settings.impersonationEnabled === true,
|
|
5423
|
+
disabled: locked,
|
|
5424
|
+
onChange: (checked) => handleChange("impersonationEnabled", checked),
|
|
5425
|
+
children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
|
|
5426
|
+
"settings.impersonation.notice",
|
|
5427
|
+
"Acting as a person processes their personal data. Tell your users in the privacy notice, and in Germany check whether the works council must agree, because the log shows what each admin did."
|
|
5428
|
+
) })
|
|
5429
|
+
}
|
|
5430
|
+
) }),
|
|
5431
|
+
!isLoading && canUsers ? /* @__PURE__ */ jsx(ActiveImpersonationsCard, {}) : null
|
|
5432
|
+
] });
|
|
5433
|
+
};
|
|
5450
5434
|
const INITIAL_SETTINGS = { ...SETTINGS_DEFAULTS, emailTemplates: fillMissingTemplates({}) };
|
|
5451
5435
|
const BUILD_DATE_OPTIONS = Object.freeze({ dateStyle: "medium" });
|
|
5452
5436
|
const getServerMessage = (error) => {
|
|
@@ -5818,6 +5802,7 @@ const TAB_COMPONENTS = {
|
|
|
5818
5802
|
"location-data": LocationDataTab,
|
|
5819
5803
|
alerts: AlertsTab,
|
|
5820
5804
|
"data-retention": DataRetentionTab,
|
|
5805
|
+
impersonation: ImpersonationTab,
|
|
5821
5806
|
"admin-activity": AdminActivityTab
|
|
5822
5807
|
};
|
|
5823
5808
|
const DraftSync = ({ values }) => {
|