strapi-plugin-magic-sessionmanager 4.14.3 → 4.16.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 +87 -0
- package/README.md +216 -85
- package/dist/admin/{Analytics-CFEgpg-G.mjs → Analytics-D4gsVwL0.mjs} +1 -1
- package/dist/admin/{Analytics-DSpn7W5A.js → Analytics-me4qzS0I.js} +1 -1
- package/dist/admin/{App-BBne8xI6.mjs → App-BJwtFWxl.mjs} +921 -106
- package/dist/admin/{App-UlRrLKcx.js → App-BTG-2Q26.js} +920 -105
- package/dist/admin/{OnlineUsersWidget-GFcYyZ9L.js → OnlineUsersWidget-DYS3Vy1Q.js} +1 -1
- package/dist/admin/{OnlineUsersWidget-C3YMTEGD.mjs → OnlineUsersWidget-Yd283YDy.mjs} +1 -1
- package/dist/admin/{Settings-BbUNvjno.mjs → Settings-DIlvfdjZ.mjs} +427 -83
- package/dist/admin/{Settings-DVhW9XHB.js → Settings-TPZ9_75s.js} +425 -81
- package/dist/admin/{de-B0CBR1Dw.js → de-BuMw1gBJ.js} +130 -8
- package/dist/admin/{de-BlKn1pSD.mjs → de-DB9ldYwN.mjs} +130 -8
- package/dist/admin/{en-IT0YTY8f.mjs → en-BbLMPQB3.mjs} +130 -8
- package/dist/admin/{en-D0ZGIIjz.js → en-BqGhOJDy.js} +130 -8
- package/dist/admin/{es-CWee-XCR.js → es-BaIeckl9.js} +130 -8
- package/dist/admin/{es-BCGzaaCh.mjs → es-C5iaiE9G.mjs} +130 -8
- package/dist/admin/{fr-xBIH4Byq.mjs → fr-BEvBUCwI.mjs} +130 -8
- package/dist/admin/{fr-rQS1M7jE.js → fr-D1YKyTex.js} +130 -8
- package/dist/admin/{index-1KmiZSfy.js → index-CgZiLcJ1.js} +13 -10
- package/dist/admin/{index-MOJkFXcZ.mjs → index-DUESEUaO.mjs} +13 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-DWDeIDVa.mjs → pt-DeDih9cR.mjs} +130 -8
- package/dist/admin/{pt-C-yTLhnS.js → pt-DtnW-s0V.js} +130 -8
- package/dist/admin/riskData-BVs9GpgD.js +26 -0
- package/dist/admin/riskData-CI1gm2yI.mjs +27 -0
- package/dist/server/index.js +2500 -299
- package/dist/server/index.mjs +2500 -299
- package/package.json +1 -1
- package/scripts/geoip-updater.cjs +58 -15
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback, createContext, useContext, useMemo, useId, Fragment, useRef, useEffect, useLayoutEffect } from "react";
|
|
3
3
|
import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSelect, SingleSelectOption, Accordion, Alert, Badge, Radio, Dialog, Tag, Combobox, ComboboxOption, NumberInput, Divider, Tabs, Textarea, Checkbox } from "@strapi/design-system";
|
|
4
|
-
import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
|
|
5
|
-
import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Check } from "@strapi/icons";
|
|
4
|
+
import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, useRBAC, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
|
|
5
|
+
import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Download, Check } from "@strapi/icons";
|
|
6
6
|
import styled from "styled-components";
|
|
7
|
-
import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, w as PageShell } from "./index-
|
|
7
|
+
import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, o as pluginPermissions, w as PageShell } from "./index-DUESEUaO.mjs";
|
|
8
8
|
import { useIntl } from "react-intl";
|
|
9
9
|
import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
|
|
10
|
+
import { g as getRiskAvailability, r as riskDependentControl } from "./riskData-CI1gm2yI.mjs";
|
|
10
11
|
const SETTINGS_TAB_IDS = Object.freeze([
|
|
11
12
|
"sessions",
|
|
12
13
|
"login-protection",
|
|
13
14
|
"location-data",
|
|
14
15
|
"alerts",
|
|
15
|
-
"data-retention"
|
|
16
|
+
"data-retention",
|
|
17
|
+
"admin-activity"
|
|
16
18
|
]);
|
|
19
|
+
const PERMISSION_GATED_TABS = Object.freeze(["admin-activity"]);
|
|
17
20
|
const DEFAULT_SETTINGS_TAB = "sessions";
|
|
18
21
|
const SETTINGS_TAB_LABELS = Object.freeze({
|
|
19
22
|
sessions: ["settings.config.tab.sessions", "Sessions"],
|
|
20
23
|
"login-protection": ["settings.config.tab.loginProtection", "Login protection"],
|
|
21
24
|
"location-data": ["settings.config.tab.locationData", "Location data"],
|
|
22
25
|
alerts: ["settings.config.tab.alerts", "Alerts"],
|
|
23
|
-
"data-retention": ["settings.config.tab.dataRetention", "Data and retention"]
|
|
26
|
+
"data-retention": ["settings.config.tab.dataRetention", "Data and retention"],
|
|
27
|
+
"admin-activity": ["settings.config.tab.adminActivity", "Admin activity"]
|
|
24
28
|
});
|
|
25
29
|
const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
26
30
|
sessions: [
|
|
@@ -57,7 +61,14 @@ const SETTINGS_TAB_FIELDS = Object.freeze({
|
|
|
57
61
|
"discordWebhookUrl",
|
|
58
62
|
"slackWebhookUrl"
|
|
59
63
|
],
|
|
60
|
-
"data-retention": ["retentionDays"]
|
|
64
|
+
"data-retention": ["retentionDays"],
|
|
65
|
+
"admin-activity": [
|
|
66
|
+
"adminSignInHistory",
|
|
67
|
+
"adminContentActivity",
|
|
68
|
+
"securityLogStoreIp",
|
|
69
|
+
"securityLogAnonymizeIp",
|
|
70
|
+
"securityLogRetentionDays"
|
|
71
|
+
]
|
|
61
72
|
});
|
|
62
73
|
const PRESERVED_SETTINGS_KEYS = Object.freeze([
|
|
63
74
|
"rateLimitWriteMax",
|
|
@@ -100,7 +111,21 @@ const SETTINGS_FIELD_LABELS = Object.freeze({
|
|
|
100
111
|
enableWebhooks: ["settings.config.webhooks.enable.label", "Send team notifications"],
|
|
101
112
|
discordWebhookUrl: ["settings.config.webhooks.discord.label", "Discord webhook URL"],
|
|
102
113
|
slackWebhookUrl: ["settings.config.webhooks.slack.label", "Slack webhook URL"],
|
|
103
|
-
retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"]
|
|
114
|
+
retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"],
|
|
115
|
+
adminSignInHistory: ["settings.config.adminActivity.signIns.label", "Record admin sign-ins"],
|
|
116
|
+
adminContentActivity: [
|
|
117
|
+
"settings.config.adminActivity.content.label",
|
|
118
|
+
"Record Content Manager activity"
|
|
119
|
+
],
|
|
120
|
+
securityLogStoreIp: ["settings.config.adminActivity.storeIp.label", "Store IP addresses"],
|
|
121
|
+
securityLogAnonymizeIp: [
|
|
122
|
+
"settings.config.adminActivity.anonymize.label",
|
|
123
|
+
"Anonymise the last part of IP addresses"
|
|
124
|
+
],
|
|
125
|
+
securityLogRetentionDays: [
|
|
126
|
+
"settings.config.adminActivity.retention.label",
|
|
127
|
+
"Keep security events for"
|
|
128
|
+
]
|
|
104
129
|
});
|
|
105
130
|
const SELECT_PRESETS = Object.freeze({
|
|
106
131
|
inactivityTimeout: Object.freeze([5, 10, 15, 30, 60, 120]),
|
|
@@ -108,11 +133,17 @@ const SELECT_PRESETS = Object.freeze({
|
|
|
108
133
|
lastSeenRateLimit: Object.freeze([10, 30, 60, 120, 300]),
|
|
109
134
|
cleanupInterval: Object.freeze([15, 30, 60, 120]),
|
|
110
135
|
sessionCreationGraceMs: Object.freeze([0, 2e3, 5e3, 1e4, 3e4]),
|
|
111
|
-
retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1])
|
|
136
|
+
retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1]),
|
|
137
|
+
securityLogRetentionDays: Object.freeze([7, 30, 90, 180, 365])
|
|
112
138
|
});
|
|
113
|
-
function resolveSettingsTab(value) {
|
|
139
|
+
function resolveSettingsTab(value, tabs = SETTINGS_TAB_IDS) {
|
|
114
140
|
const candidate = Array.isArray(value) ? value[0] : value;
|
|
115
|
-
return
|
|
141
|
+
return tabs.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
|
|
142
|
+
}
|
|
143
|
+
function getVisibleSettingsTabs(canViewAdminActivity) {
|
|
144
|
+
return SETTINGS_TAB_IDS.filter(
|
|
145
|
+
(tab) => canViewAdminActivity || !PERMISSION_GATED_TABS.includes(tab)
|
|
146
|
+
);
|
|
116
147
|
}
|
|
117
148
|
function buildTabSearch(search, tab) {
|
|
118
149
|
const params = new URLSearchParams(typeof search === "string" ? search : "");
|
|
@@ -589,6 +620,16 @@ const RequiresGeolocation = () => {
|
|
|
589
620
|
const { t } = useSettingsTranslate();
|
|
590
621
|
return /* @__PURE__ */ jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
|
|
591
622
|
};
|
|
623
|
+
const RiskSourceNotice = ({ savedOn = false, tab = "location-data" }) => {
|
|
624
|
+
const { t } = useSettingsTranslate();
|
|
625
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-risk-source-notice": "", children: [
|
|
626
|
+
/* @__PURE__ */ jsx(RequiresNotice, { tab: tab || void 0, children: t("settings.config.requires.riskData", "Needs a risk data source") }),
|
|
627
|
+
savedOn ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
628
|
+
"settings.config.requires.riskData.savedOn",
|
|
629
|
+
"Saved as on. It takes effect once a risk data source is set up."
|
|
630
|
+
) }) : null
|
|
631
|
+
] });
|
|
632
|
+
};
|
|
592
633
|
const AdvancedTrigger = styled(Accordion.Trigger)`
|
|
593
634
|
&&:focus-visible {
|
|
594
635
|
outline: 2px solid ${({ theme }) => theme.colors.primary600};
|
|
@@ -1364,7 +1405,12 @@ const SETTINGS_DEFAULTS = Object.freeze({
|
|
|
1364
1405
|
blockedCountries: [],
|
|
1365
1406
|
geoIpProvider: "auto",
|
|
1366
1407
|
geoIpDatabasePath: "",
|
|
1367
|
-
geoLookupFailureMode: "auto"
|
|
1408
|
+
geoLookupFailureMode: "auto",
|
|
1409
|
+
adminSignInHistory: true,
|
|
1410
|
+
adminContentActivity: false,
|
|
1411
|
+
securityLogStoreIp: true,
|
|
1412
|
+
securityLogAnonymizeIp: false,
|
|
1413
|
+
securityLogRetentionDays: 90
|
|
1368
1414
|
});
|
|
1369
1415
|
const MAX_FAILED_LOGINS_RANGE = Object.freeze({ min: 0, max: 100 });
|
|
1370
1416
|
const WEBHOOK_HOSTS = Object.freeze({
|
|
@@ -1879,6 +1925,9 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
1879
1925
|
const maxFailedError = tError(errors.maxFailedLogins);
|
|
1880
1926
|
const maxFailedValue = Number(settings.maxFailedLogins);
|
|
1881
1927
|
const lookupOff = !settings.enableGeolocation;
|
|
1928
|
+
const risk = getRiskAvailability(form.geoIp.status);
|
|
1929
|
+
const reject = riskDependentControl(settings.blockSuspiciousSessions, risk.state);
|
|
1930
|
+
const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
|
|
1882
1931
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1883
1932
|
/* @__PURE__ */ jsx(IntroText, { children: t(
|
|
1884
1933
|
"settings.config.loginProtection.intro",
|
|
@@ -1978,6 +2027,23 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
1978
2027
|
subtitle: t("settings.config.suspicious.intro", "Refuses new sign-ins that look risky."),
|
|
1979
2028
|
children: [
|
|
1980
2029
|
lookupOff ? /* @__PURE__ */ jsx(RequiresGeolocation, {}) : null,
|
|
2030
|
+
!lookupOff && risk.state === "missing" ? /* @__PURE__ */ jsxs(
|
|
2031
|
+
PersistentAlert,
|
|
2032
|
+
{
|
|
2033
|
+
variant: "default",
|
|
2034
|
+
closeLabel: t("common.close", "Close"),
|
|
2035
|
+
title: t("settings.config.risk.missing.title", "No risk data source"),
|
|
2036
|
+
"data-risk-missing": "",
|
|
2037
|
+
children: [
|
|
2038
|
+
t(
|
|
2039
|
+
"settings.config.risk.missing.body",
|
|
2040
|
+
"VPN, proxy and Tor detection needs a risk data source. Until one is set up, no sign-in is refused as suspicious."
|
|
2041
|
+
),
|
|
2042
|
+
" ",
|
|
2043
|
+
/* @__PURE__ */ jsx(SettingsTabLink, { tab: "location-data", children: t("settings.config.risk.missing.link", "Set up risk data") })
|
|
2044
|
+
]
|
|
2045
|
+
}
|
|
2046
|
+
) : null,
|
|
1981
2047
|
/* @__PURE__ */ jsx(
|
|
1982
2048
|
SettingsToggleRow,
|
|
1983
2049
|
{
|
|
@@ -1985,45 +2051,48 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
1985
2051
|
title: t("settings.config.suspicious.reject.label", "Reject suspicious sign-ins"),
|
|
1986
2052
|
description: t(
|
|
1987
2053
|
"settings.config.suspicious.reject.hint",
|
|
1988
|
-
"Refuses sign-ins from VPN, proxy or
|
|
2054
|
+
"Refuses sign-ins from VPN, proxy or Tor addresses and, with security scoring on, scores below 50. Hosting networks only trigger alerts."
|
|
1989
2055
|
),
|
|
1990
|
-
checked:
|
|
1991
|
-
disabled: lookupOff,
|
|
2056
|
+
checked: reject.checked,
|
|
2057
|
+
disabled: lookupOff || reject.disabled,
|
|
1992
2058
|
onChange: (checked) => handleChange("blockSuspiciousSessions", checked),
|
|
1993
|
-
children:
|
|
1994
|
-
"settings.config.suspicious.reject.localNote",
|
|
1995
|
-
"The local database has no VPN, proxy or threat data and always scores 100, so only failed lookups can be refused."
|
|
1996
|
-
) }) : null
|
|
2059
|
+
children: !lookupOff && reject.disabled ? /* @__PURE__ */ jsx(RiskSourceNotice, { savedOn: reject.savedOnButInactive }) : null
|
|
1997
2060
|
}
|
|
1998
2061
|
),
|
|
1999
|
-
/* @__PURE__ */
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2062
|
+
/* @__PURE__ */ jsxs(AdvancedSection, { hasError: fieldHasError(errors, "geoLookupFailureMode"), children: [
|
|
2063
|
+
/* @__PURE__ */ jsx(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsx(
|
|
2064
|
+
FormField,
|
|
2065
|
+
{
|
|
2066
|
+
id: "geoip-lookup-failure-mode",
|
|
2067
|
+
name: "geoLookupFailureMode",
|
|
2068
|
+
label: t(
|
|
2069
|
+
"settings.config.suspicious.failureMode.label",
|
|
2070
|
+
"If the location cannot be determined"
|
|
2071
|
+
),
|
|
2072
|
+
description: t(
|
|
2073
|
+
"settings.config.suspicious.failureMode.hint",
|
|
2074
|
+
"Automatic rejects only when 'Reject suspicious sign-ins' is on. A rejected sign-in gets 'Login temporarily unavailable'. With 'Reject sign-in', the Automatic provider no longer falls back to ipapi.co."
|
|
2075
|
+
),
|
|
2076
|
+
children: /* @__PURE__ */ jsxs(
|
|
2077
|
+
SingleSelect,
|
|
2078
|
+
{
|
|
2079
|
+
value: settings.geoLookupFailureMode || "auto",
|
|
2080
|
+
disabled: lookupOff,
|
|
2081
|
+
onChange: (value) => handleChange("geoLookupFailureMode", value),
|
|
2082
|
+
children: [
|
|
2083
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
|
|
2084
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "allow", children: t("settings.config.suspicious.failureMode.allow", "Allow sign-in") }),
|
|
2085
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "block", children: t("settings.config.suspicious.failureMode.block", "Reject sign-in") })
|
|
2086
|
+
]
|
|
2087
|
+
}
|
|
2088
|
+
)
|
|
2089
|
+
}
|
|
2090
|
+
) }),
|
|
2091
|
+
autoStillRejects ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-auto-still-rejects": "", children: t(
|
|
2092
|
+
"settings.config.suspicious.failureMode.savedOnNote",
|
|
2093
|
+
"Automatic still rejects sign-ins whose location cannot be determined, because 'Reject suspicious sign-ins' is saved as on. Choose 'Allow sign-in' to change that."
|
|
2094
|
+
) }) : null
|
|
2095
|
+
] })
|
|
2027
2096
|
]
|
|
2028
2097
|
}
|
|
2029
2098
|
),
|
|
@@ -2088,7 +2157,7 @@ const LoginProtectionTab = ({ form }) => {
|
|
|
2088
2157
|
] })
|
|
2089
2158
|
] });
|
|
2090
2159
|
};
|
|
2091
|
-
const BUILD_DATE_OPTIONS$
|
|
2160
|
+
const BUILD_DATE_OPTIONS$2 = Object.freeze({ dateStyle: "medium" });
|
|
2092
2161
|
const PathValue = ({ path }) => {
|
|
2093
2162
|
const parts = String(path).split("/");
|
|
2094
2163
|
return /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: parts.map((part, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2199,7 +2268,7 @@ const GeoIpDatabaseCard = ({ form }) => {
|
|
|
2199
2268
|
geoIpStatus.metadata?.lastModified,
|
|
2200
2269
|
locale,
|
|
2201
2270
|
"",
|
|
2202
|
-
BUILD_DATE_OPTIONS$
|
|
2271
|
+
BUILD_DATE_OPTIONS$2
|
|
2203
2272
|
)
|
|
2204
2273
|
},
|
|
2205
2274
|
{
|
|
@@ -2362,9 +2431,149 @@ const GeoIpDatabaseCard = ({ form }) => {
|
|
|
2362
2431
|
}
|
|
2363
2432
|
);
|
|
2364
2433
|
};
|
|
2434
|
+
const BUILD_DATE_OPTIONS$1 = Object.freeze({ dateStyle: "medium" });
|
|
2435
|
+
const databaseState = (entry) => {
|
|
2436
|
+
if (entry?.usable) return "ready";
|
|
2437
|
+
if (entry?.exists) return "unusable";
|
|
2438
|
+
return "missing";
|
|
2439
|
+
};
|
|
2440
|
+
const BADGE_COLOURS = Object.freeze({
|
|
2441
|
+
ready: { backgroundColor: "success100", textColor: "success700" },
|
|
2442
|
+
unusable: { backgroundColor: "warning200", textColor: "neutral800" },
|
|
2443
|
+
missing: { backgroundColor: "neutral150", textColor: "neutral700" }
|
|
2444
|
+
});
|
|
2445
|
+
const RiskDatabase = ({ id, title, shortName, description, entry, form, lookupOff }) => {
|
|
2446
|
+
const { t, locale } = useSettingsTranslate();
|
|
2447
|
+
const buttonRef = useRef(null);
|
|
2448
|
+
const { geoIp } = form;
|
|
2449
|
+
const state = databaseState(entry);
|
|
2450
|
+
const stateLabels = {
|
|
2451
|
+
ready: t("settings.config.risk.database.ready", "Ready"),
|
|
2452
|
+
unusable: t("settings.config.risk.database.unusable", "Cannot be read"),
|
|
2453
|
+
missing: t("settings.config.risk.database.missing", "Not downloaded")
|
|
2454
|
+
};
|
|
2455
|
+
const built = formatSessionDate(entry?.metadata?.lastModified, locale, "", BUILD_DATE_OPTIONS$1);
|
|
2456
|
+
const pending = geoIp.riskUpdating === id;
|
|
2457
|
+
const disabled = lookupOff || Boolean(geoIp.riskUpdating) || geoIp.updating || !geoIp.status?.hasCredentials || entry?.fromEnvironment === true;
|
|
2458
|
+
const download = async () => {
|
|
2459
|
+
await geoIp.updateDatabase(false, id);
|
|
2460
|
+
window.requestAnimationFrame(
|
|
2461
|
+
() => window.requestAnimationFrame(() => refocusIfLost(buttonRef.current, buttonRef.current))
|
|
2462
|
+
);
|
|
2463
|
+
};
|
|
2464
|
+
return /* @__PURE__ */ jsx(
|
|
2465
|
+
Box,
|
|
2466
|
+
{
|
|
2467
|
+
padding: 4,
|
|
2468
|
+
hasRadius: true,
|
|
2469
|
+
borderColor: "neutral200",
|
|
2470
|
+
background: "neutral0",
|
|
2471
|
+
height: "100%",
|
|
2472
|
+
"data-risk-database": id,
|
|
2473
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 3, height: "100%", children: [
|
|
2474
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 2, wrap: "wrap", children: [
|
|
2475
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", tag: "h3", children: title }),
|
|
2476
|
+
/* @__PURE__ */ jsx(Badge, { ...BADGE_COLOURS[state], children: stateLabels[state] })
|
|
2477
|
+
] }),
|
|
2478
|
+
/* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: description }),
|
|
2479
|
+
state === "unusable" ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral800", tag: "p", children: t(
|
|
2480
|
+
"settings.config.risk.database.unusableHint",
|
|
2481
|
+
"The file exists but is not this MaxMind database. Download it again."
|
|
2482
|
+
) }) : null,
|
|
2483
|
+
built ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("settings.config.risk.database.built", "Built {date}", { date: built }) }) : null,
|
|
2484
|
+
entry?.fromEnvironment ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
2485
|
+
"settings.config.risk.database.fromEnvironment",
|
|
2486
|
+
"Read from the path in an environment variable. Update that file outside Strapi."
|
|
2487
|
+
) }) : null,
|
|
2488
|
+
/* @__PURE__ */ jsx(Box, { marginTop: "auto", children: /* @__PURE__ */ jsx(
|
|
2489
|
+
Button,
|
|
2490
|
+
{
|
|
2491
|
+
ref: buttonRef,
|
|
2492
|
+
variant: "secondary",
|
|
2493
|
+
startIcon: /* @__PURE__ */ jsx(Download, {}),
|
|
2494
|
+
loading: pending,
|
|
2495
|
+
disabled,
|
|
2496
|
+
onClick: download,
|
|
2497
|
+
children: state === "missing" ? t("settings.config.risk.database.download", "Download {name}", { name: shortName }) : t("settings.config.risk.database.update", "Update {name}", { name: shortName })
|
|
2498
|
+
}
|
|
2499
|
+
) })
|
|
2500
|
+
] })
|
|
2501
|
+
}
|
|
2502
|
+
);
|
|
2503
|
+
};
|
|
2504
|
+
const RiskDataCard = ({ form }) => {
|
|
2505
|
+
const { t } = useSettingsTranslate();
|
|
2506
|
+
const { settings, geoIp } = form;
|
|
2507
|
+
const lookupOff = !settings.enableGeolocation;
|
|
2508
|
+
const risk = getRiskAvailability(geoIp.status);
|
|
2509
|
+
const sourceLabels = {
|
|
2510
|
+
"anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
|
|
2511
|
+
"asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
|
|
2512
|
+
};
|
|
2513
|
+
return /* @__PURE__ */ jsxs(
|
|
2514
|
+
SectionCard,
|
|
2515
|
+
{
|
|
2516
|
+
id: "risk-data",
|
|
2517
|
+
title: t("settings.config.risk.title", "Risk data (VPN, proxy, Tor)"),
|
|
2518
|
+
subtitle: t(
|
|
2519
|
+
"settings.config.risk.intro",
|
|
2520
|
+
"Location data cannot tell VPNs, proxies or Tor apart. A local MaxMind database can; lookups stay on this server."
|
|
2521
|
+
),
|
|
2522
|
+
action: risk.state === "unknown" ? null : /* @__PURE__ */ jsx(
|
|
2523
|
+
Badge,
|
|
2524
|
+
{
|
|
2525
|
+
backgroundColor: risk.state === "available" ? "success100" : "neutral150",
|
|
2526
|
+
textColor: risk.state === "available" ? "success700" : "neutral700",
|
|
2527
|
+
children: risk.state === "available" ? sourceLabels[risk.source] : t("settings.config.risk.source.none", "Not set up")
|
|
2528
|
+
}
|
|
2529
|
+
),
|
|
2530
|
+
children: [
|
|
2531
|
+
lookupOff ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : null,
|
|
2532
|
+
/* @__PURE__ */ jsxs(EqualGrid, { columns: 2, stackBelow: "medium", gap: 4, children: [
|
|
2533
|
+
/* @__PURE__ */ jsx(
|
|
2534
|
+
RiskDatabase,
|
|
2535
|
+
{
|
|
2536
|
+
id: "anonymous-ip",
|
|
2537
|
+
title: t("settings.config.risk.anonymousIp.title", "GeoIP2 Anonymous IP"),
|
|
2538
|
+
shortName: t("settings.config.risk.anonymousIp.short", "Anonymous IP"),
|
|
2539
|
+
description: t(
|
|
2540
|
+
"settings.config.risk.anonymousIp.hint",
|
|
2541
|
+
"Paid MaxMind database. Detects VPNs, public and residential proxies, Tor exit nodes and hosting providers. The download fails if your MaxMind account does not include it."
|
|
2542
|
+
),
|
|
2543
|
+
entry: geoIp.status?.risk?.anonymousIp,
|
|
2544
|
+
form,
|
|
2545
|
+
lookupOff
|
|
2546
|
+
}
|
|
2547
|
+
),
|
|
2548
|
+
/* @__PURE__ */ jsx(
|
|
2549
|
+
RiskDatabase,
|
|
2550
|
+
{
|
|
2551
|
+
id: "asn",
|
|
2552
|
+
title: t("settings.config.risk.asn.title", "GeoLite2 ASN (heuristic)"),
|
|
2553
|
+
shortName: t("settings.config.risk.asn.short", "ASN"),
|
|
2554
|
+
description: t(
|
|
2555
|
+
"settings.config.risk.asn.hint",
|
|
2556
|
+
"Free MaxMind database. Flags sign-ins from large hosting and cloud networks such as AWS, Azure or Hetzner for alerts. A heuristic: it does not detect VPNs, proxies or Tor and never refuses a sign-in. Used only without the Anonymous IP database."
|
|
2557
|
+
),
|
|
2558
|
+
entry: geoIp.status?.risk?.asn,
|
|
2559
|
+
form,
|
|
2560
|
+
lookupOff
|
|
2561
|
+
}
|
|
2562
|
+
)
|
|
2563
|
+
] }),
|
|
2564
|
+
geoIp.status && !geoIp.status.hasCredentials ? /* @__PURE__ */ jsx(RequiresNotice, { children: t(
|
|
2565
|
+
"settings.config.risk.credentials",
|
|
2566
|
+
"Downloads use the MaxMind credentials under Provider and database. Add them first."
|
|
2567
|
+
) }) : null
|
|
2568
|
+
]
|
|
2569
|
+
}
|
|
2570
|
+
);
|
|
2571
|
+
};
|
|
2365
2572
|
const LocationDataTab = ({ form }) => {
|
|
2366
2573
|
const { t } = useSettingsTranslate();
|
|
2367
2574
|
const { settings, handleChange } = form;
|
|
2575
|
+
const risk = getRiskAvailability(form.geoIp.status);
|
|
2576
|
+
const scoring = riskDependentControl(settings.enableSecurityScoring, risk.state);
|
|
2368
2577
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
2369
2578
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
2370
2579
|
/* @__PURE__ */ jsx(IntroText, { children: t(
|
|
@@ -2401,16 +2610,17 @@ const LocationDataTab = ({ form }) => {
|
|
|
2401
2610
|
title: t("settings.config.lookup.scoring.label", "Security scoring"),
|
|
2402
2611
|
description: t(
|
|
2403
2612
|
"settings.config.lookup.scoring.hint",
|
|
2404
|
-
"Applies the score thresholds: below 70 triggers a suspicious-sign-in email, below 50 a rejection if enabled.
|
|
2613
|
+
"Applies the score thresholds: below 70 triggers a suspicious-sign-in email, below 50 a rejection if enabled."
|
|
2405
2614
|
),
|
|
2406
|
-
checked:
|
|
2407
|
-
disabled: !settings.enableGeolocation,
|
|
2615
|
+
checked: scoring.checked,
|
|
2616
|
+
disabled: !settings.enableGeolocation || scoring.disabled,
|
|
2408
2617
|
onChange: (checked) => handleChange("enableSecurityScoring", checked),
|
|
2409
|
-
children: !settings.enableGeolocation ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : null
|
|
2618
|
+
children: !settings.enableGeolocation ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : scoring.disabled ? /* @__PURE__ */ jsx(RiskSourceNotice, { savedOn: scoring.savedOnButInactive, tab: null }) : null
|
|
2410
2619
|
}
|
|
2411
2620
|
)
|
|
2412
2621
|
] }),
|
|
2413
|
-
/* @__PURE__ */ jsx(GeoIpDatabaseCard, { form })
|
|
2622
|
+
/* @__PURE__ */ jsx(GeoIpDatabaseCard, { form }),
|
|
2623
|
+
/* @__PURE__ */ jsx(RiskDataCard, { form })
|
|
2414
2624
|
] });
|
|
2415
2625
|
};
|
|
2416
2626
|
const CodeTextarea = styled(Textarea)`
|
|
@@ -2799,14 +3009,16 @@ const AlertsTab = ({ form }) => {
|
|
|
2799
3009
|
const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
|
|
2800
3010
|
const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
|
|
2801
3011
|
const templateErrors = fieldHasError(errors, "emailTemplates");
|
|
3012
|
+
const risk = getRiskAvailability(form.geoIp.status);
|
|
2802
3013
|
const emailTypes = [
|
|
2803
3014
|
{
|
|
2804
3015
|
field: "alertOnSuspiciousLogin",
|
|
3016
|
+
needsRiskData: true,
|
|
2805
3017
|
hintId: hintIds.suspicious,
|
|
2806
3018
|
label: t("settings.config.email.suspicious.label", "Suspicious sign-in"),
|
|
2807
3019
|
hint: t(
|
|
2808
3020
|
"settings.config.email.suspicious.hint",
|
|
2809
|
-
"VPN, proxy or
|
|
3021
|
+
"VPN, proxy, Tor or hosting address, or a score below 70 with scoring on."
|
|
2810
3022
|
)
|
|
2811
3023
|
},
|
|
2812
3024
|
{
|
|
@@ -2820,11 +3032,12 @@ const AlertsTab = ({ form }) => {
|
|
|
2820
3032
|
},
|
|
2821
3033
|
{
|
|
2822
3034
|
field: "alertOnVpnProxy",
|
|
3035
|
+
needsRiskData: true,
|
|
2823
3036
|
hintId: hintIds.vpnProxy,
|
|
2824
3037
|
label: t("settings.config.email.vpnProxy.label", "VPN or proxy"),
|
|
2825
3038
|
hint: t(
|
|
2826
3039
|
"settings.config.email.vpnProxy.hint",
|
|
2827
|
-
"
|
|
3040
|
+
"Sign-in from a VPN, or from a public or residential proxy."
|
|
2828
3041
|
)
|
|
2829
3042
|
}
|
|
2830
3043
|
];
|
|
@@ -2863,19 +3076,24 @@ const AlertsTab = ({ form }) => {
|
|
|
2863
3076
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
|
|
2864
3077
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
|
|
2865
3078
|
!lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
|
|
2866
|
-
/* @__PURE__ */ jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsx("div", { children: emailTypes.map(({ field, hintId, label, hint }) =>
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
3079
|
+
/* @__PURE__ */ jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
|
|
3080
|
+
const control = needsRiskData ? riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
|
|
3081
|
+
const disabled = emailTypesDisabled || control.disabled;
|
|
3082
|
+
return /* @__PURE__ */ jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
|
|
3083
|
+
/* @__PURE__ */ jsx(
|
|
3084
|
+
Checkbox,
|
|
3085
|
+
{
|
|
3086
|
+
checked: control.checked,
|
|
3087
|
+
disabled,
|
|
3088
|
+
"aria-describedby": hintId,
|
|
3089
|
+
onCheckedChange: (checked) => handleChange(field, checked === true),
|
|
3090
|
+
children: label
|
|
3091
|
+
}
|
|
3092
|
+
),
|
|
3093
|
+
/* @__PURE__ */ jsx(ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint }),
|
|
3094
|
+
!lookupOff && control.disabled ? /* @__PURE__ */ jsx(RiskSourceNotice, { savedOn: control.savedOnButInactive }) : null
|
|
3095
|
+
] }, field);
|
|
3096
|
+
}) }) })
|
|
2879
3097
|
] }),
|
|
2880
3098
|
/* @__PURE__ */ jsxs(
|
|
2881
3099
|
AdvancedSection,
|
|
@@ -2920,6 +3138,11 @@ const AlertsTab = ({ form }) => {
|
|
|
2920
3138
|
}
|
|
2921
3139
|
),
|
|
2922
3140
|
!lookupOff && !settings.enableWebhooks ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.webhooks", "Requires Send team notifications") }) : null,
|
|
3141
|
+
!lookupOff && risk.state === "missing" ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", "data-risk-webhook-note": "", children: t(
|
|
3142
|
+
"settings.config.webhooks.noRiskData",
|
|
3143
|
+
"Without a risk data source, {suspicious} is never sent.",
|
|
3144
|
+
WEBHOOK_EVENTS
|
|
3145
|
+
) }) : null,
|
|
2923
3146
|
/* @__PURE__ */ jsxs(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
|
|
2924
3147
|
/* @__PURE__ */ jsx(
|
|
2925
3148
|
FormField,
|
|
@@ -3059,6 +3282,111 @@ const DataRetentionTab = ({ form }) => {
|
|
|
3059
3282
|
)
|
|
3060
3283
|
] });
|
|
3061
3284
|
};
|
|
3285
|
+
const AdminActivityTab = ({ form }) => {
|
|
3286
|
+
const { t } = useSettingsTranslate();
|
|
3287
|
+
const units = useOptionLabels();
|
|
3288
|
+
const { settings, handleChange } = form;
|
|
3289
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
3290
|
+
/* @__PURE__ */ jsx(IntroText, { children: t(
|
|
3291
|
+
"settings.config.adminActivity.intro",
|
|
3292
|
+
"The security log records sign-ins and work in this admin panel. Each admin’s history is under Session Manager > Admin panel; only admins with “View admin activity” can open it."
|
|
3293
|
+
) }),
|
|
3294
|
+
/* @__PURE__ */ jsxs(SectionCard, { title: t("settings.config.adminActivity.recording.title", "What is recorded"), children: [
|
|
3295
|
+
/* @__PURE__ */ jsx(
|
|
3296
|
+
SettingsToggleRow,
|
|
3297
|
+
{
|
|
3298
|
+
id: "admin-sign-in-history",
|
|
3299
|
+
title: t("settings.config.adminActivity.signIns.label", "Record admin sign-ins"),
|
|
3300
|
+
description: t(
|
|
3301
|
+
"settings.config.adminActivity.signIns.hint",
|
|
3302
|
+
"Every sign-in, failed attempt, lockout and sign-out, and who signed out whom, with time, browser and operating system."
|
|
3303
|
+
),
|
|
3304
|
+
checked: settings.adminSignInHistory,
|
|
3305
|
+
onChange: (checked) => handleChange("adminSignInHistory", checked)
|
|
3306
|
+
}
|
|
3307
|
+
),
|
|
3308
|
+
/* @__PURE__ */ jsx(
|
|
3309
|
+
SettingsToggleRow,
|
|
3310
|
+
{
|
|
3311
|
+
id: "admin-content-activity",
|
|
3312
|
+
title: t(
|
|
3313
|
+
"settings.config.adminActivity.content.label",
|
|
3314
|
+
"Record Content Manager activity"
|
|
3315
|
+
),
|
|
3316
|
+
description: t(
|
|
3317
|
+
"settings.config.adminActivity.content.hint",
|
|
3318
|
+
"Which entries each admin opens, creates, edits, publishes, unpublishes or deletes, with content type, title, locale and time."
|
|
3319
|
+
),
|
|
3320
|
+
checked: settings.adminContentActivity,
|
|
3321
|
+
onChange: (checked) => handleChange("adminContentActivity", checked),
|
|
3322
|
+
children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
|
|
3323
|
+
"settings.config.adminActivity.content.notice",
|
|
3324
|
+
"This records how people work. In many countries employees must be told first, and in Germany the works council usually has a say. Check this before you turn it on."
|
|
3325
|
+
) })
|
|
3326
|
+
}
|
|
3327
|
+
)
|
|
3328
|
+
] }),
|
|
3329
|
+
/* @__PURE__ */ jsxs(
|
|
3330
|
+
SectionCard,
|
|
3331
|
+
{
|
|
3332
|
+
title: t("settings.config.adminActivity.privacy.title", "IP addresses and retention"),
|
|
3333
|
+
subtitle: t(
|
|
3334
|
+
"settings.config.adminActivity.privacy.subtitle",
|
|
3335
|
+
"These options apply to every event in the security log."
|
|
3336
|
+
),
|
|
3337
|
+
children: [
|
|
3338
|
+
/* @__PURE__ */ jsx(
|
|
3339
|
+
SettingsToggleRow,
|
|
3340
|
+
{
|
|
3341
|
+
id: "security-log-store-ip",
|
|
3342
|
+
title: t("settings.config.adminActivity.storeIp.label", "Store IP addresses"),
|
|
3343
|
+
description: t(
|
|
3344
|
+
"settings.config.adminActivity.storeIp.hint",
|
|
3345
|
+
"The address comes from Strapi’s client IP (server.proxy settings). The location uses the IP location lookup under Location data."
|
|
3346
|
+
),
|
|
3347
|
+
checked: settings.securityLogStoreIp,
|
|
3348
|
+
onChange: (checked) => handleChange("securityLogStoreIp", checked)
|
|
3349
|
+
}
|
|
3350
|
+
),
|
|
3351
|
+
/* @__PURE__ */ jsx(
|
|
3352
|
+
SettingsToggleRow,
|
|
3353
|
+
{
|
|
3354
|
+
id: "security-log-anonymize-ip",
|
|
3355
|
+
title: t(
|
|
3356
|
+
"settings.config.adminActivity.anonymize.label",
|
|
3357
|
+
"Anonymise the last part of IP addresses"
|
|
3358
|
+
),
|
|
3359
|
+
description: t(
|
|
3360
|
+
"settings.config.adminActivity.anonymize.hint",
|
|
3361
|
+
"Stores 203.0.113.0 instead of 203.0.113.42 (IPv6: the first 48 bits only)."
|
|
3362
|
+
),
|
|
3363
|
+
checked: settings.securityLogAnonymizeIp,
|
|
3364
|
+
disabled: !settings.securityLogStoreIp,
|
|
3365
|
+
onChange: (checked) => handleChange("securityLogAnonymizeIp", checked),
|
|
3366
|
+
children: !settings.securityLogStoreIp ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.adminActivity.requiresIp", "Requires Store IP addresses") }) : null
|
|
3367
|
+
}
|
|
3368
|
+
),
|
|
3369
|
+
/* @__PURE__ */ jsx(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsx(
|
|
3370
|
+
PresetSelect,
|
|
3371
|
+
{
|
|
3372
|
+
id: "security-log-retention",
|
|
3373
|
+
name: "securityLogRetentionDays",
|
|
3374
|
+
label: t("settings.config.adminActivity.retention.label", "Keep security events for"),
|
|
3375
|
+
description: t(
|
|
3376
|
+
"settings.config.adminActivity.retention.hint",
|
|
3377
|
+
"Older events are deleted once a day. Events of a deleted admin are deleted with the account."
|
|
3378
|
+
),
|
|
3379
|
+
value: settings.securityLogRetentionDays,
|
|
3380
|
+
presets: SELECT_PRESETS.securityLogRetentionDays,
|
|
3381
|
+
format: units.days,
|
|
3382
|
+
onChange: (value) => handleChange("securityLogRetentionDays", value)
|
|
3383
|
+
}
|
|
3384
|
+
) })
|
|
3385
|
+
]
|
|
3386
|
+
}
|
|
3387
|
+
)
|
|
3388
|
+
] });
|
|
3389
|
+
};
|
|
3062
3390
|
async function copyText(value, clipboard = globalThis.navigator?.clipboard) {
|
|
3063
3391
|
if (typeof value !== "string") {
|
|
3064
3392
|
throw new TypeError("clipboard_value_must_be_text");
|
|
@@ -3096,6 +3424,7 @@ function useSettingsForm() {
|
|
|
3096
3424
|
const [geoIpStatusError, setGeoIpStatusError] = useState(false);
|
|
3097
3425
|
const [geoIpCredentials, setGeoIpCredentials] = useState({ accountId: "", licenseKey: "" });
|
|
3098
3426
|
const [geoIpUpdating, setGeoIpUpdating] = useState(false);
|
|
3427
|
+
const [riskUpdating, setRiskUpdating] = useState(null);
|
|
3099
3428
|
const [geoIpSavingCredentials, setGeoIpSavingCredentials] = useState(false);
|
|
3100
3429
|
const [settings, setSettings] = useState(INITIAL_SETTINGS);
|
|
3101
3430
|
const [savedSettings, setSavedSettings] = useState(settings);
|
|
@@ -3314,17 +3643,20 @@ function useSettingsForm() {
|
|
|
3314
3643
|
}
|
|
3315
3644
|
}, [put, t, toggleNotification, fetchGeoIpStatus]);
|
|
3316
3645
|
const handleUpdateGeoIpDatabase = useCallback(
|
|
3317
|
-
async (force = false) => {
|
|
3318
|
-
setGeoIpUpdating
|
|
3646
|
+
async (force = false, database = "location") => {
|
|
3647
|
+
const setPending = database === "location" ? setGeoIpUpdating : setRiskUpdating;
|
|
3648
|
+
setPending(database === "location" ? true : database);
|
|
3319
3649
|
try {
|
|
3320
|
-
const
|
|
3650
|
+
const body = database === "location" ? { force } : { force, database };
|
|
3651
|
+
const response = await post(`/${pluginId}/geoip/update`, body);
|
|
3321
3652
|
requireSuccessfulMutation(response.data);
|
|
3322
3653
|
const status = await fetchGeoIpStatus();
|
|
3323
3654
|
const result = response.data.result || {};
|
|
3655
|
+
const riskEntry = database === "anonymous-ip" ? status?.risk?.anonymousIp : database === "asn" ? status?.risk?.asn : null;
|
|
3324
3656
|
const values = {
|
|
3325
|
-
edition: status?.editionId || "—",
|
|
3657
|
+
edition: (riskEntry || status)?.editionId || "—",
|
|
3326
3658
|
date: formatSessionDate(
|
|
3327
|
-
result.lastModified || status?.metadata?.lastModified,
|
|
3659
|
+
result.lastModified || (riskEntry || status)?.metadata?.lastModified,
|
|
3328
3660
|
locale,
|
|
3329
3661
|
"—",
|
|
3330
3662
|
BUILD_DATE_OPTIONS
|
|
@@ -3352,7 +3684,7 @@ function useSettingsForm() {
|
|
|
3352
3684
|
)
|
|
3353
3685
|
});
|
|
3354
3686
|
} finally {
|
|
3355
|
-
|
|
3687
|
+
setPending(database === "location" ? false : null);
|
|
3356
3688
|
}
|
|
3357
3689
|
},
|
|
3358
3690
|
[post, t, locale, toggleNotification, fetchGeoIpStatus]
|
|
@@ -3384,6 +3716,7 @@ function useSettingsForm() {
|
|
|
3384
3716
|
credentials: geoIpCredentials,
|
|
3385
3717
|
setCredentials: setGeoIpCredentials,
|
|
3386
3718
|
updating: geoIpUpdating,
|
|
3719
|
+
riskUpdating,
|
|
3387
3720
|
savingCredentials: geoIpSavingCredentials,
|
|
3388
3721
|
fetchStatus: fetchGeoIpStatus,
|
|
3389
3722
|
saveCredentials: handleSaveGeoIpCredentials,
|
|
@@ -3426,7 +3759,8 @@ const TAB_COMPONENTS = {
|
|
|
3426
3759
|
"login-protection": LoginProtectionTab,
|
|
3427
3760
|
"location-data": LocationDataTab,
|
|
3428
3761
|
alerts: AlertsTab,
|
|
3429
|
-
"data-retention": DataRetentionTab
|
|
3762
|
+
"data-retention": DataRetentionTab,
|
|
3763
|
+
"admin-activity": AdminActivityTab
|
|
3430
3764
|
};
|
|
3431
3765
|
const DraftSync = ({ values }) => {
|
|
3432
3766
|
const setValues = useForm("DraftSync", (state) => state.setValues);
|
|
@@ -3446,7 +3780,14 @@ const SettingsPage = () => {
|
|
|
3446
3780
|
const { t } = useSettingsTranslate();
|
|
3447
3781
|
const form = useSettingsForm();
|
|
3448
3782
|
const [{ query }] = useQueryParams();
|
|
3449
|
-
const
|
|
3783
|
+
const {
|
|
3784
|
+
allowedActions: { canRead: canViewAdminActivity }
|
|
3785
|
+
} = useRBAC(pluginPermissions.adminActivityRead);
|
|
3786
|
+
const visibleTabs = useMemo(
|
|
3787
|
+
() => getVisibleSettingsTabs(Boolean(canViewAdminActivity)),
|
|
3788
|
+
[canViewAdminActivity]
|
|
3789
|
+
);
|
|
3790
|
+
const requestedTab = resolveSettingsTab(query?.tab, visibleTabs);
|
|
3450
3791
|
const [activeTab, setActiveTab] = useState(requestedTab);
|
|
3451
3792
|
const [followedTab, setFollowedTab] = useState(requestedTab);
|
|
3452
3793
|
const tabsRef = useRef(null);
|
|
@@ -3473,11 +3814,14 @@ const SettingsPage = () => {
|
|
|
3473
3814
|
const handleSaveClick = useCallback(async () => {
|
|
3474
3815
|
if (await handleSave()) focusActiveTab();
|
|
3475
3816
|
}, [handleSave, focusActiveTab]);
|
|
3476
|
-
const changeTab = useCallback(
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3817
|
+
const changeTab = useCallback(
|
|
3818
|
+
(tab) => {
|
|
3819
|
+
const next = resolveSettingsTab(tab, visibleTabs);
|
|
3820
|
+
setActiveTab(next);
|
|
3821
|
+
writeTabToAddressBar(next);
|
|
3822
|
+
},
|
|
3823
|
+
[visibleTabs]
|
|
3824
|
+
);
|
|
3481
3825
|
const navigation = useMemo(
|
|
3482
3826
|
() => ({
|
|
3483
3827
|
selectTab: (tab) => {
|
|
@@ -3562,10 +3906,10 @@ const SettingsPage = () => {
|
|
|
3562
3906
|
SettingsTabsList,
|
|
3563
3907
|
{
|
|
3564
3908
|
"aria-label": t("settings.config.tabs.label", "Configuration sections"),
|
|
3565
|
-
children:
|
|
3909
|
+
children: visibleTabs.map((tab) => /* @__PURE__ */ jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsx(SettingsTabLabel, { children: t(SETTINGS_TAB_LABELS[tab][0], SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
|
|
3566
3910
|
}
|
|
3567
3911
|
),
|
|
3568
|
-
|
|
3912
|
+
visibleTabs.map((tab) => {
|
|
3569
3913
|
const TabPanel = TAB_COMPONENTS[tab];
|
|
3570
3914
|
return /* @__PURE__ */ jsx(Tabs.Content, { value: tab, forceMount: true, hidden: activeTab !== tab, children: /* @__PURE__ */ jsx(TabPanelFrame, { "data-settings-tab-panel": "", children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", paddingTop: 6, children: /* @__PURE__ */ jsx(TabPanel, { form }) }) }) }, tab);
|
|
3571
3915
|
}),
|