strapi-plugin-magic-sessionmanager 4.22.1 → 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 +31 -0
- package/README.md +116 -82
- package/dist/admin/ActiveImpersonationsCard-CbyOAlrL.mjs +396 -0
- package/dist/admin/ActiveImpersonationsCard-D1CVmV-w.js +395 -0
- package/dist/admin/{Analytics-CIHgaURb.mjs → Analytics-DGAHD19E.mjs} +1 -1
- package/dist/admin/{Analytics-B7BAjApz.js → Analytics-_WA68oHb.js} +1 -1
- package/dist/admin/{App-DJkJC06E.js → App-CfhAQ17e.js} +304 -104
- package/dist/admin/{App-CPE-CQGz.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-Dou2hxGY.mjs → OnlineUsersWidget-2u-fYMb7.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-CcjNfzzf.js → OnlineUsersWidget-CmBqFLAA.js} +1 -1
- package/dist/admin/{Settings--eEiHv_a.js → Settings-BBs2FDp7.js} +27 -229
- package/dist/admin/{Settings-h_exWUiI.mjs → Settings-CKDNGJhl.mjs} +19 -221
- package/dist/admin/{de-Wz5Emtrb.mjs → de-CK-HuY41.mjs} +42 -4
- package/dist/admin/{de-oBmcAcXj.js → de-CSRQPn6F.js} +42 -4
- package/dist/admin/{en-B1TN5F62.js → en-DCtAgGEa.js} +42 -4
- package/dist/admin/{en-B_1Ka64U.mjs → en-KZ5ajaAR.mjs} +42 -4
- package/dist/admin/{es-CVgw4zsj.mjs → es-B7k8taWV.mjs} +42 -4
- package/dist/admin/{es-Bb515J0p.js → es-CKT00l4K.js} +42 -4
- package/dist/admin/{fr-yDdwunmg.js → fr-B2EdBFSb.js} +42 -4
- package/dist/admin/{fr-0AgMxTFc.mjs → fr-Q2gmYqCn.mjs} +42 -4
- package/dist/admin/{index-DVQ7tdTC.mjs → index-BPbs1GyP.mjs} +365 -57
- package/dist/admin/{index-qtN2dOm4.js → index-Cho0XGZ1.js} +319 -11
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-BAB07LY-.js → pt-CcMUcqDy.js} +42 -4
- package/dist/admin/{pt-DtM74ffN.mjs → pt-CmxZTaf2.mjs} +42 -4
- package/dist/admin/useBreakpoint-CoBfu0Ov.js +62 -0
- package/dist/admin/useBreakpoint-CuyIc2qy.mjs +63 -0
- package/dist/server/index.js +867 -10
- package/dist/server/index.mjs +867 -10
- package/package.json +6 -2
- package/dist/admin/dashboardModel-DNT_l-Bk.js +0 -169
- package/dist/admin/dashboardModel-fApbKGay.mjs +0 -170
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useFetchClient, useNotification, useClipboard, useRBAC, useQueryParams, Pagination, BackButton, Page } from "@strapi/strapi/admin";
|
|
3
3
|
import { NavLink, Link as Link$1, Routes, Route } from "react-router-dom";
|
|
4
|
-
import {
|
|
4
|
+
import { useState, useRef, useId, useEffect, useMemo, useCallback, useLayoutEffect } from "react";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
|
-
import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Link, SimpleMenu, MenuItem, Grid, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Tooltip, SearchForm, Searchbar, TextButton, SingleSelect, SingleSelectOption, LinkButton, EmptyStateLayout, Badge, Tabs, Field, Textarea, Dialog } from "@strapi/design-system";
|
|
7
|
-
import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowRight, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut } from "@strapi/icons";
|
|
6
|
+
import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Link, SimpleMenu, MenuItem, Grid, Table, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Tooltip, SearchForm, Searchbar, TextButton, SingleSelect, SingleSelectOption, LinkButton, EmptyStateLayout, Badge, Tabs, Field, Textarea, Checkbox, Dialog } from "@strapi/design-system";
|
|
7
|
+
import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowRight, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, Key, SignOut, ExternalLink } from "@strapi/icons";
|
|
8
8
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
9
|
-
import styled
|
|
10
|
-
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as buildSignInParams, o as useEventList, q as SignInEventTable, r as PERIOD_OPTIONS, s as buildSignInCsv, v as SIGN_IN_FILTER_OPTIONS, w as buildActivityParams, x as buildActivityCsv, A as ActivityEventTable, y as ACTIVITY_ACTION_OPTIONS, z as ACTIVITY_ACTION_LABELS, B as downloadCsv, E as MAX_EVENT_EXPORT_ROWS, F as isCancelledRequest, G as RECENT_EVENT_LIMIT, H as buildUserActivityParams, I as RECENT_USER_EVENT_LIMIT, U as USER_ACTIVITY_API_PATH, J as USER_ACTIVITY_PAGE_PATH, K as UserEventTable, L as useElementWidth, N as SESSION_FILTER_OPTIONS, O as END_REASON_FILTER_OPTIONS, Q as PageShell, T as StatGrid, W as StatCard, X as buildSessionCsv, Y as buildSessionJson, Z as restoreDialogFocus, _ as requireSessionList, $ as getAdminStatusPresentation, a0 as getBadgeColors, a1 as useSettingsTranslate, a2 as useSecondsLeft, a3 as validateReason, a4 as REASON_MAX, a5 as formatClock, a6 as
|
|
11
|
-
import {
|
|
9
|
+
import styled from "styled-components";
|
|
10
|
+
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, u as useSessionFormatters, c as getSessionStatus, d as getDevicePresentation, i as isNativeOnlySession, e as getSessionEndReasonPresentation, D as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, f as pluginId, l as logSafeAdminError, h as PersistentAlert, R as ReadableText, j as pluginPermissions, M as MissingValue, V as ValueOrMissing, k as SESSION_STATES, m as SESSION_STATUS_PRESENTATION, n as buildSignInParams, o as useEventList, q as SignInEventTable, r as PERIOD_OPTIONS, s as buildSignInCsv, v as SIGN_IN_FILTER_OPTIONS, w as buildActivityParams, x as buildActivityCsv, A as ActivityEventTable, y as ACTIVITY_ACTION_OPTIONS, z as ACTIVITY_ACTION_LABELS, B as downloadCsv, E as MAX_EVENT_EXPORT_ROWS, F as isCancelledRequest, G as RECENT_EVENT_LIMIT, H as buildUserActivityParams, I as RECENT_USER_EVENT_LIMIT, U as USER_ACTIVITY_API_PATH, J as USER_ACTIVITY_PAGE_PATH, K as UserEventTable, L as useElementWidth, N as SESSION_FILTER_OPTIONS, O as END_REASON_FILTER_OPTIONS, Q as PageShell, T as StatGrid, W as StatCard, X as buildSessionCsv, Y as buildSessionJson, Z as restoreDialogFocus, _ as requireSessionList, $ as getAdminStatusPresentation, a0 as getBadgeColors, a1 as useSettingsTranslate, a2 as useSecondsLeft, a3 as validateReason, a4 as REASON_MAX, a5 as formatClock, a6 as landingUrl, a7 as parseAdminPanelQuery, a8 as buildAdminListParams, a9 as withIdentityPlaceholders, aa as ADMIN_FILTER_OPTIONS, ab as ADMIN_PAGE_SIZE_OPTIONS, ac as ADMIN_DEFAULT_PAGE_SIZE, ad as hasAdminFilters, ae as getSignOutErrorMessage, af as splitDuration, ag as parseActivityPageQuery, ah as EVENT_PAGE_SIZE, ai as ACTIVITY_PAGE_SIZE_OPTIONS, aj as ALL_ADMINS_FILTER_OPTIONS, ak as hasActivityPageFilters, al as parseUserActivityQuery, am as userText, an as buildUserActivityCsv, ao as USER_ACTIVITY_SETTINGS_PATH, ap as USER_ACTIVITY_FILTER_OPTIONS, aq as USER_ACTIVITY_FILTER_LABELS, ar as hasUserActivityFilters } from "./index-BPbs1GyP.mjs";
|
|
11
|
+
import { u as useBreakpoint } from "./useBreakpoint-CuyIc2qy.mjs";
|
|
12
|
+
import { i as isRiskSource, g as getSessionUserLabels, a as getUserEditPath, R as RISK_SETTINGS_PATH, b as RowActions, s as shouldIsolateActionKey, c as shouldRedispatchEscape, D as DASHBOARD_COMPACT_TABLE_COLUMNS, d as DASHBOARD_TABLE_COLUMNS, r as readDisclosureOpen, e as getBrowserStorage, w as writeDisclosureOpen, p as parseDashboardQuery, A as AUTO_REFRESH_INTERVAL_MS, f as pickFocusSessionId, h as encodeSearchQuery, j as shouldUseCompactTable, P as PAGE_SIZE_OPTIONS, k as DEFAULT_PAGE_SIZE, l as getExportDeviceInfo, m as getErrorStatus, n as hasActiveFilters, o as ActiveImpersonationsCard } from "./ActiveImpersonationsCard-CbyOAlrL.mjs";
|
|
12
13
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
13
14
|
const { formatMessage } = useIntl();
|
|
14
15
|
const key = reason || getSessionEndReason(session);
|
|
@@ -90,64 +91,6 @@ function readSessionStats(payload) {
|
|
|
90
91
|
stats.nativeOnlyAfterTracking = isCount$1(data?.nativeOnlyAfterTracking) ? data.nativeOnlyAfterTracking : null;
|
|
91
92
|
return stats;
|
|
92
93
|
}
|
|
93
|
-
const DS_BREAKPOINTS = Object.freeze({
|
|
94
|
-
small: "@media(min-width: 520px)",
|
|
95
|
-
medium: "@media(min-width: 768px)",
|
|
96
|
-
large: "@media(min-width: 1080px)"
|
|
97
|
-
});
|
|
98
|
-
const BREAKPOINT_ORDER = Object.freeze(["initial", "small", "medium", "large"]);
|
|
99
|
-
function mediaQueryFromBreakpoint(breakpoint) {
|
|
100
|
-
if (typeof breakpoint !== "string") return "";
|
|
101
|
-
const query = breakpoint.replace(/^\s*@media\s*/i, "").trim();
|
|
102
|
-
return /^\(.*\)$/.test(query) ? query : "";
|
|
103
|
-
}
|
|
104
|
-
function getBreakpointQueries(theme) {
|
|
105
|
-
const source = theme?.breakpoints || {};
|
|
106
|
-
return {
|
|
107
|
-
small: mediaQueryFromBreakpoint(source.small) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.small),
|
|
108
|
-
medium: mediaQueryFromBreakpoint(source.medium) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.medium),
|
|
109
|
-
large: mediaQueryFromBreakpoint(source.large) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.large)
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function resolveBreakpoint(matches = {}) {
|
|
113
|
-
if (matches.large) return "large";
|
|
114
|
-
if (matches.medium) return "medium";
|
|
115
|
-
if (matches.small) return "small";
|
|
116
|
-
return "initial";
|
|
117
|
-
}
|
|
118
|
-
function isBelowBreakpoint(current, target) {
|
|
119
|
-
return BREAKPOINT_ORDER.indexOf(current) < BREAKPOINT_ORDER.indexOf(target);
|
|
120
|
-
}
|
|
121
|
-
const readMatches = (queries) => {
|
|
122
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
123
|
-
return { small: true, medium: true, large: true };
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
small: window.matchMedia(queries.small).matches,
|
|
127
|
-
medium: window.matchMedia(queries.medium).matches,
|
|
128
|
-
large: window.matchMedia(queries.large).matches
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
function useBreakpoint() {
|
|
132
|
-
const theme = useTheme();
|
|
133
|
-
const queries = useMemo(() => getBreakpointQueries(theme), [theme]);
|
|
134
|
-
const [matches, setMatches] = useState(() => readMatches(queries));
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return void 0;
|
|
137
|
-
const lists = ["small", "medium", "large"].map((name) => window.matchMedia(queries[name]));
|
|
138
|
-
const update = () => setMatches(readMatches(queries));
|
|
139
|
-
update();
|
|
140
|
-
lists.forEach((list) => list.addEventListener?.("change", update));
|
|
141
|
-
return () => lists.forEach((list) => list.removeEventListener?.("change", update));
|
|
142
|
-
}, [queries]);
|
|
143
|
-
const breakpoint = resolveBreakpoint(matches);
|
|
144
|
-
return {
|
|
145
|
-
breakpoint,
|
|
146
|
-
isBelowSmall: isBelowBreakpoint(breakpoint, "small"),
|
|
147
|
-
isBelowMedium: isBelowBreakpoint(breakpoint, "medium"),
|
|
148
|
-
isBelowLarge: isBelowBreakpoint(breakpoint, "large")
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
94
|
const RISK_LEVEL_MESSAGES = Object.freeze({
|
|
152
95
|
none: Object.freeze({ messageId: "modal.security.risk.none", defaultMessage: "None" }),
|
|
153
96
|
low: Object.freeze({ messageId: "modal.security.risk.low", defaultMessage: "Low" }),
|
|
@@ -1712,7 +1655,8 @@ const SignInHistoryPanel = ({ admin }) => {
|
|
|
1712
1655
|
all: t("adminPanel.activity.filter.allEvents", "All events"),
|
|
1713
1656
|
succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
|
|
1714
1657
|
failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
|
|
1715
|
-
"signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs")
|
|
1658
|
+
"signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs"),
|
|
1659
|
+
impersonation: t("adminPanel.activity.filter.impersonation", "Impersonation")
|
|
1716
1660
|
};
|
|
1717
1661
|
return /* @__PURE__ */ jsx(
|
|
1718
1662
|
EventList,
|
|
@@ -2590,6 +2534,7 @@ const HomePage = () => {
|
|
|
2590
2534
|
};
|
|
2591
2535
|
const HIGHLIGHT_BADGE = { backgroundColor: "primary100", textColor: "neutral800" };
|
|
2592
2536
|
const offersPreview = (admin, canPreview) => Boolean(canPreview) && admin.self !== true && !(admin.roles || []).some((role) => role?.superAdmin === true);
|
|
2537
|
+
const offersSignIn = (admin, canSignIn) => offersPreview(admin, canSignIn) && (admin.account === void 0 || admin.account === "active");
|
|
2593
2538
|
const keepActionKeys = (event) => {
|
|
2594
2539
|
if (shouldIsolateActionKey(event.key, true)) event.stopPropagation();
|
|
2595
2540
|
};
|
|
@@ -2641,6 +2586,9 @@ const AdminTable = ({
|
|
|
2641
2586
|
onSignOutEverywhere,
|
|
2642
2587
|
canPreview,
|
|
2643
2588
|
onPreview,
|
|
2589
|
+
canSignIn,
|
|
2590
|
+
signInUnavailable,
|
|
2591
|
+
onSignIn,
|
|
2644
2592
|
busy
|
|
2645
2593
|
}) => {
|
|
2646
2594
|
const t = useT$2();
|
|
@@ -2678,13 +2626,24 @@ const AdminTable = ({
|
|
|
2678
2626
|
offersPreview(admin, canPreview) ? /* @__PURE__ */ jsx(
|
|
2679
2627
|
IconButton,
|
|
2680
2628
|
{
|
|
2681
|
-
label: t("adminPanel.actions.
|
|
2629
|
+
label: t("adminPanel.actions.viewPermissions", "View permissions of {name}", {
|
|
2682
2630
|
name: admin.name || `#${admin.id}`
|
|
2683
2631
|
}),
|
|
2684
2632
|
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2685
2633
|
children: /* @__PURE__ */ jsx(User, {})
|
|
2686
2634
|
}
|
|
2687
2635
|
) : null,
|
|
2636
|
+
offersSignIn(admin, canSignIn) ? /* @__PURE__ */ jsx(
|
|
2637
|
+
IconButton,
|
|
2638
|
+
{
|
|
2639
|
+
label: signInUnavailable || t("adminPanel.actions.signInAs", "Sign in as {name}", {
|
|
2640
|
+
name: admin.name || `#${admin.id}`
|
|
2641
|
+
}),
|
|
2642
|
+
disabled: Boolean(signInUnavailable),
|
|
2643
|
+
onClick: (event) => onSignIn?.(admin, event.currentTarget),
|
|
2644
|
+
children: /* @__PURE__ */ jsx(Key, {})
|
|
2645
|
+
}
|
|
2646
|
+
) : null,
|
|
2688
2647
|
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsx(
|
|
2689
2648
|
IconButton,
|
|
2690
2649
|
{
|
|
@@ -2713,7 +2672,10 @@ const AdminCardList = ({
|
|
|
2713
2672
|
onView,
|
|
2714
2673
|
onSignOutEverywhere,
|
|
2715
2674
|
canPreview,
|
|
2716
|
-
onPreview
|
|
2675
|
+
onPreview,
|
|
2676
|
+
canSignIn,
|
|
2677
|
+
signInUnavailable,
|
|
2678
|
+
onSignIn
|
|
2717
2679
|
}) => {
|
|
2718
2680
|
const t = useT$2();
|
|
2719
2681
|
return /* @__PURE__ */ jsx(
|
|
@@ -2764,11 +2726,29 @@ const AdminCardList = ({
|
|
|
2764
2726
|
variant: "secondary",
|
|
2765
2727
|
startIcon: /* @__PURE__ */ jsx(User, {}),
|
|
2766
2728
|
onClick: (event) => onPreview?.(admin, event.currentTarget),
|
|
2767
|
-
"aria-label": t(
|
|
2729
|
+
"aria-label": t(
|
|
2730
|
+
"adminPanel.actions.viewPermissions",
|
|
2731
|
+
"View permissions of {name}",
|
|
2732
|
+
{
|
|
2733
|
+
name: admin.name || `#${admin.id}`
|
|
2734
|
+
}
|
|
2735
|
+
),
|
|
2736
|
+
flex: "1 1 auto",
|
|
2737
|
+
children: t("adminPanel.actions.viewPermissionsShort", "View permissions")
|
|
2738
|
+
}
|
|
2739
|
+
) : null,
|
|
2740
|
+
offersSignIn(admin, canSignIn) ? /* @__PURE__ */ jsx(
|
|
2741
|
+
Button,
|
|
2742
|
+
{
|
|
2743
|
+
variant: "secondary",
|
|
2744
|
+
startIcon: /* @__PURE__ */ jsx(Key, {}),
|
|
2745
|
+
disabled: Boolean(signInUnavailable),
|
|
2746
|
+
onClick: (event) => onSignIn?.(admin, event.currentTarget),
|
|
2747
|
+
"aria-label": signInUnavailable || t("adminPanel.actions.signInAs", "Sign in as {name}", {
|
|
2768
2748
|
name: admin.name || `#${admin.id}`
|
|
2769
2749
|
}),
|
|
2770
2750
|
flex: "1 1 auto",
|
|
2771
|
-
children: t("adminPanel.actions.
|
|
2751
|
+
children: t("adminPanel.actions.signInAsShort", "Sign in as")
|
|
2772
2752
|
}
|
|
2773
2753
|
) : null,
|
|
2774
2754
|
canRevoke && admin.canSignOut ? /* @__PURE__ */ jsx(
|
|
@@ -3009,7 +2989,7 @@ const AdminSessionsModal = ({
|
|
|
3009
2989
|
] }) });
|
|
3010
2990
|
};
|
|
3011
2991
|
const ADMIN_PREVIEW_DURATIONS = Object.freeze([15, 30]);
|
|
3012
|
-
const REFUSALS = Object.freeze({
|
|
2992
|
+
const REFUSALS$1 = Object.freeze({
|
|
3013
2993
|
disabled: ["impersonation.error.disabled", "Impersonation is turned off in the settings."],
|
|
3014
2994
|
self: ["impersonation.preview.error.self", "You cannot view yourself as another admin."],
|
|
3015
2995
|
"super-admin": [
|
|
@@ -3109,8 +3089,8 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
|
|
|
3109
3089
|
"Too many impersonations were started. Try again in a few minutes."
|
|
3110
3090
|
)
|
|
3111
3091
|
);
|
|
3112
|
-
} else if (REFUSALS[code]) {
|
|
3113
|
-
setFailure(t(...REFUSALS[code]));
|
|
3092
|
+
} else if (REFUSALS$1[code]) {
|
|
3093
|
+
setFailure(t(...REFUSALS$1[code]));
|
|
3114
3094
|
} else {
|
|
3115
3095
|
logSafeAdminError("impersonation.preview", err);
|
|
3116
3096
|
setFailure(t("impersonation.preview.error.start", "The preview could not be opened."));
|
|
@@ -3148,7 +3128,9 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
|
|
|
3148
3128
|
onClose();
|
|
3149
3129
|
};
|
|
3150
3130
|
return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: (open) => open ? null : close(), children: /* @__PURE__ */ jsxs(Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
|
|
3151
|
-
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: t("impersonation.preview.title", "
|
|
3131
|
+
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: t("impersonation.preview.title", "Permissions of {name}", {
|
|
3132
|
+
name: name || `#${admin.id}`
|
|
3133
|
+
}) }) }),
|
|
3152
3134
|
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
3153
3135
|
failure ? /* @__PURE__ */ jsx(PersistentAlert, { variant: "danger", closeLabel: t("common.close", "Close"), children: failure }) : null,
|
|
3154
3136
|
!result ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -3278,6 +3260,200 @@ const PreviewAdminModal = ({ admin, onClose, onCloseAutoFocus, onChanged }) => {
|
|
|
3278
3260
|
] }) })
|
|
3279
3261
|
] }) });
|
|
3280
3262
|
};
|
|
3263
|
+
const REFUSALS = Object.freeze({
|
|
3264
|
+
disabled: ["impersonation.error.disabled", "Impersonation is turned off in the settings."],
|
|
3265
|
+
unsupported: [
|
|
3266
|
+
"impersonation.signIn.error.unsupported",
|
|
3267
|
+
"Signing in as another admin is not available on this Strapi version."
|
|
3268
|
+
],
|
|
3269
|
+
self: ["impersonation.signIn.error.self", "You cannot sign in as yourself."],
|
|
3270
|
+
"super-admin": ["impersonation.signIn.error.superAdmin", "You cannot sign in as a Super Admin."],
|
|
3271
|
+
"not-subset": [
|
|
3272
|
+
"impersonation.signIn.error.notSubset",
|
|
3273
|
+
"This admin has permissions that you do not have, so you cannot sign in as them."
|
|
3274
|
+
],
|
|
3275
|
+
inactive: ["impersonation.signIn.error.inactive", "This admin account is not active."],
|
|
3276
|
+
"already-active": [
|
|
3277
|
+
"impersonation.signIn.error.alreadyActive",
|
|
3278
|
+
"Someone is already signed in as this admin. End that impersonation first."
|
|
3279
|
+
],
|
|
3280
|
+
nested: [
|
|
3281
|
+
"impersonation.signIn.error.nested",
|
|
3282
|
+
"You cannot start an impersonation while impersonating."
|
|
3283
|
+
],
|
|
3284
|
+
"api-token": ["impersonation.error.apiToken", "API tokens cannot impersonate."]
|
|
3285
|
+
});
|
|
3286
|
+
const currentAdminBase = () => {
|
|
3287
|
+
const path = window.location.pathname;
|
|
3288
|
+
const index = path.indexOf(`/plugins/${pluginId}`);
|
|
3289
|
+
return index >= 0 ? path.slice(0, index) : "/admin";
|
|
3290
|
+
};
|
|
3291
|
+
const unsupportedText = (support, t) => {
|
|
3292
|
+
if (!support || support.supported) return null;
|
|
3293
|
+
if (support.reason === "token-lifespan") {
|
|
3294
|
+
return t(
|
|
3295
|
+
"impersonation.signIn.unsupported.lifespan",
|
|
3296
|
+
"Not available: the admin access token lifespan is shorter than 15 minutes."
|
|
3297
|
+
);
|
|
3298
|
+
}
|
|
3299
|
+
return t(
|
|
3300
|
+
"impersonation.signIn.unsupported.version",
|
|
3301
|
+
"Not available on Strapi {version}: this plugin release was tested with Strapi 5.50 to 5.64. Update the plugin to use it.",
|
|
3302
|
+
{ version: support.version || "?" }
|
|
3303
|
+
);
|
|
3304
|
+
};
|
|
3305
|
+
const SignInAsAdminModal = ({ admin, support, onClose, onCloseAutoFocus, onChanged }) => {
|
|
3306
|
+
const { t, tError } = useSettingsTranslate();
|
|
3307
|
+
const { post } = useFetchClient();
|
|
3308
|
+
const durations = support?.durations?.length ? support.durations : [15];
|
|
3309
|
+
const [reason, setReason] = useState("");
|
|
3310
|
+
const [minutes, setMinutes] = useState(durations[0]);
|
|
3311
|
+
const [allowChanges, setAllowChanges] = useState(false);
|
|
3312
|
+
const [touched, setTouched] = useState(false);
|
|
3313
|
+
const [pending, setPending] = useState(false);
|
|
3314
|
+
const [failure, setFailure] = useState(null);
|
|
3315
|
+
const [handoff, setHandoff] = useState(null);
|
|
3316
|
+
const allowHintId = useId();
|
|
3317
|
+
const reasonError = validateReason(reason);
|
|
3318
|
+
const unsupported = unsupportedText(support, t);
|
|
3319
|
+
const name = admin.name || `#${admin.id}`;
|
|
3320
|
+
const start = async () => {
|
|
3321
|
+
setTouched(true);
|
|
3322
|
+
if (reasonError || unsupported) return;
|
|
3323
|
+
setPending(true);
|
|
3324
|
+
setFailure(null);
|
|
3325
|
+
try {
|
|
3326
|
+
const { data } = await post(`/${pluginId}/impersonation/admins/${admin.id}/sign-in`, {
|
|
3327
|
+
reason: reason.trim(),
|
|
3328
|
+
durationMinutes: minutes,
|
|
3329
|
+
allowChanges
|
|
3330
|
+
});
|
|
3331
|
+
setHandoff(data?.data?.handoff || null);
|
|
3332
|
+
onChanged?.();
|
|
3333
|
+
} catch (err) {
|
|
3334
|
+
if (isCancelledRequest(err)) return;
|
|
3335
|
+
const response = err?.response;
|
|
3336
|
+
const code = response?.data?.error?.details?.reason;
|
|
3337
|
+
if (response?.status === 429) {
|
|
3338
|
+
setFailure(
|
|
3339
|
+
t(
|
|
3340
|
+
"impersonation.error.rateLimited",
|
|
3341
|
+
"Too many impersonations were started. Try again in a few minutes."
|
|
3342
|
+
)
|
|
3343
|
+
);
|
|
3344
|
+
} else if (REFUSALS[code]) {
|
|
3345
|
+
setFailure(t(...REFUSALS[code]));
|
|
3346
|
+
} else {
|
|
3347
|
+
logSafeAdminError("impersonation.signIn", err);
|
|
3348
|
+
setFailure(t("impersonation.signIn.error.start", "The sign-in could not be started."));
|
|
3349
|
+
}
|
|
3350
|
+
} finally {
|
|
3351
|
+
setPending(false);
|
|
3352
|
+
}
|
|
3353
|
+
};
|
|
3354
|
+
const href = handoff ? landingUrl(currentAdminBase(), handoff) : null;
|
|
3355
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: (open) => open ? null : onClose(), children: /* @__PURE__ */ jsxs(Modal.Content, { onCloseAutoFocus, "aria-describedby": void 0, children: [
|
|
3356
|
+
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: t("common.close", "Close"), children: /* @__PURE__ */ jsx(Modal.Title, { children: t("impersonation.signIn.title", "Sign in as {name}", { name }) }) }),
|
|
3357
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
3358
|
+
failure ? /* @__PURE__ */ jsx(PersistentAlert, { variant: "danger", closeLabel: t("common.close", "Close"), children: failure }) : null,
|
|
3359
|
+
unsupported ? /* @__PURE__ */ jsx(PersistentAlert, { variant: "default", closeLabel: t("common.close", "Close"), children: unsupported }) : null,
|
|
3360
|
+
!handoff ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3361
|
+
/* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
|
|
3362
|
+
"impersonation.signIn.intro",
|
|
3363
|
+
"Opens a new tab signed in as this admin, with their menu and permissions. Your other tabs stay signed in as you. The start, the end and every change are recorded in the security log."
|
|
3364
|
+
) }),
|
|
3365
|
+
/* @__PURE__ */ jsxs(
|
|
3366
|
+
Field.Root,
|
|
3367
|
+
{
|
|
3368
|
+
name: "reason",
|
|
3369
|
+
required: true,
|
|
3370
|
+
error: touched && reasonError ? tError(reasonError) : void 0,
|
|
3371
|
+
hint: t("impersonation.preview.reason.hint", "Stored in the security log."),
|
|
3372
|
+
children: [
|
|
3373
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("impersonation.reason.label", "Reason") }),
|
|
3374
|
+
/* @__PURE__ */ jsx(
|
|
3375
|
+
Textarea,
|
|
3376
|
+
{
|
|
3377
|
+
value: reason,
|
|
3378
|
+
maxLength: REASON_MAX,
|
|
3379
|
+
placeholder: t("impersonation.reason.placeholder", "For example: ticket 4711"),
|
|
3380
|
+
onChange: (event) => setReason(event.target.value),
|
|
3381
|
+
onBlur: () => setTouched(true)
|
|
3382
|
+
}
|
|
3383
|
+
),
|
|
3384
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
3385
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
3386
|
+
]
|
|
3387
|
+
}
|
|
3388
|
+
),
|
|
3389
|
+
/* @__PURE__ */ jsxs(Field.Root, { name: "durationMinutes", children: [
|
|
3390
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("impersonation.duration.label", "Duration") }),
|
|
3391
|
+
/* @__PURE__ */ jsx(
|
|
3392
|
+
SingleSelect,
|
|
3393
|
+
{
|
|
3394
|
+
value: String(minutes),
|
|
3395
|
+
onChange: (value) => setMinutes(Number(value)),
|
|
3396
|
+
children: durations.map((value) => /* @__PURE__ */ jsx(SingleSelectOption, { value: String(value), children: t(
|
|
3397
|
+
"impersonation.duration.minutes",
|
|
3398
|
+
"{count, plural, one {# minute} other {# minutes}}",
|
|
3399
|
+
{ count: value }
|
|
3400
|
+
) }, value))
|
|
3401
|
+
}
|
|
3402
|
+
)
|
|
3403
|
+
] }),
|
|
3404
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
3405
|
+
/* @__PURE__ */ jsx(
|
|
3406
|
+
Checkbox,
|
|
3407
|
+
{
|
|
3408
|
+
checked: allowChanges,
|
|
3409
|
+
"aria-describedby": allowHintId,
|
|
3410
|
+
onCheckedChange: (checked) => setAllowChanges(checked === true),
|
|
3411
|
+
children: t("impersonation.signIn.allowChanges", "Allow changes")
|
|
3412
|
+
}
|
|
3413
|
+
),
|
|
3414
|
+
/* @__PURE__ */ jsx(Typography, { id: allowHintId, variant: "pi", textColor: "neutral600", children: t(
|
|
3415
|
+
"impersonation.signIn.allowChanges.hint",
|
|
3416
|
+
"Off: the tab is read-only. Their account, password, sessions, admin users, roles and API tokens can never be changed."
|
|
3417
|
+
) })
|
|
3418
|
+
] }),
|
|
3419
|
+
allowChanges ? /* @__PURE__ */ jsx(PersistentAlert, { variant: "warning", closeLabel: t("common.close", "Close"), children: t(
|
|
3420
|
+
"impersonation.signIn.allowChanges.warning",
|
|
3421
|
+
'Changes you make will appear in Strapi as made by {name} (for example "Last edited by"). The security log records you as the person who made them.',
|
|
3422
|
+
{ name }
|
|
3423
|
+
) }) : null
|
|
3424
|
+
] }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 3, "data-sign-in-ready": "", children: [
|
|
3425
|
+
/* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral800", tag: "p", children: t(
|
|
3426
|
+
"impersonation.signIn.ready",
|
|
3427
|
+
"Ready. Open the tab within one minute; the link works once. End the impersonation from the bar at the top of that tab, or from this page."
|
|
3428
|
+
) }),
|
|
3429
|
+
/* @__PURE__ */ jsx(
|
|
3430
|
+
LinkButton,
|
|
3431
|
+
{
|
|
3432
|
+
href,
|
|
3433
|
+
isExternal: true,
|
|
3434
|
+
endIcon: /* @__PURE__ */ jsx(ExternalLink, {}),
|
|
3435
|
+
size: "L",
|
|
3436
|
+
onClick: () => window.setTimeout(onClose, 0),
|
|
3437
|
+
children: t("impersonation.signIn.open", "Open tab signed in as {name}", { name })
|
|
3438
|
+
}
|
|
3439
|
+
)
|
|
3440
|
+
] })
|
|
3441
|
+
] }) }),
|
|
3442
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
3443
|
+
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: handoff ? t("common.close", "Close") : t("common.cancel", "Cancel") }) }),
|
|
3444
|
+
!handoff ? /* @__PURE__ */ jsx(
|
|
3445
|
+
Button,
|
|
3446
|
+
{
|
|
3447
|
+
variant: allowChanges ? "danger" : "default",
|
|
3448
|
+
onClick: start,
|
|
3449
|
+
loading: pending,
|
|
3450
|
+
disabled: Boolean(unsupported),
|
|
3451
|
+
children: t("impersonation.signIn.start", "Start sign-in")
|
|
3452
|
+
}
|
|
3453
|
+
) : null
|
|
3454
|
+
] })
|
|
3455
|
+
] }) });
|
|
3456
|
+
};
|
|
3281
3457
|
const SETTINGS_USERS_PATH = "/settings/users";
|
|
3282
3458
|
const PaginationTargets$2 = styled.div`
|
|
3283
3459
|
nav a {
|
|
@@ -3311,8 +3487,13 @@ const AdminPanelPage = () => {
|
|
|
3311
3487
|
const {
|
|
3312
3488
|
allowedActions: { canAdmins: canPreviewAdmins }
|
|
3313
3489
|
} = useRBAC(pluginPermissions.impersonateAdmins);
|
|
3490
|
+
const {
|
|
3491
|
+
allowedActions: { canSignIn: canSignInAsAdmin }
|
|
3492
|
+
} = useRBAC(pluginPermissions.signInAsAdmin);
|
|
3314
3493
|
const [impersonationEnabled, setImpersonationEnabled] = useState(false);
|
|
3494
|
+
const [signInSupport, setSignInSupport] = useState(null);
|
|
3315
3495
|
const [previewTarget, setPreviewTarget] = useState(null);
|
|
3496
|
+
const [signInTarget, setSignInTarget] = useState(null);
|
|
3316
3497
|
const [admins, setAdmins] = useState([]);
|
|
3317
3498
|
const [meta, setMeta] = useState(null);
|
|
3318
3499
|
const [loading, setLoading] = useState(true);
|
|
@@ -3329,17 +3510,19 @@ const AdminPanelPage = () => {
|
|
|
3329
3510
|
const hasLoadedRef = useRef(false);
|
|
3330
3511
|
const openerRef = useRef(null);
|
|
3331
3512
|
useEffect(() => {
|
|
3332
|
-
if (!canPreviewAdmins) return void 0;
|
|
3513
|
+
if (!canPreviewAdmins && !canSignInAsAdmin) return void 0;
|
|
3333
3514
|
let current = true;
|
|
3334
3515
|
get(`/${pluginId}/impersonation/status`).then(({ data }) => {
|
|
3335
|
-
if (current)
|
|
3516
|
+
if (!current) return;
|
|
3517
|
+
setImpersonationEnabled(data?.data?.enabled === true);
|
|
3518
|
+
setSignInSupport(data?.data?.adminSignIn || null);
|
|
3336
3519
|
}).catch((err) => {
|
|
3337
3520
|
if (!isCancelledRequest(err)) logSafeAdminError("impersonation.status", err);
|
|
3338
3521
|
});
|
|
3339
3522
|
return () => {
|
|
3340
3523
|
current = false;
|
|
3341
3524
|
};
|
|
3342
|
-
}, [canPreviewAdmins, get]);
|
|
3525
|
+
}, [canPreviewAdmins, canSignInAsAdmin, get]);
|
|
3343
3526
|
const confirmReturnRef = useRef(null);
|
|
3344
3527
|
const captionRef = useRef(null);
|
|
3345
3528
|
const pageRef = useRef(null);
|
|
@@ -3560,6 +3743,12 @@ const AdminPanelPage = () => {
|
|
|
3560
3743
|
openerRef.current = trigger;
|
|
3561
3744
|
setPreviewTarget({ id: admin.id, name: admin.name });
|
|
3562
3745
|
},
|
|
3746
|
+
canSignIn: Boolean(canSignInAsAdmin) && impersonationEnabled,
|
|
3747
|
+
signInUnavailable: unsupportedText(signInSupport, t),
|
|
3748
|
+
onSignIn: (admin, trigger) => {
|
|
3749
|
+
openerRef.current = trigger;
|
|
3750
|
+
setSignInTarget({ id: admin.id, name: admin.name });
|
|
3751
|
+
},
|
|
3563
3752
|
busy: refreshing
|
|
3564
3753
|
};
|
|
3565
3754
|
const policy = meta?.policy;
|
|
@@ -3793,6 +3982,7 @@ const AdminPanelPage = () => {
|
|
|
3793
3982
|
}
|
|
3794
3983
|
)
|
|
3795
3984
|
] }) : null,
|
|
3985
|
+
showData && impersonationEnabled && (canSignInAsAdmin || canPreviewAdmins) ? /* @__PURE__ */ jsx(ActiveImpersonationsCard, {}) : null,
|
|
3796
3986
|
showData && canViewActivity ? /* @__PURE__ */ jsx(
|
|
3797
3987
|
RecentSignInActivity,
|
|
3798
3988
|
{
|
|
@@ -3825,6 +4015,15 @@ const AdminPanelPage = () => {
|
|
|
3825
4015
|
onCloseAutoFocus: (event) => restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
|
|
3826
4016
|
}
|
|
3827
4017
|
) : null,
|
|
4018
|
+
signInTarget ? /* @__PURE__ */ jsx(
|
|
4019
|
+
SignInAsAdminModal,
|
|
4020
|
+
{
|
|
4021
|
+
admin: signInTarget,
|
|
4022
|
+
support: signInSupport,
|
|
4023
|
+
onClose: () => setSignInTarget(null),
|
|
4024
|
+
onCloseAutoFocus: (event) => restoreDialogFocus(event, openerRef.current, captionRef.current || pageRef.current)
|
|
4025
|
+
}
|
|
4026
|
+
) : null,
|
|
3828
4027
|
confirm ? /* @__PURE__ */ jsx(
|
|
3829
4028
|
ConfirmAction,
|
|
3830
4029
|
{
|
|
@@ -3903,6 +4102,7 @@ const AdminActivityPage = () => {
|
|
|
3903
4102
|
succeeded: t("adminPanel.activity.filter.succeeded", "Sign-ins"),
|
|
3904
4103
|
failed: t("adminPanel.activity.filter.failed", "Failed and locked out"),
|
|
3905
4104
|
"signed-out": t("adminPanel.activity.filter.signedOut", "Sign-outs"),
|
|
4105
|
+
impersonation: t("adminPanel.activity.filter.impersonation", "Impersonation"),
|
|
3906
4106
|
changes: t("adminPanel.activity.filter.changes", "Settings and log access")
|
|
3907
4107
|
};
|
|
3908
4108
|
const title = t("adminPanel.activity.page.title", "Security activity");
|