strapi-identity 0.4.2 → 0.5.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/dist/admin/{AdminReset-BiWQDTRv.js → AdminReset-BoWx0F06.js} +1 -1
- package/dist/admin/{AdminReset-DOmsyqwQ.mjs → AdminReset-D4NNnBDS.mjs} +1 -1
- package/dist/admin/{ProfileToggle-BUqs_hxZ.js → ProfileToggle-DtjyJRWN.js} +1 -1
- package/dist/admin/{ProfileToggle-k0d-caPC.mjs → ProfileToggle-NJZgrDT_.mjs} +1 -1
- package/dist/admin/{SettingsPage-DVVkN1xw.js → SettingsPage-BXl7gVGV.js} +1 -1
- package/dist/admin/{SettingsPage-Dm_llkYv.mjs → SettingsPage-CZuOMYvG.mjs} +1 -1
- package/dist/admin/{index-B9P8S4CX.js → index-BeqHh5Gz.js} +22 -15
- package/dist/admin/{index-DpIJdETG.mjs → index-CKG2ZxYT.mjs} +22 -15
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/ConfirmModal/ConfirmModal.d.ts +9 -0
- package/dist/admin/src/components/ConfirmModal/index.d.ts +1 -0
- package/dist/admin/src/components/EmailOTPModal/EmailOTPModal.d.ts +8 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/InputOTP.d.ts +11 -0
- package/dist/admin/src/components/RemoveModal/RemoveModal.d.ts +6 -0
- package/dist/admin/src/components/RemoveModal/index.d.ts +1 -0
- package/dist/admin/src/components/WarningAlert/WarningAlert.d.ts +10 -0
- package/dist/admin/src/components/WarningAlert/index.d.ts +1 -0
- package/dist/admin/src/injection/AdminReset.d.ts +4 -0
- package/dist/admin/src/injection/ProfileToggle.d.ts +2 -0
- package/dist/admin/src/pages/EnforcedPage.d.ts +13 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/public/VerifyPage.d.ts +12 -0
- package/dist/admin/src/settings/SettingsPage.d.ts +1 -0
- package/dist/admin/src/utils/getTranslation.d.ts +2 -0
- package/dist/admin/src/utils/tokenHelpers.d.ts +12 -0
- package/dist/server/index.js +71 -47
- package/dist/server/index.mjs +71 -47
- package/dist/server/src/bootstrap.d.ts +3 -0
- package/dist/server/src/config/index.d.ts +3 -0
- package/dist/server/src/content-types/config/index.d.ts +72 -0
- package/dist/server/src/content-types/config/schema.json.d.ts +72 -0
- package/dist/server/src/content-types/email-otp/index.d.ts +48 -0
- package/dist/server/src/content-types/email-otp/schema.json.d.ts +48 -0
- package/dist/server/src/content-types/index.d.ts +3 -0
- package/dist/server/src/content-types/mfa/index.d.ts +55 -0
- package/dist/server/src/content-types/mfa/schema.json.d.ts +55 -0
- package/dist/server/src/content-types/temp-mfa/index.d.ts +35 -0
- package/dist/server/src/content-types/temp-mfa/schema.json.d.ts +35 -0
- package/dist/server/src/controllers/admin.d.ts +4 -0
- package/dist/server/src/controllers/config.d.ts +4 -0
- package/dist/server/src/controllers/controller.d.ts +8 -0
- package/dist/server/src/controllers/index.d.ts +3 -0
- package/dist/server/src/destroy.d.ts +3 -0
- package/dist/server/src/middlewares/index.d.ts +3 -0
- package/dist/server/src/policies/has-mfa.d.ts +3 -0
- package/dist/server/src/policies/index.d.ts +3 -0
- package/dist/server/src/register.d.ts +3 -0
- package/dist/server/src/routes/admin/admin.json.d.ts +35 -0
- package/dist/server/src/routes/admin/config.json.d.ts +50 -0
- package/dist/server/src/routes/admin/index.d.ts +3 -0
- package/dist/server/src/routes/admin/mfa.json.d.ts +94 -0
- package/dist/server/src/routes/index.d.ts +3 -0
- package/dist/server/src/services/admin.d.ts +11 -0
- package/dist/server/src/services/config.d.ts +57 -0
- package/dist/server/src/services/email.d.ts +8 -0
- package/dist/server/src/services/index.d.ts +3 -0
- package/dist/server/src/services/mfa.d.ts +82 -0
- package/package.json +6 -5
|
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const WarningAlert = require("./WarningAlert-DFE5euMk.js");
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
|
7
|
-
const index = require("./index-
|
|
7
|
+
const index = require("./index-BeqHh5Gz.js");
|
|
8
8
|
const reactIntl = require("react-intl");
|
|
9
9
|
const AdminReset = ({ id }) => {
|
|
10
10
|
const { formatMessage } = reactIntl.useIntl();
|
|
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
3
|
import { W as WarningAlert } from "./WarningAlert-VU011LVF.mjs";
|
|
4
4
|
import { Box, Flex, Typography, Grid, Button } from "@strapi/design-system";
|
|
5
|
-
import { g as getToken, a as getTranslation } from "./index-
|
|
5
|
+
import { g as getToken, a as getTranslation } from "./index-CKG2ZxYT.mjs";
|
|
6
6
|
import { useIntl } from "react-intl";
|
|
7
7
|
const AdminReset = ({ id }) => {
|
|
8
8
|
const { formatMessage } = useIntl();
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const designSystem = require("@strapi/design-system");
|
|
6
|
-
const index = require("./index-
|
|
6
|
+
const index = require("./index-BeqHh5Gz.js");
|
|
7
7
|
const reactIntl = require("react-intl");
|
|
8
8
|
function RemoveModal({ open, onOpenChange, onSubmit }) {
|
|
9
9
|
const { formatMessage } = reactIntl.useIntl();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
3
|
import { Modal, Flex, Typography, TextInput, Button, Box, Grid, Field, Toggle } from "@strapi/design-system";
|
|
4
|
-
import { a as getTranslation, I as InputOTP, b as InputOTPGroup, c as InputOTPSlot, d as InputOTPSeparator, g as getToken, C as ConfirmModal, E as EmailOTPModal } from "./index-
|
|
4
|
+
import { a as getTranslation, I as InputOTP, b as InputOTPGroup, c as InputOTPSlot, d as InputOTPSeparator, g as getToken, C as ConfirmModal, E as EmailOTPModal } from "./index-CKG2ZxYT.mjs";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
6
|
function RemoveModal({ open, onOpenChange, onSubmit }) {
|
|
7
7
|
const { formatMessage } = useIntl();
|
|
@@ -6,7 +6,7 @@ const WarningAlert = require("./WarningAlert-DFE5euMk.js");
|
|
|
6
6
|
const admin = require("@strapi/strapi/admin");
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
|
-
const index = require("./index-
|
|
9
|
+
const index = require("./index-BeqHh5Gz.js");
|
|
10
10
|
const reactIntl = require("react-intl");
|
|
11
11
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
12
12
|
var lodash$1 = { exports: {} };
|
|
@@ -4,7 +4,7 @@ import { W as WarningAlert } from "./WarningAlert-VU011LVF.mjs";
|
|
|
4
4
|
import { useNotification, Page, Layouts } from "@strapi/strapi/admin";
|
|
5
5
|
import { Button, Flex, Typography, Grid, Field, Toggle, TextInput, Textarea } from "@strapi/design-system";
|
|
6
6
|
import { Check } from "@strapi/icons";
|
|
7
|
-
import { g as getToken, a as getTranslation } from "./index-
|
|
7
|
+
import { g as getToken, a as getTranslation } from "./index-CKG2ZxYT.mjs";
|
|
8
8
|
import { useIntl } from "react-intl";
|
|
9
9
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
10
10
|
var lodash$1 = { exports: {} };
|
|
@@ -1370,7 +1370,8 @@ const VerifyPage = ({ fallbackIcon }) => {
|
|
|
1370
1370
|
`${response.status} ${response.statusText}: ${data.error || "Unknown error"}`
|
|
1371
1371
|
);
|
|
1372
1372
|
}
|
|
1373
|
-
const
|
|
1373
|
+
const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
|
|
1374
|
+
const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
|
|
1374
1375
|
window.location.replace(target);
|
|
1375
1376
|
} catch (error2) {
|
|
1376
1377
|
setError(
|
|
@@ -1383,20 +1384,26 @@ const VerifyPage = ({ fallbackIcon }) => {
|
|
|
1383
1384
|
}
|
|
1384
1385
|
};
|
|
1385
1386
|
React.useEffect(() => {
|
|
1386
|
-
|
|
1387
|
-
const [name, value] = cookie.split("=");
|
|
1388
|
-
return name === "strapi_admin_mfa" ? value.trim() : acc;
|
|
1389
|
-
}, null);
|
|
1390
|
-
if (auth?.token || !mfaToken) {
|
|
1387
|
+
if (auth?.token) {
|
|
1391
1388
|
window.location.replace("/admin");
|
|
1392
1389
|
return;
|
|
1393
1390
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1391
|
+
const ac = new AbortController();
|
|
1392
|
+
(async () => {
|
|
1393
|
+
try {
|
|
1394
|
+
const response = await fetch("/strapi-identity/verify/info", { signal: ac.signal });
|
|
1395
|
+
if (!response.ok) {
|
|
1396
|
+
window.location.replace("/admin");
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
const data = await response.json();
|
|
1400
|
+
setMfaType(data.data?.mfaType || null);
|
|
1401
|
+
} catch (error2) {
|
|
1402
|
+
if (error2 instanceof DOMException && error2.name === "AbortError") return;
|
|
1403
|
+
window.location.replace("/admin");
|
|
1404
|
+
}
|
|
1405
|
+
})();
|
|
1406
|
+
return () => ac.abort();
|
|
1400
1407
|
}, [auth?.token]);
|
|
1401
1408
|
const handleResend = async () => {
|
|
1402
1409
|
setResendLoading(true);
|
|
@@ -1958,7 +1965,7 @@ const plugin = {
|
|
|
1958
1965
|
},
|
|
1959
1966
|
id: "strapi-identity-settings",
|
|
1960
1967
|
to: `/${PLUGIN_ID}`,
|
|
1961
|
-
Component: () => Promise.resolve().then(() => require("./SettingsPage-
|
|
1968
|
+
Component: () => Promise.resolve().then(() => require("./SettingsPage-BXl7gVGV.js")),
|
|
1962
1969
|
permissions: [{ action: "plugin::strapi-identity.settings.update" }]
|
|
1963
1970
|
});
|
|
1964
1971
|
app.addMiddlewares([mfaRedirect]);
|
|
@@ -1967,14 +1974,14 @@ const plugin = {
|
|
|
1967
1974
|
id: "profile-toggle",
|
|
1968
1975
|
route: "/admin/me",
|
|
1969
1976
|
selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
|
|
1970
|
-
Component: () => Promise.resolve().then(() => require("./ProfileToggle-
|
|
1977
|
+
Component: () => Promise.resolve().then(() => require("./ProfileToggle-DtjyJRWN.js"))
|
|
1971
1978
|
});
|
|
1972
1979
|
injections.registerRoute({
|
|
1973
1980
|
id: "admin-reset",
|
|
1974
1981
|
route: "/admin/settings/users/:id",
|
|
1975
1982
|
selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
|
|
1976
1983
|
permissions: [{ action: "plugin::strapi-identity.settings.update" }],
|
|
1977
|
-
Component: () => Promise.resolve().then(() => require("./AdminReset-
|
|
1984
|
+
Component: () => Promise.resolve().then(() => require("./AdminReset-BoWx0F06.js"))
|
|
1978
1985
|
});
|
|
1979
1986
|
InjectVerify(app);
|
|
1980
1987
|
InjectEnforced(app);
|
|
@@ -1350,7 +1350,8 @@ const VerifyPage = ({ fallbackIcon }) => {
|
|
|
1350
1350
|
`${response.status} ${response.statusText}: ${data.error || "Unknown error"}`
|
|
1351
1351
|
);
|
|
1352
1352
|
}
|
|
1353
|
-
const
|
|
1353
|
+
const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
|
|
1354
|
+
const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
|
|
1354
1355
|
window.location.replace(target);
|
|
1355
1356
|
} catch (error2) {
|
|
1356
1357
|
setError(
|
|
@@ -1363,20 +1364,26 @@ const VerifyPage = ({ fallbackIcon }) => {
|
|
|
1363
1364
|
}
|
|
1364
1365
|
};
|
|
1365
1366
|
useEffect(() => {
|
|
1366
|
-
|
|
1367
|
-
const [name, value] = cookie.split("=");
|
|
1368
|
-
return name === "strapi_admin_mfa" ? value.trim() : acc;
|
|
1369
|
-
}, null);
|
|
1370
|
-
if (auth?.token || !mfaToken) {
|
|
1367
|
+
if (auth?.token) {
|
|
1371
1368
|
window.location.replace("/admin");
|
|
1372
1369
|
return;
|
|
1373
1370
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1371
|
+
const ac = new AbortController();
|
|
1372
|
+
(async () => {
|
|
1373
|
+
try {
|
|
1374
|
+
const response = await fetch("/strapi-identity/verify/info", { signal: ac.signal });
|
|
1375
|
+
if (!response.ok) {
|
|
1376
|
+
window.location.replace("/admin");
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
const data = await response.json();
|
|
1380
|
+
setMfaType(data.data?.mfaType || null);
|
|
1381
|
+
} catch (error2) {
|
|
1382
|
+
if (error2 instanceof DOMException && error2.name === "AbortError") return;
|
|
1383
|
+
window.location.replace("/admin");
|
|
1384
|
+
}
|
|
1385
|
+
})();
|
|
1386
|
+
return () => ac.abort();
|
|
1380
1387
|
}, [auth?.token]);
|
|
1381
1388
|
const handleResend = async () => {
|
|
1382
1389
|
setResendLoading(true);
|
|
@@ -1938,7 +1945,7 @@ const plugin = {
|
|
|
1938
1945
|
},
|
|
1939
1946
|
id: "strapi-identity-settings",
|
|
1940
1947
|
to: `/${PLUGIN_ID}`,
|
|
1941
|
-
Component: () => import("./SettingsPage-
|
|
1948
|
+
Component: () => import("./SettingsPage-CZuOMYvG.mjs"),
|
|
1942
1949
|
permissions: [{ action: "plugin::strapi-identity.settings.update" }]
|
|
1943
1950
|
});
|
|
1944
1951
|
app.addMiddlewares([mfaRedirect]);
|
|
@@ -1947,14 +1954,14 @@ const plugin = {
|
|
|
1947
1954
|
id: "profile-toggle",
|
|
1948
1955
|
route: "/admin/me",
|
|
1949
1956
|
selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
|
|
1950
|
-
Component: () => import("./ProfileToggle-
|
|
1957
|
+
Component: () => import("./ProfileToggle-NJZgrDT_.mjs")
|
|
1951
1958
|
});
|
|
1952
1959
|
injections.registerRoute({
|
|
1953
1960
|
id: "admin-reset",
|
|
1954
1961
|
route: "/admin/settings/users/:id",
|
|
1955
1962
|
selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
|
|
1956
1963
|
permissions: [{ action: "plugin::strapi-identity.settings.update" }],
|
|
1957
|
-
Component: () => import("./AdminReset-
|
|
1964
|
+
Component: () => import("./AdminReset-D4NNnBDS.mjs")
|
|
1958
1965
|
});
|
|
1959
1966
|
InjectVerify(app);
|
|
1960
1967
|
InjectEnforced(app);
|
package/dist/admin/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-BeqHh5Gz.js");
|
|
4
4
|
require("strapi-admin-portal");
|
|
5
5
|
exports.default = index.plugin;
|
package/dist/admin/index.mjs
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ConfirmModalProps {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
onOpenChange?: (open: boolean) => void;
|
|
4
|
+
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
5
|
+
qrCodeUri?: string | null;
|
|
6
|
+
secret?: string | null;
|
|
7
|
+
passcodes?: string[] | null;
|
|
8
|
+
}
|
|
9
|
+
export default function ConfirmModal({ open, onOpenChange, onSubmit, qrCodeUri, secret, passcodes, }: ConfirmModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type ConfirmModalProps } from './ConfirmModal';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface EmailOTPModalProps {
|
|
2
|
+
mode: 'setup' | 'disable';
|
|
3
|
+
open: boolean;
|
|
4
|
+
email: string;
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
onSuccess: () => void;
|
|
7
|
+
}
|
|
8
|
+
export default function EmailOTPModal({ mode, open, email, onOpenChange, onSuccess, }: EmailOTPModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OTPInput } from 'input-otp';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare function InputOTP({ className, containerClassName, ...props }: React.ComponentPropsWithoutRef<typeof OTPInput> & {
|
|
4
|
+
containerClassName?: string;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<'div'> & {
|
|
8
|
+
index: number;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface RemoveModalProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onOpenChange: (open: boolean) => void;
|
|
4
|
+
onSubmit: React.FormEventHandler<HTMLFormElement>;
|
|
5
|
+
}
|
|
6
|
+
export default function RemoveModal({ open, onOpenChange, onSubmit }: RemoveModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type RemoveModalProps } from './RemoveModal';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface WarningAlertProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
title?: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
confirmText?: string;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
onConfirm: () => void;
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
}
|
|
10
|
+
export default function WarningAlert({ open, title, children, confirmText, loading, onConfirm, onCancel, }: WarningAlertProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type WarningAlertProps } from './WarningAlert';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StrapiApp } from '@strapi/strapi/admin';
|
|
2
|
+
import { RouteObject } from 'react-router-dom';
|
|
3
|
+
export interface InjectPublicRouter extends Omit<StrapiApp['router'], 'router'> {
|
|
4
|
+
router: {
|
|
5
|
+
routes: RouteObject[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Inject the enforced MFA page route into the Strapi admin router
|
|
10
|
+
*/
|
|
11
|
+
export declare const InjectEnforced: (app: StrapiApp) => Promise<void>;
|
|
12
|
+
declare const EnforcedPage: () => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
export { EnforcedPage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_ID = "strapi-identity";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrapiApp } from '@strapi/strapi/admin';
|
|
2
|
+
import { RouteObject } from 'react-router-dom';
|
|
3
|
+
export interface InjectPublicRouter extends Omit<StrapiApp['router'], 'router'> {
|
|
4
|
+
router: {
|
|
5
|
+
routes: RouteObject[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Inject the verify page route into the Strapi router
|
|
10
|
+
* @param router StrapiApp router instance
|
|
11
|
+
*/
|
|
12
|
+
export declare const InjectVerify: (app: StrapiApp) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SettingsPage(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the value of a specified cookie.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name of the cookie to retrieve.
|
|
5
|
+
* @returns The decoded cookie value if found, otherwise null.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getCookieValue: (name: string) => string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the JWT token from localStorage or cookies.
|
|
10
|
+
* @returns The JWT token if found, otherwise null.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getToken: () => string | null;
|
package/dist/server/index.js
CHANGED
|
@@ -9650,7 +9650,7 @@ const replaceLogin = (route2, secret2, domain) => {
|
|
|
9650
9650
|
await strapi.service("plugin::strapi-identity.email").send(adminUser.email, otp);
|
|
9651
9651
|
}
|
|
9652
9652
|
} catch (err) {
|
|
9653
|
-
|
|
9653
|
+
strapi.log.error("Error sending login email OTP");
|
|
9654
9654
|
}
|
|
9655
9655
|
}
|
|
9656
9656
|
ctx.res.removeHeader("set-cookie");
|
|
@@ -9664,7 +9664,7 @@ const replaceLogin = (route2, secret2, domain) => {
|
|
|
9664
9664
|
const newToken = jwt.sign(newPayload, secret2, { expiresIn: "5m" });
|
|
9665
9665
|
const expires = new Date(Date.now() + 5 * 60 * 1e3);
|
|
9666
9666
|
const secure = strapi.config.get("admin.auth.cookie.secure") ?? process.env.NODE_ENV === "production";
|
|
9667
|
-
const opt = { domain, httpOnly:
|
|
9667
|
+
const opt = { domain, httpOnly: true, overwrite: true, secure, expires };
|
|
9668
9668
|
ctx.cookies.set("strapi_admin_mfa", newToken, opt);
|
|
9669
9669
|
ctx.body.data = { data: {}, error: null };
|
|
9670
9670
|
});
|
|
@@ -9710,7 +9710,6 @@ const registerMiddlewares = (server) => {
|
|
|
9710
9710
|
"/admin/users/me",
|
|
9711
9711
|
"/strapi-identity/status",
|
|
9712
9712
|
"/strapi-identity/config",
|
|
9713
|
-
"/strapi-identity/config/enabled",
|
|
9714
9713
|
"/strapi-identity/enable",
|
|
9715
9714
|
"/strapi-identity/setup",
|
|
9716
9715
|
"/strapi-identity/enable-email",
|
|
@@ -9718,7 +9717,6 @@ const registerMiddlewares = (server) => {
|
|
|
9718
9717
|
];
|
|
9719
9718
|
const isAllowed = allowedPaths.includes(ctx.path) || // Static assets (JS, CSS, images, fonts, sourcemaps)
|
|
9720
9719
|
/\.(mjs|js|css|png|jpg|jpeg|gif|svg|ico|woff2?|ttf|eot|map)(\?.*)?$/.test(ctx.path) || ctx.path.startsWith("/admin/@") || ctx.path.startsWith("/admin/src/");
|
|
9721
|
-
if (!isAllowed) console.log(ctx.path);
|
|
9722
9720
|
if (!isAllowed) {
|
|
9723
9721
|
if (ctx.accepts("html") && ctx.path.startsWith("/admin")) {
|
|
9724
9722
|
ctx.redirect("/admin/strapi-identity/enforced");
|
|
@@ -9845,7 +9843,7 @@ const config$2 = ({ strapi: strapi2 }) => ({
|
|
|
9845
9843
|
ctx.status = 200;
|
|
9846
9844
|
ctx.body = { data: enabled, error: null };
|
|
9847
9845
|
} catch (error) {
|
|
9848
|
-
|
|
9846
|
+
strapi2.log.error("Error checking if Strapi Identity is enabled");
|
|
9849
9847
|
ctx.status = 500;
|
|
9850
9848
|
ctx.body = { data: null, error: "Server Error" };
|
|
9851
9849
|
}
|
|
@@ -9856,18 +9854,7 @@ const config$2 = ({ strapi: strapi2 }) => ({
|
|
|
9856
9854
|
ctx.status = 200;
|
|
9857
9855
|
ctx.body = { data: config2, error: null };
|
|
9858
9856
|
} catch (error) {
|
|
9859
|
-
|
|
9860
|
-
ctx.status = 500;
|
|
9861
|
-
ctx.body = { data: null, error: "Server Error" };
|
|
9862
|
-
}
|
|
9863
|
-
},
|
|
9864
|
-
async getEmailStatus(ctx) {
|
|
9865
|
-
try {
|
|
9866
|
-
const emailService = strapi2.config.get("plugin::email");
|
|
9867
|
-
ctx.status = 200;
|
|
9868
|
-
ctx.body = { data: emailService, error: null };
|
|
9869
|
-
} catch (error) {
|
|
9870
|
-
console.log("Error getting email status:", error);
|
|
9857
|
+
strapi2.log.error("Error getting config");
|
|
9871
9858
|
ctx.status = 500;
|
|
9872
9859
|
ctx.body = { data: null, error: "Server Error" };
|
|
9873
9860
|
}
|
|
@@ -9879,7 +9866,7 @@ const config$2 = ({ strapi: strapi2 }) => ({
|
|
|
9879
9866
|
ctx.status = 200;
|
|
9880
9867
|
ctx.body = { data: updatedConfig, error: null };
|
|
9881
9868
|
} catch (error) {
|
|
9882
|
-
|
|
9869
|
+
strapi2.log.error("Error updating config");
|
|
9883
9870
|
ctx.status = 500;
|
|
9884
9871
|
ctx.body = { data: null, error: "Server Error" };
|
|
9885
9872
|
}
|
|
@@ -9931,6 +9918,18 @@ const buildCookieOptionsWithExpiry = (type, absoluteExpiresAtISO, secureRequest)
|
|
|
9931
9918
|
return { ...base, expires: chosen, maxAge: Math.max(0, chosen.getTime() - now) };
|
|
9932
9919
|
};
|
|
9933
9920
|
const controller = ({ strapi: strapi2 }) => ({
|
|
9921
|
+
async verifyInfo(ctx) {
|
|
9922
|
+
const secret2 = strapi2.config.get("admin.auth.secret");
|
|
9923
|
+
const token = ctx.cookies.get("strapi_admin_mfa");
|
|
9924
|
+
try {
|
|
9925
|
+
const payload = jwt.verify(token, secret2);
|
|
9926
|
+
ctx.status = 200;
|
|
9927
|
+
ctx.body = { data: { mfaType: payload.mfaType || null }, error: null };
|
|
9928
|
+
} catch {
|
|
9929
|
+
ctx.status = 401;
|
|
9930
|
+
ctx.body = { data: null, error: "Invalid or expired MFA session" };
|
|
9931
|
+
}
|
|
9932
|
+
},
|
|
9934
9933
|
async verify(ctx) {
|
|
9935
9934
|
const sessionManager = strapi2.sessionManager;
|
|
9936
9935
|
const secret2 = strapi2.config.get("admin.auth.secret");
|
|
@@ -9977,7 +9976,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
9977
9976
|
error: null
|
|
9978
9977
|
};
|
|
9979
9978
|
} catch (error) {
|
|
9980
|
-
|
|
9979
|
+
strapi2.log.error("Error verifying MFA code");
|
|
9981
9980
|
ctx.status = 500;
|
|
9982
9981
|
ctx.body = { data: null, error: "Server Error" };
|
|
9983
9982
|
}
|
|
@@ -10000,7 +9999,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
10000
9999
|
ctx.body = { data: { message: "MFA disabled" }, error: null };
|
|
10001
10000
|
}
|
|
10002
10001
|
} catch (error) {
|
|
10003
|
-
|
|
10002
|
+
strapi2.log.error("Error enabling/disabling MFA");
|
|
10004
10003
|
ctx.status = 500;
|
|
10005
10004
|
ctx.body = { data: null, error: "Failed to update MFA" };
|
|
10006
10005
|
}
|
|
@@ -10045,7 +10044,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
10045
10044
|
ctx.status = 200;
|
|
10046
10045
|
ctx.body = { data: { message: "MFA disabled" }, error: null };
|
|
10047
10046
|
} catch (error) {
|
|
10048
|
-
|
|
10047
|
+
strapi2.log.error("Error disabling MFA");
|
|
10049
10048
|
ctx.status = 500;
|
|
10050
10049
|
ctx.body = { data: null, error: "Failed to disable MFA" };
|
|
10051
10050
|
}
|
|
@@ -10073,7 +10072,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
10073
10072
|
ctx.status = 200;
|
|
10074
10073
|
ctx.body = { data: { message: "Verification email sent" }, error: null };
|
|
10075
10074
|
} catch (error) {
|
|
10076
|
-
|
|
10075
|
+
strapi2.log.error("Error initiating email MFA setup");
|
|
10077
10076
|
ctx.status = 500;
|
|
10078
10077
|
ctx.body = { data: null, error: "Failed to initiate email MFA setup" };
|
|
10079
10078
|
}
|
|
@@ -10093,7 +10092,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
10093
10092
|
ctx.status = 200;
|
|
10094
10093
|
ctx.body = { data: { message: "Email OTP enabled" }, error: null };
|
|
10095
10094
|
} catch (error) {
|
|
10096
|
-
|
|
10095
|
+
strapi2.log.error("Error completing email MFA setup");
|
|
10097
10096
|
ctx.status = 500;
|
|
10098
10097
|
ctx.body = { data: null, error: "Failed to enable email MFA" };
|
|
10099
10098
|
}
|
|
@@ -10114,7 +10113,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
10114
10113
|
ctx.status = 200;
|
|
10115
10114
|
ctx.body = { data: { message: "Verification email sent" }, error: null };
|
|
10116
10115
|
} catch (error) {
|
|
10117
|
-
|
|
10116
|
+
strapi2.log.error("Error sending disable email OTP");
|
|
10118
10117
|
ctx.status = 500;
|
|
10119
10118
|
ctx.body = { data: null, error: "Failed to send verification email" };
|
|
10120
10119
|
}
|
|
@@ -10142,7 +10141,7 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
10142
10141
|
ctx.status = 200;
|
|
10143
10142
|
ctx.body = { data: { message: "Verification email resent" }, error: null };
|
|
10144
10143
|
} catch (error) {
|
|
10145
|
-
|
|
10144
|
+
strapi2.log.error("Error resending login email OTP");
|
|
10146
10145
|
ctx.status = 500;
|
|
10147
10146
|
ctx.body = { data: null, error: "Failed to resend verification email" };
|
|
10148
10147
|
}
|
|
@@ -10228,35 +10227,40 @@ const config$1 = [
|
|
|
10228
10227
|
pluginName: "strapi-identity",
|
|
10229
10228
|
type: "content-api"
|
|
10230
10229
|
},
|
|
10231
|
-
config: {}
|
|
10232
|
-
},
|
|
10233
|
-
{
|
|
10234
|
-
method: "GET",
|
|
10235
|
-
path: "/config",
|
|
10236
|
-
handler: "config.getConfig",
|
|
10237
|
-
info: {
|
|
10238
|
-
apiName: "getConfig",
|
|
10239
|
-
pluginName: "strapi-identity",
|
|
10240
|
-
type: "content-api"
|
|
10241
|
-
},
|
|
10242
10230
|
config: {
|
|
10243
10231
|
policies: [
|
|
10244
|
-
"admin::isAuthenticatedAdmin"
|
|
10232
|
+
"admin::isAuthenticatedAdmin",
|
|
10233
|
+
{
|
|
10234
|
+
name: "admin::hasPermissions",
|
|
10235
|
+
config: {
|
|
10236
|
+
actions: [
|
|
10237
|
+
"plugin::strapi-identity.settings.read"
|
|
10238
|
+
]
|
|
10239
|
+
}
|
|
10240
|
+
}
|
|
10245
10241
|
]
|
|
10246
10242
|
}
|
|
10247
10243
|
},
|
|
10248
10244
|
{
|
|
10249
10245
|
method: "GET",
|
|
10250
|
-
path: "/config
|
|
10251
|
-
handler: "config.
|
|
10246
|
+
path: "/config",
|
|
10247
|
+
handler: "config.getConfig",
|
|
10252
10248
|
info: {
|
|
10253
|
-
apiName: "
|
|
10249
|
+
apiName: "getConfig",
|
|
10254
10250
|
pluginName: "strapi-identity",
|
|
10255
10251
|
type: "content-api"
|
|
10256
10252
|
},
|
|
10257
10253
|
config: {
|
|
10258
10254
|
policies: [
|
|
10259
|
-
"admin::isAuthenticatedAdmin"
|
|
10255
|
+
"admin::isAuthenticatedAdmin",
|
|
10256
|
+
{
|
|
10257
|
+
name: "admin::hasPermissions",
|
|
10258
|
+
config: {
|
|
10259
|
+
actions: [
|
|
10260
|
+
"plugin::strapi-identity.settings.read"
|
|
10261
|
+
]
|
|
10262
|
+
}
|
|
10263
|
+
}
|
|
10260
10264
|
]
|
|
10261
10265
|
}
|
|
10262
10266
|
},
|
|
@@ -10285,6 +10289,22 @@ const config$1 = [
|
|
|
10285
10289
|
}
|
|
10286
10290
|
];
|
|
10287
10291
|
const mfa = [
|
|
10292
|
+
{
|
|
10293
|
+
method: "GET",
|
|
10294
|
+
path: "/verify/info",
|
|
10295
|
+
handler: "controller.verifyInfo",
|
|
10296
|
+
info: {
|
|
10297
|
+
apiName: "verifyInfo",
|
|
10298
|
+
pluginName: "strapi-identity",
|
|
10299
|
+
type: "content-api"
|
|
10300
|
+
},
|
|
10301
|
+
config: {
|
|
10302
|
+
auth: false,
|
|
10303
|
+
policies: [
|
|
10304
|
+
"has-mfa"
|
|
10305
|
+
]
|
|
10306
|
+
}
|
|
10307
|
+
},
|
|
10288
10308
|
{
|
|
10289
10309
|
method: "POST",
|
|
10290
10310
|
path: "/verify",
|
|
@@ -10298,6 +10318,9 @@ const mfa = [
|
|
|
10298
10318
|
auth: false,
|
|
10299
10319
|
policies: [
|
|
10300
10320
|
"has-mfa"
|
|
10321
|
+
],
|
|
10322
|
+
middlewares: [
|
|
10323
|
+
"admin::rateLimit"
|
|
10301
10324
|
]
|
|
10302
10325
|
}
|
|
10303
10326
|
},
|
|
@@ -10358,7 +10381,8 @@ const mfa = [
|
|
|
10358
10381
|
auth: false,
|
|
10359
10382
|
policies: [
|
|
10360
10383
|
"has-mfa"
|
|
10361
|
-
]
|
|
10384
|
+
],
|
|
10385
|
+
middlewares: []
|
|
10362
10386
|
}
|
|
10363
10387
|
},
|
|
10364
10388
|
{
|
|
@@ -10407,7 +10431,7 @@ const isEnabled$1 = (id) => {
|
|
|
10407
10431
|
try {
|
|
10408
10432
|
return mfaToken2.count({ where: { admin_user: { id }, enabled: true } }).then((count) => count > 0);
|
|
10409
10433
|
} catch (error) {
|
|
10410
|
-
|
|
10434
|
+
strapi.log.error("Error checking if 2FA is enabled for user");
|
|
10411
10435
|
return false;
|
|
10412
10436
|
}
|
|
10413
10437
|
};
|
|
@@ -10424,7 +10448,7 @@ const reset = async (id) => {
|
|
|
10424
10448
|
existingTemp ? mfaTemp2.delete({ documentId: existingTemp.documentId }) : null
|
|
10425
10449
|
]);
|
|
10426
10450
|
} catch (error) {
|
|
10427
|
-
|
|
10451
|
+
strapi.log.error("Error resetting 2FA for user");
|
|
10428
10452
|
throw new Error("Failed to reset 2FA for user");
|
|
10429
10453
|
}
|
|
10430
10454
|
};
|
|
@@ -10488,7 +10512,7 @@ const disableEmailMFAForAllUsers = async () => {
|
|
|
10488
10512
|
)
|
|
10489
10513
|
]);
|
|
10490
10514
|
} catch (err) {
|
|
10491
|
-
|
|
10515
|
+
strapi.log.error("Error disabling email MFA for all users");
|
|
10492
10516
|
}
|
|
10493
10517
|
};
|
|
10494
10518
|
const disableMFAForAllUsers = async () => {
|
|
@@ -10504,7 +10528,7 @@ const disableMFAForAllUsers = async () => {
|
|
|
10504
10528
|
...temps.map((temp) => tempDocument.delete({ documentId: temp.documentId }))
|
|
10505
10529
|
]);
|
|
10506
10530
|
} catch (err) {
|
|
10507
|
-
|
|
10531
|
+
strapi.log.error("Error disabling MFA for all users");
|
|
10508
10532
|
}
|
|
10509
10533
|
};
|
|
10510
10534
|
const checkUserByJWT = async (jwtToken) => {
|
|
@@ -10557,7 +10581,7 @@ const send = async (to, otp) => {
|
|
|
10557
10581
|
sendConfig.replyTo = config2.response_email;
|
|
10558
10582
|
}
|
|
10559
10583
|
return emailService.send(sendConfig).catch((error) => {
|
|
10560
|
-
|
|
10584
|
+
strapi.log.error("Error sending email");
|
|
10561
10585
|
});
|
|
10562
10586
|
};
|
|
10563
10587
|
const replaceTemplateVariables = (template, variables) => {
|