strapi-plugin-magic-sessionmanager 4.5.12 → 4.6.1
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 +21 -0
- package/README.md +90 -34
- package/dist/{_chunks/Analytics-DM4_UffY.js → admin/Analytics-BMkhiuRX.js} +3 -121
- package/dist/{_chunks/Analytics--qB2cKuD.mjs → admin/Analytics-CwNJ3TNI.mjs} +5 -123
- package/dist/{_chunks/App-DF-VsbDW.js → admin/App-DazHh7Zi.js} +67 -646
- package/dist/{_chunks/App-CL5q29Mi.mjs → admin/App-Sk0F9UEN.mjs} +69 -648
- package/dist/{_chunks/License-D9piCp34.mjs → admin/License-6SIpR7Rk.mjs} +34 -113
- package/dist/{_chunks/License-Dmm1d3fQ.js → admin/License-BwbmzbP_.js} +34 -113
- package/dist/{_chunks/OnlineUsersWidget-KchZ_ScS.js → admin/OnlineUsersWidget-BIfnbFcZ.js} +44 -36
- package/dist/{_chunks/OnlineUsersWidget-DHsthkt0.mjs → admin/OnlineUsersWidget-Qq_uCTi1.mjs} +44 -36
- package/dist/{_chunks/Settings-D6ILgR9X.mjs → admin/Settings-BA7S_8DF.mjs} +286 -112
- package/dist/{_chunks/Settings-CUNaxDWk.js → admin/Settings-CCYScjxv.js} +284 -110
- package/dist/{_chunks/de-CDA1V0rF.mjs → admin/de-6rIvkYOp.mjs} +37 -14
- package/dist/{_chunks/de-I-Q-pWqu.js → admin/de-DjP2WJ_V.js} +37 -14
- package/dist/{_chunks/en-Bd7_h-4e.js → admin/en-0pesBbOT.js} +37 -14
- package/dist/{_chunks/en-DzmOCyzQ.mjs → admin/en-8hiv31Dv.mjs} +37 -14
- package/dist/{_chunks/es-BcAx18XG.js → admin/es-DdBRpF7F.js} +37 -14
- package/dist/{_chunks/es-Cx-SN6qV.mjs → admin/es-LRQ148f5.mjs} +37 -14
- package/dist/{_chunks/fr-DXlXE5Eo.mjs → admin/fr-CKhx_qil.mjs} +37 -14
- package/dist/{_chunks/fr-DCzYMuJ-.js → admin/fr-DJ6DbeDy.js} +37 -14
- package/dist/{_chunks/index-CTxGMDHr.js → admin/index-DTskQVDl.js} +12 -25
- package/dist/{_chunks/index-CwxKazpc.mjs → admin/index-UTLA1r40.mjs} +12 -25
- package/dist/admin/index.js +3 -2
- package/dist/admin/index.mjs +1 -1
- package/dist/{_chunks/pt-21-MAb72.js → admin/pt-D0SMoAmo.js} +37 -14
- package/dist/{_chunks/pt-zsdTSjba.mjs → admin/pt-DXizUvcj.mjs} +37 -14
- package/dist/server/index.js +9680 -8914
- package/dist/server/index.mjs +9701 -8918
- package/package.json +25 -14
- package/scripts/geoip-updater.cjs +220 -0
- package/scripts/update-geoip-db.mjs +38 -0
- package/strapi-admin.js +2 -1
- package/strapi-server.js +2 -1
- package/dist/_chunks/UpgradePage-D697BVWo.mjs +0 -352
- package/dist/_chunks/UpgradePage-Dwrv7g8L.js +0 -354
- package/dist/_chunks/useLicense-B9WW9s_d.mjs +0 -86
- package/dist/_chunks/useLicense-BEbtA_Zo.js +0 -85
- /package/dist/{_chunks → admin}/StyledButtons-Cz8oYhmc.mjs +0 -0
- /package/dist/{_chunks → admin}/StyledButtons-DDuxnYz8.js +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
3
|
import { useIntl } from "react-intl";
|
|
4
|
-
import { Flex, Loader, Typography, Button, Box,
|
|
4
|
+
import { Flex, Loader, Typography, Button, Box, Accordion, Grid, SingleSelect, SingleSelectOption, Divider, Alert, TextInput, Badge, Toggle, NumberInput, Checkbox, Tabs } from "@strapi/design-system";
|
|
5
5
|
import { useFetchClient, useNotification } from "@strapi/strapi/admin";
|
|
6
|
-
import { Check,
|
|
6
|
+
import { Check, Cog, Trash, Shield, Code, Duplicate, Clock, Mail } from "@strapi/icons";
|
|
7
7
|
import styled, { css, keyframes } from "styled-components";
|
|
8
|
-
import { a as pluginId, g as getTranslation } from "./index-
|
|
9
|
-
import { u as useLicense } from "./useLicense-B9WW9s_d.mjs";
|
|
8
|
+
import { a as pluginId, g as getTranslation } from "./index-UTLA1r40.mjs";
|
|
10
9
|
import { D as DangerButton, S as ShowHideButton, G as GradientButton, C as CopyButton, T as TertiaryButton, c as SecondaryButton } from "./StyledButtons-Cz8oYhmc.mjs";
|
|
11
10
|
const COUNTRIES = [
|
|
12
11
|
{ code: "DE", name: "Germany", flag: "🇩🇪" },
|
|
@@ -118,17 +117,17 @@ const ToggleCard = styled(Box)`
|
|
|
118
117
|
cursor: pointer;
|
|
119
118
|
display: flex;
|
|
120
119
|
align-items: center;
|
|
121
|
-
|
|
120
|
+
|
|
122
121
|
&:hover {
|
|
123
122
|
transform: translateY(-4px);
|
|
124
123
|
box-shadow: ${(props) => props.$active ? "0 8px 30px rgba(34, 197, 94, 0.25)" : "0 6px 16px rgba(0, 0, 0, 0.12)"};
|
|
125
124
|
border-color: ${(props) => props.$active ? "var(--colors-success600, #15803D)" : "rgba(128, 128, 128, 0.3)"};
|
|
126
125
|
}
|
|
127
|
-
|
|
126
|
+
|
|
128
127
|
&:active {
|
|
129
128
|
transform: translateY(-2px);
|
|
130
129
|
}
|
|
131
|
-
|
|
130
|
+
|
|
132
131
|
${(props) => props.$active && `
|
|
133
132
|
&::before {
|
|
134
133
|
content: 'ACTIVE';
|
|
@@ -145,7 +144,7 @@ const ToggleCard = styled(Box)`
|
|
|
145
144
|
box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
|
|
146
145
|
}
|
|
147
146
|
`}
|
|
148
|
-
|
|
147
|
+
|
|
149
148
|
${(props) => !props.$active && `
|
|
150
149
|
&::before {
|
|
151
150
|
content: 'INACTIVE';
|
|
@@ -168,29 +167,29 @@ const GreenToggle = styled.div`
|
|
|
168
167
|
button[role="switch"] {
|
|
169
168
|
background-color: var(--colors-success600, #16A34A) !important;
|
|
170
169
|
border-color: var(--colors-success600, #16A34A) !important;
|
|
171
|
-
|
|
170
|
+
|
|
172
171
|
&:hover {
|
|
173
172
|
background-color: var(--colors-success600, #15803D) !important;
|
|
174
173
|
border-color: var(--colors-success600, #15803D) !important;
|
|
175
174
|
}
|
|
176
|
-
|
|
175
|
+
|
|
177
176
|
&:focus {
|
|
178
177
|
background-color: var(--colors-success600, #16A34A) !important;
|
|
179
178
|
border-color: var(--colors-success600, #16A34A) !important;
|
|
180
179
|
box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2) !important;
|
|
181
180
|
}
|
|
182
181
|
}
|
|
183
|
-
|
|
182
|
+
|
|
184
183
|
/* Toggle handle */
|
|
185
184
|
button[role="switch"] > span {
|
|
186
185
|
background-color: white !important;
|
|
187
186
|
}
|
|
188
187
|
`}
|
|
189
|
-
|
|
188
|
+
|
|
190
189
|
${(props) => !props.$isActive && `
|
|
191
190
|
button[role="switch"] {
|
|
192
191
|
background-color: rgba(128, 128, 128, 0.2);
|
|
193
|
-
|
|
192
|
+
|
|
194
193
|
&:hover {
|
|
195
194
|
background-color: rgba(128, 128, 128, 0.2);
|
|
196
195
|
}
|
|
@@ -257,14 +256,14 @@ const getDefaultTemplates = () => ({
|
|
|
257
256
|
<div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f9fafb; border-radius: 10px;">
|
|
258
257
|
<h2 style="color: #dc2626;">[ALERT] Suspicious Login Detected</h2>
|
|
259
258
|
<p>A potentially suspicious login was detected for your account.</p>
|
|
260
|
-
|
|
259
|
+
|
|
261
260
|
<div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
|
|
262
261
|
<h3 style="margin-top: 0;">Account Information:</h3>
|
|
263
262
|
<ul>
|
|
264
263
|
<li><strong>Email:</strong> {{user.email}}</li>
|
|
265
264
|
<li><strong>Username:</strong> {{user.username}}</li>
|
|
266
265
|
</ul>
|
|
267
|
-
|
|
266
|
+
|
|
268
267
|
<h3>Login Details:</h3>
|
|
269
268
|
<ul>
|
|
270
269
|
<li><strong>Time:</strong> {{session.loginTime}}</li>
|
|
@@ -273,7 +272,7 @@ const getDefaultTemplates = () => ({
|
|
|
273
272
|
<li><strong>Timezone:</strong> {{geo.timezone}}</li>
|
|
274
273
|
<li><strong>Device:</strong> {{session.userAgent}}</li>
|
|
275
274
|
</ul>
|
|
276
|
-
|
|
275
|
+
|
|
277
276
|
<h3 style="color: #dc2626;">Security Alert:</h3>
|
|
278
277
|
<ul>
|
|
279
278
|
<li>VPN Detected: {{reason.isVpn}}</li>
|
|
@@ -282,9 +281,9 @@ const getDefaultTemplates = () => ({
|
|
|
282
281
|
<li>Security Score: {{reason.securityScore}}/100</li>
|
|
283
282
|
</ul>
|
|
284
283
|
</div>
|
|
285
|
-
|
|
284
|
+
|
|
286
285
|
<p>If this was you, you can safely ignore this email. If you don't recognize this activity, please secure your account immediately.</p>
|
|
287
|
-
|
|
286
|
+
|
|
288
287
|
<hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
|
|
289
288
|
<p style="color: #666; font-size: 12px;">This is an automated security notification from Magic Session Manager.</p>
|
|
290
289
|
</div>
|
|
@@ -312,11 +311,11 @@ Security: VPN={{reason.isVpn}}, Proxy={{reason.isProxy}}, Threat={{reason.isThre
|
|
|
312
311
|
<div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f0f9ff; border-radius: 10px;">
|
|
313
312
|
<h2 style="color: #0284c7;">[LOCATION] Login from New Location</h2>
|
|
314
313
|
<p>Your account was accessed from a new location.</p>
|
|
315
|
-
|
|
314
|
+
|
|
316
315
|
<div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
|
|
317
316
|
<h3 style="margin-top: 0;">Account:</h3>
|
|
318
317
|
<p><strong>{{user.email}}</strong></p>
|
|
319
|
-
|
|
318
|
+
|
|
320
319
|
<h3>New Location Details:</h3>
|
|
321
320
|
<ul>
|
|
322
321
|
<li><strong>Time:</strong> {{session.loginTime}}</li>
|
|
@@ -325,9 +324,9 @@ Security: VPN={{reason.isVpn}}, Proxy={{reason.isProxy}}, Threat={{reason.isThre
|
|
|
325
324
|
<li><strong>Device:</strong> {{session.userAgent}}</li>
|
|
326
325
|
</ul>
|
|
327
326
|
</div>
|
|
328
|
-
|
|
327
|
+
|
|
329
328
|
<p>If this was you, no action is needed. If you don't recognize this login, please secure your account.</p>
|
|
330
|
-
|
|
329
|
+
|
|
331
330
|
<hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
|
|
332
331
|
<p style="color: #666; font-size: 12px;">Magic Session Manager notification</p>
|
|
333
332
|
</div>
|
|
@@ -355,11 +354,11 @@ If this was you, no action is needed.`
|
|
|
355
354
|
<div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fffbeb; border-radius: 10px;">
|
|
356
355
|
<h2 style="color: #d97706;">[WARNING] VPN/Proxy Detected</h2>
|
|
357
356
|
<p>A login from a VPN or proxy service was detected on your account.</p>
|
|
358
|
-
|
|
357
|
+
|
|
359
358
|
<div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
|
|
360
359
|
<h3 style="margin-top: 0;">Account:</h3>
|
|
361
360
|
<p><strong>{{user.email}}</strong></p>
|
|
362
|
-
|
|
361
|
+
|
|
363
362
|
<h3>Login Details:</h3>
|
|
364
363
|
<ul>
|
|
365
364
|
<li><strong>Time:</strong> {{session.loginTime}}</li>
|
|
@@ -370,9 +369,9 @@ If this was you, no action is needed.`
|
|
|
370
369
|
<li><strong>Proxy:</strong> {{reason.isProxy}}</li>
|
|
371
370
|
</ul>
|
|
372
371
|
</div>
|
|
373
|
-
|
|
372
|
+
|
|
374
373
|
<p>VPN/Proxy usage may indicate suspicious activity. If this was you, you can safely ignore this email.</p>
|
|
375
|
-
|
|
374
|
+
|
|
376
375
|
<hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
|
|
377
376
|
<p style="color: #666; font-size: 12px;">Magic Session Manager notification</p>
|
|
378
377
|
</div>
|
|
@@ -401,7 +400,19 @@ const generateSecureKey = () => {
|
|
|
401
400
|
}
|
|
402
401
|
return key;
|
|
403
402
|
};
|
|
404
|
-
const GeofencingPanel = ({
|
|
403
|
+
const GeofencingPanel = ({
|
|
404
|
+
settings,
|
|
405
|
+
handleChange,
|
|
406
|
+
t,
|
|
407
|
+
geoIpStatus,
|
|
408
|
+
geoIpCredentials,
|
|
409
|
+
setGeoIpCredentials,
|
|
410
|
+
onSaveGeoIpCredentials,
|
|
411
|
+
onUpdateGeoIp,
|
|
412
|
+
geoIpUpdating,
|
|
413
|
+
geoIpSavingCredentials,
|
|
414
|
+
hasChanges
|
|
415
|
+
}) => {
|
|
405
416
|
const [pendingCode, setPendingCode] = useState("");
|
|
406
417
|
const mode = (() => {
|
|
407
418
|
if (Array.isArray(settings.allowedCountries) && settings.allowedCountries.length > 0) {
|
|
@@ -460,6 +471,119 @@ const GeofencingPanel = ({ settings, handleChange, t }) => {
|
|
|
460
471
|
] })
|
|
461
472
|
}
|
|
462
473
|
) }),
|
|
474
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
475
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.provider.title", "GeoIP Provider") }),
|
|
476
|
+
/* @__PURE__ */ jsxs(
|
|
477
|
+
SingleSelect,
|
|
478
|
+
{
|
|
479
|
+
value: settings.geoIpProvider || "auto",
|
|
480
|
+
onChange: (value) => handleChange("geoIpProvider", value),
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.geofencing.provider.auto", "Auto") }),
|
|
483
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "local-mmdb", children: t("settings.geofencing.provider.local", "Local MMDB") }),
|
|
484
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "ipapi", children: t("settings.geofencing.provider.ipapi", "ipapi.co") }),
|
|
485
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "disabled", children: t("settings.geofencing.provider.disabled", "Disabled") })
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
] }) }),
|
|
490
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
491
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.failureMode.title", "Lookup Failure Mode") }),
|
|
492
|
+
/* @__PURE__ */ jsxs(
|
|
493
|
+
SingleSelect,
|
|
494
|
+
{
|
|
495
|
+
value: settings.geoLookupFailureMode || "auto",
|
|
496
|
+
onChange: (value) => handleChange("geoLookupFailureMode", value),
|
|
497
|
+
children: [
|
|
498
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.geofencing.failureMode.auto", "Auto") }),
|
|
499
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "allow", children: t("settings.geofencing.failureMode.allow", "Allow") }),
|
|
500
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "block", children: t("settings.geofencing.failureMode.block", "Block") })
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
)
|
|
504
|
+
] }) }),
|
|
505
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
506
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.databasePath.title", "Local MMDB Path") }),
|
|
507
|
+
/* @__PURE__ */ jsx(
|
|
508
|
+
TextInput,
|
|
509
|
+
{
|
|
510
|
+
name: "geoIpDatabasePath",
|
|
511
|
+
value: settings.geoIpDatabasePath || "",
|
|
512
|
+
onChange: (e) => handleChange("geoIpDatabasePath", e.target.value),
|
|
513
|
+
placeholder: "/var/lib/strapi/GeoLite2-Country.mmdb"
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
] }) }),
|
|
517
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(Box, { padding: 3, background: "neutral100", hasRadius: true, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
|
|
518
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", gap: 3, children: [
|
|
519
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
520
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", style: { display: "block", marginBottom: "4px" }, children: t("settings.geofencing.database.title", "Local GeoIP Database") }),
|
|
521
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: geoIpStatus?.exists ? t("settings.geofencing.database.exists", "Database is installed locally.") : t("settings.geofencing.database.missing", "No local database installed yet.") })
|
|
522
|
+
] }),
|
|
523
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: geoIpStatus?.exists ? "success100" : "warning100", children: geoIpStatus?.exists ? t("settings.geofencing.database.installed", "Installed") : t("settings.geofencing.database.notInstalled", "Missing") })
|
|
524
|
+
] }),
|
|
525
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
|
|
526
|
+
t("settings.geofencing.database.path", "Path"),
|
|
527
|
+
": ",
|
|
528
|
+
geoIpStatus?.databasePath || settings.geoIpDatabasePath || "data/GeoLite2-Country.mmdb"
|
|
529
|
+
] }),
|
|
530
|
+
geoIpStatus?.metadata?.lastModified && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
|
|
531
|
+
t("settings.geofencing.database.lastModified", "Last MaxMind update"),
|
|
532
|
+
": ",
|
|
533
|
+
geoIpStatus.metadata.lastModified
|
|
534
|
+
] }),
|
|
535
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: 3, children: [
|
|
536
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
|
|
537
|
+
TextInput,
|
|
538
|
+
{
|
|
539
|
+
name: "maxmindAccountId",
|
|
540
|
+
value: geoIpCredentials.accountId || "",
|
|
541
|
+
onChange: (e) => setGeoIpCredentials((prev) => ({ ...prev, accountId: e.target.value })),
|
|
542
|
+
placeholder: t("settings.geofencing.maxmind.accountId", "MaxMind Account ID")
|
|
543
|
+
}
|
|
544
|
+
) }),
|
|
545
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
|
|
546
|
+
TextInput,
|
|
547
|
+
{
|
|
548
|
+
name: "maxmindLicenseKey",
|
|
549
|
+
type: "password",
|
|
550
|
+
value: geoIpCredentials.licenseKey || "",
|
|
551
|
+
onChange: (e) => setGeoIpCredentials((prev) => ({ ...prev, licenseKey: e.target.value })),
|
|
552
|
+
placeholder: geoIpStatus?.hasCredentials ? t("settings.geofencing.maxmind.licenseStored", "License key stored") : t("settings.geofencing.maxmind.licenseKey", "MaxMind License Key")
|
|
553
|
+
}
|
|
554
|
+
) })
|
|
555
|
+
] }),
|
|
556
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
|
|
557
|
+
/* @__PURE__ */ jsx(
|
|
558
|
+
Button,
|
|
559
|
+
{
|
|
560
|
+
variant: "secondary",
|
|
561
|
+
onClick: onSaveGeoIpCredentials,
|
|
562
|
+
disabled: geoIpSavingCredentials || !geoIpCredentials.accountId || !geoIpCredentials.licenseKey,
|
|
563
|
+
children: geoIpSavingCredentials ? t("settings.geofencing.credentials.saving", "Saving...") : t("settings.geofencing.credentials.save", "Save MaxMind Credentials")
|
|
564
|
+
}
|
|
565
|
+
),
|
|
566
|
+
/* @__PURE__ */ jsx(
|
|
567
|
+
Button,
|
|
568
|
+
{
|
|
569
|
+
onClick: () => onUpdateGeoIp(false),
|
|
570
|
+
disabled: geoIpUpdating || !geoIpStatus?.hasCredentials || hasChanges,
|
|
571
|
+
children: geoIpUpdating ? t("settings.geofencing.database.updating", "Updating...") : t("settings.geofencing.database.update", "Download / Update DB")
|
|
572
|
+
}
|
|
573
|
+
),
|
|
574
|
+
/* @__PURE__ */ jsx(
|
|
575
|
+
Button,
|
|
576
|
+
{
|
|
577
|
+
variant: "tertiary",
|
|
578
|
+
onClick: () => onUpdateGeoIp(true),
|
|
579
|
+
disabled: geoIpUpdating || !geoIpStatus?.hasCredentials || hasChanges,
|
|
580
|
+
children: t("settings.geofencing.database.force", "Force Refresh")
|
|
581
|
+
}
|
|
582
|
+
)
|
|
583
|
+
] }),
|
|
584
|
+
hasChanges && /* @__PURE__ */ jsx(Alert, { variant: "warning", closeLabel: "", title: "", onClose: () => {
|
|
585
|
+
}, children: t("settings.geofencing.database.saveFirst", "Save settings before downloading so the server uses the latest database path.") })
|
|
586
|
+
] }) }) }),
|
|
463
587
|
/* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
464
588
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.mode.title", "Mode") }),
|
|
465
589
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
@@ -566,7 +690,6 @@ const SettingsPage = () => {
|
|
|
566
690
|
const { formatMessage } = useIntl();
|
|
567
691
|
const { get, post, put } = useFetchClient();
|
|
568
692
|
const { toggleNotification } = useNotification();
|
|
569
|
-
const { isPremium, isAdvanced, isEnterprise } = useLicense();
|
|
570
693
|
const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
571
694
|
const [loading, setLoading] = useState(true);
|
|
572
695
|
const [saving, setSaving] = useState(false);
|
|
@@ -575,6 +698,10 @@ const SettingsPage = () => {
|
|
|
575
698
|
const [activeTemplateTab, setActiveTemplateTab] = useState("suspiciousLogin");
|
|
576
699
|
const [encryptionKey, setEncryptionKey] = useState("");
|
|
577
700
|
const [showEncryptionKey, setShowEncryptionKey] = useState(false);
|
|
701
|
+
const [geoIpStatus, setGeoIpStatus] = useState(null);
|
|
702
|
+
const [geoIpCredentials, setGeoIpCredentials] = useState({ accountId: "", licenseKey: "" });
|
|
703
|
+
const [geoIpUpdating, setGeoIpUpdating] = useState(false);
|
|
704
|
+
const [geoIpSavingCredentials, setGeoIpSavingCredentials] = useState(false);
|
|
578
705
|
const [settings, setSettings] = useState({
|
|
579
706
|
inactivityTimeout: 15,
|
|
580
707
|
cleanupInterval: 30,
|
|
@@ -605,6 +732,9 @@ const SettingsPage = () => {
|
|
|
605
732
|
enableGeofencing: false,
|
|
606
733
|
allowedCountries: [],
|
|
607
734
|
blockedCountries: [],
|
|
735
|
+
geoIpProvider: "auto",
|
|
736
|
+
geoIpDatabasePath: "",
|
|
737
|
+
geoLookupFailureMode: "auto",
|
|
608
738
|
emailTemplates: {
|
|
609
739
|
suspiciousLogin: { subject: "", html: "", text: "" },
|
|
610
740
|
newLocation: { subject: "", html: "", text: "" },
|
|
@@ -637,8 +767,10 @@ const SettingsPage = () => {
|
|
|
637
767
|
});
|
|
638
768
|
}
|
|
639
769
|
setSettings((prev) => ({ ...prev, ...loadedSettings }));
|
|
770
|
+
await fetchGeoIpStatus();
|
|
640
771
|
} else {
|
|
641
772
|
setSettings((prev) => ({ ...prev, emailTemplates: getDefaultTemplates() }));
|
|
773
|
+
await fetchGeoIpStatus();
|
|
642
774
|
}
|
|
643
775
|
} catch (err) {
|
|
644
776
|
console.error("[Settings] Error loading from backend:", err);
|
|
@@ -651,6 +783,21 @@ const SettingsPage = () => {
|
|
|
651
783
|
setLoading(false);
|
|
652
784
|
}
|
|
653
785
|
};
|
|
786
|
+
const fetchGeoIpStatus = async () => {
|
|
787
|
+
try {
|
|
788
|
+
const response = await get(`/${pluginId}/geoip/status`);
|
|
789
|
+
if (response?.data?.status) {
|
|
790
|
+
const status = response.data.status;
|
|
791
|
+
setGeoIpStatus(status);
|
|
792
|
+
setGeoIpCredentials((prev) => ({
|
|
793
|
+
accountId: prev.accountId || status.accountId || "",
|
|
794
|
+
licenseKey: ""
|
|
795
|
+
}));
|
|
796
|
+
}
|
|
797
|
+
} catch (err) {
|
|
798
|
+
console.error("[Settings] Error loading GeoIP status:", err);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
654
801
|
const handleChange = (key, value) => {
|
|
655
802
|
setSettings((prev) => ({ ...prev, [key]: value }));
|
|
656
803
|
setHasChanges(true);
|
|
@@ -660,6 +807,7 @@ const SettingsPage = () => {
|
|
|
660
807
|
try {
|
|
661
808
|
const response = await put(`/${pluginId}/settings`, settings);
|
|
662
809
|
if (response?.data?.success) {
|
|
810
|
+
await fetchGeoIpStatus();
|
|
663
811
|
toggleNotification({
|
|
664
812
|
type: "success",
|
|
665
813
|
message: t("notifications.success.saved", "Settings saved successfully to database!")
|
|
@@ -683,6 +831,49 @@ const SettingsPage = () => {
|
|
|
683
831
|
setSaving(false);
|
|
684
832
|
}
|
|
685
833
|
};
|
|
834
|
+
const handleSaveGeoIpCredentials = async () => {
|
|
835
|
+
setGeoIpSavingCredentials(true);
|
|
836
|
+
try {
|
|
837
|
+
const response = await put(`/${pluginId}/geoip/credentials`, geoIpCredentials);
|
|
838
|
+
if (response?.data?.success) {
|
|
839
|
+
toggleNotification({
|
|
840
|
+
type: "success",
|
|
841
|
+
message: t("notifications.success.geoipCredentialsSaved", "MaxMind credentials saved.")
|
|
842
|
+
});
|
|
843
|
+
setGeoIpCredentials((prev) => ({ ...prev, licenseKey: "" }));
|
|
844
|
+
await fetchGeoIpStatus();
|
|
845
|
+
}
|
|
846
|
+
} catch (err) {
|
|
847
|
+
console.error("[Settings] Error saving GeoIP credentials:", err);
|
|
848
|
+
toggleNotification({
|
|
849
|
+
type: "danger",
|
|
850
|
+
message: t("notifications.error.geoipCredentials", "Failed to save MaxMind credentials.")
|
|
851
|
+
});
|
|
852
|
+
} finally {
|
|
853
|
+
setGeoIpSavingCredentials(false);
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
const handleUpdateGeoIpDatabase = async (force = false) => {
|
|
857
|
+
setGeoIpUpdating(true);
|
|
858
|
+
try {
|
|
859
|
+
const response = await post(`/${pluginId}/geoip/update`, { force });
|
|
860
|
+
if (response?.data?.success) {
|
|
861
|
+
toggleNotification({
|
|
862
|
+
type: "success",
|
|
863
|
+
message: response.data.result?.changed ? t("notifications.success.geoipUpdated", "GeoIP database updated.") : t("notifications.success.geoipCurrent", "GeoIP database is already current.")
|
|
864
|
+
});
|
|
865
|
+
await fetchGeoIpStatus();
|
|
866
|
+
}
|
|
867
|
+
} catch (err) {
|
|
868
|
+
console.error("[Settings] Error updating GeoIP database:", err);
|
|
869
|
+
toggleNotification({
|
|
870
|
+
type: "danger",
|
|
871
|
+
message: t("notifications.error.geoipUpdate", "Failed to update GeoIP database.")
|
|
872
|
+
});
|
|
873
|
+
} finally {
|
|
874
|
+
setGeoIpUpdating(false);
|
|
875
|
+
}
|
|
876
|
+
};
|
|
686
877
|
const handleReset = () => {
|
|
687
878
|
fetchSettings();
|
|
688
879
|
setHasChanges(false);
|
|
@@ -754,29 +945,6 @@ const SettingsPage = () => {
|
|
|
754
945
|
] })
|
|
755
946
|
] }) }),
|
|
756
947
|
/* @__PURE__ */ jsxs(Box, { paddingTop: 6, paddingLeft: 6, paddingRight: 6, paddingBottom: 10, children: [
|
|
757
|
-
/* @__PURE__ */ jsx(Box, { padding: 4, background: "primary50", hasRadius: true, style: { marginBottom: "24px", border: "1px solid rgba(14, 165, 233, 0.3)" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "center", children: [
|
|
758
|
-
/* @__PURE__ */ jsx(Information, { style: { width: "20px", height: "20px", color: "var(--colors-primary600, #0284C7)" } }),
|
|
759
|
-
/* @__PURE__ */ jsxs(Box, { children: [
|
|
760
|
-
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "primary700", style: { marginBottom: "4px" }, children: t("settings.license.title", "Current License Status") }),
|
|
761
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
|
|
762
|
-
/* @__PURE__ */ jsxs(Badge, { backgroundColor: isPremium ? "success100" : "neutral100", textColor: isPremium ? "success700" : "neutral600", children: [
|
|
763
|
-
isPremium ? "✓" : "✗",
|
|
764
|
-
" ",
|
|
765
|
-
t("settings.license.premium", "Premium")
|
|
766
|
-
] }),
|
|
767
|
-
/* @__PURE__ */ jsxs(Badge, { backgroundColor: isAdvanced ? "primary100" : "neutral100", textColor: isAdvanced ? "primary700" : "neutral600", children: [
|
|
768
|
-
isAdvanced ? "✓" : "✗",
|
|
769
|
-
" ",
|
|
770
|
-
t("settings.license.advanced", "Advanced")
|
|
771
|
-
] }),
|
|
772
|
-
/* @__PURE__ */ jsxs(Badge, { backgroundColor: isEnterprise ? "secondary100" : "neutral100", textColor: isEnterprise ? "secondary700" : "neutral600", children: [
|
|
773
|
-
isEnterprise ? "✓" : "✗",
|
|
774
|
-
" ",
|
|
775
|
-
t("settings.license.enterprise", "Enterprise")
|
|
776
|
-
] })
|
|
777
|
-
] })
|
|
778
|
-
] })
|
|
779
|
-
] }) }),
|
|
780
948
|
/* @__PURE__ */ jsxs(Accordion.Root, { type: "multiple", defaultValue: ["general", "security", "email"], children: [
|
|
781
949
|
/* @__PURE__ */ jsxs(Accordion.Item, { value: "general", children: [
|
|
782
950
|
/* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
|
|
@@ -1211,66 +1379,64 @@ const SettingsPage = () => {
|
|
|
1211
1379
|
] })
|
|
1212
1380
|
}
|
|
1213
1381
|
) }),
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1382
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
|
|
1383
|
+
ToggleCard,
|
|
1384
|
+
{
|
|
1385
|
+
$active: settings.enableGeolocation,
|
|
1386
|
+
onClick: () => handleChange("enableGeolocation", !settings.enableGeolocation),
|
|
1387
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
|
|
1388
|
+
/* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.enableGeolocation, children: /* @__PURE__ */ jsx(
|
|
1389
|
+
Toggle,
|
|
1390
|
+
{
|
|
1391
|
+
checked: settings.enableGeolocation,
|
|
1392
|
+
onChange: () => handleChange("enableGeolocation", !settings.enableGeolocation)
|
|
1393
|
+
}
|
|
1394
|
+
) }),
|
|
1395
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
|
|
1396
|
+
/* @__PURE__ */ jsx(
|
|
1397
|
+
Typography,
|
|
1223
1398
|
{
|
|
1224
|
-
|
|
1225
|
-
|
|
1399
|
+
variant: "delta",
|
|
1400
|
+
fontWeight: "bold",
|
|
1401
|
+
textColor: settings.enableGeolocation ? "success700" : "neutral800",
|
|
1402
|
+
style: { fontSize: "16px" },
|
|
1403
|
+
children: t("settings.security.geolocation.title", "IP Geolocation")
|
|
1226
1404
|
}
|
|
1227
|
-
)
|
|
1228
|
-
/* @__PURE__ */
|
|
1229
|
-
/* @__PURE__ */ jsx(
|
|
1230
|
-
Typography,
|
|
1231
|
-
{
|
|
1232
|
-
variant: "delta",
|
|
1233
|
-
fontWeight: "bold",
|
|
1234
|
-
textColor: settings.enableGeolocation ? "success700" : "neutral800",
|
|
1235
|
-
style: { fontSize: "16px" },
|
|
1236
|
-
children: t("settings.security.geolocation.title", "IP Geolocation")
|
|
1237
|
-
}
|
|
1238
|
-
),
|
|
1239
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.geolocation.description", "Fetch location data for each session (Premium)") })
|
|
1240
|
-
] })
|
|
1405
|
+
),
|
|
1406
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.geolocation.description", "Fetch location data for each session") })
|
|
1241
1407
|
] })
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1408
|
+
] })
|
|
1409
|
+
}
|
|
1410
|
+
) }),
|
|
1411
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
|
|
1412
|
+
ToggleCard,
|
|
1413
|
+
{
|
|
1414
|
+
$active: settings.enableSecurityScoring,
|
|
1415
|
+
onClick: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring),
|
|
1416
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
|
|
1417
|
+
/* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.enableSecurityScoring, children: /* @__PURE__ */ jsx(
|
|
1418
|
+
Toggle,
|
|
1419
|
+
{
|
|
1420
|
+
checked: settings.enableSecurityScoring,
|
|
1421
|
+
onChange: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring)
|
|
1422
|
+
}
|
|
1423
|
+
) }),
|
|
1424
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
|
|
1425
|
+
/* @__PURE__ */ jsx(
|
|
1426
|
+
Typography,
|
|
1252
1427
|
{
|
|
1253
|
-
|
|
1254
|
-
|
|
1428
|
+
variant: "delta",
|
|
1429
|
+
fontWeight: "bold",
|
|
1430
|
+
textColor: settings.enableSecurityScoring ? "success700" : "neutral800",
|
|
1431
|
+
style: { fontSize: "16px" },
|
|
1432
|
+
children: t("settings.security.scoring.title", "Security Scoring")
|
|
1255
1433
|
}
|
|
1256
|
-
)
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */ jsx(
|
|
1259
|
-
Typography,
|
|
1260
|
-
{
|
|
1261
|
-
variant: "delta",
|
|
1262
|
-
fontWeight: "bold",
|
|
1263
|
-
textColor: settings.enableSecurityScoring ? "success700" : "neutral800",
|
|
1264
|
-
style: { fontSize: "16px" },
|
|
1265
|
-
children: t("settings.security.scoring.title", "Security Scoring")
|
|
1266
|
-
}
|
|
1267
|
-
),
|
|
1268
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.scoring.description", "Calculate security scores and detect threats (Premium)") })
|
|
1269
|
-
] })
|
|
1434
|
+
),
|
|
1435
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.scoring.description", "Calculate security scores and detect threats") })
|
|
1270
1436
|
] })
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1437
|
+
] })
|
|
1438
|
+
}
|
|
1439
|
+
) })
|
|
1274
1440
|
] }) }),
|
|
1275
1441
|
/* @__PURE__ */ jsx(Grid.Root, { gap: 6, children: /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
1276
1442
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: [
|
|
@@ -1282,11 +1448,11 @@ const SettingsPage = () => {
|
|
|
1282
1448
|
{
|
|
1283
1449
|
value: settings.maxFailedLogins,
|
|
1284
1450
|
onValueChange: (val) => handleChange("maxFailedLogins", val),
|
|
1285
|
-
min:
|
|
1451
|
+
min: 0,
|
|
1286
1452
|
max: 20
|
|
1287
1453
|
}
|
|
1288
1454
|
),
|
|
1289
|
-
/* @__PURE__ */ jsx(Box, { padding: 2, background: "warning50", style: { borderRadius: "4px", marginTop: "8px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", style: { fontSize: "11px" }, children: t("settings.security.maxFailed.hint", "User will be blocked after {count} failed attempts", { count: settings.maxFailedLogins }) }) })
|
|
1455
|
+
/* @__PURE__ */ jsx(Box, { padding: 2, background: "warning50", style: { borderRadius: "4px", marginTop: "8px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", style: { fontSize: "11px" }, children: Number(settings.maxFailedLogins) === 0 ? t("settings.security.maxFailed.disabled", "Login lockout is disabled") : t("settings.security.maxFailed.hint", "User will be blocked after {count} failed attempts", { count: settings.maxFailedLogins }) }) })
|
|
1290
1456
|
] }) }) })
|
|
1291
1457
|
] }) })
|
|
1292
1458
|
] }),
|
|
@@ -1304,17 +1470,25 @@ const SettingsPage = () => {
|
|
|
1304
1470
|
{
|
|
1305
1471
|
settings,
|
|
1306
1472
|
handleChange,
|
|
1307
|
-
t
|
|
1473
|
+
t,
|
|
1474
|
+
geoIpStatus,
|
|
1475
|
+
geoIpCredentials,
|
|
1476
|
+
setGeoIpCredentials,
|
|
1477
|
+
onSaveGeoIpCredentials: handleSaveGeoIpCredentials,
|
|
1478
|
+
onUpdateGeoIp: handleUpdateGeoIpDatabase,
|
|
1479
|
+
geoIpUpdating,
|
|
1480
|
+
geoIpSavingCredentials,
|
|
1481
|
+
hasChanges
|
|
1308
1482
|
}
|
|
1309
1483
|
) }) })
|
|
1310
1484
|
] }),
|
|
1311
|
-
|
|
1485
|
+
/* @__PURE__ */ jsxs(Accordion.Item, { value: "email", children: [
|
|
1312
1486
|
/* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
|
|
1313
1487
|
Accordion.Trigger,
|
|
1314
1488
|
{
|
|
1315
1489
|
icon: Mail,
|
|
1316
1490
|
description: t("settings.email.description", "Email alerts for security events"),
|
|
1317
|
-
children: t("settings.email.title", "Email Notifications
|
|
1491
|
+
children: t("settings.email.title", "Email Notifications")
|
|
1318
1492
|
}
|
|
1319
1493
|
) }),
|
|
1320
1494
|
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Box, { padding: 6, children: [
|
|
@@ -1719,13 +1893,13 @@ const SettingsPage = () => {
|
|
|
1719
1893
|
] })
|
|
1720
1894
|
] }) })
|
|
1721
1895
|
] }),
|
|
1722
|
-
|
|
1896
|
+
/* @__PURE__ */ jsxs(Accordion.Item, { value: "webhooks", children: [
|
|
1723
1897
|
/* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
|
|
1724
1898
|
Accordion.Trigger,
|
|
1725
1899
|
{
|
|
1726
1900
|
icon: Code,
|
|
1727
1901
|
description: t("settings.webhooks.description", "Discord & Slack integration"),
|
|
1728
|
-
children: t("settings.webhooks.title", "Webhook Integration
|
|
1902
|
+
children: t("settings.webhooks.title", "Webhook Integration")
|
|
1729
1903
|
}
|
|
1730
1904
|
) }),
|
|
1731
1905
|
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Box, { padding: 6, children: [
|