strapi-plugin-oidc 1.0.16 → 1.0.18
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/{index-BADTLgSt.mjs → index-BBRKt8XS.mjs} +27 -3
- package/dist/admin/{index-CINLwPy3.mjs → index-BpfwqZXc.mjs} +8 -4
- package/dist/admin/{index-Cq1ERJUV.js → index-D-EIdjjQ.js} +27 -3
- package/dist/admin/{index-C762D8BZ.js → index-Dw-jQQYI.js} +7 -3
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +14 -1
- package/dist/server/index.mjs +14 -1
- package/package.json +1 -1
|
@@ -54,7 +54,7 @@ const index = {
|
|
|
54
54
|
defaultMessage: "Configuration"
|
|
55
55
|
},
|
|
56
56
|
Component: async () => {
|
|
57
|
-
return await import("./index-
|
|
57
|
+
return await import("./index-BpfwqZXc.mjs");
|
|
58
58
|
},
|
|
59
59
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
60
60
|
}
|
|
@@ -66,6 +66,19 @@ const index = {
|
|
|
66
66
|
});
|
|
67
67
|
},
|
|
68
68
|
bootstrap() {
|
|
69
|
+
let isLogoutInProgress = false;
|
|
70
|
+
const isAuthRoute = (path) => {
|
|
71
|
+
const match = path.match(/\/auth\/(login|register|forgot-password|reset-password)/);
|
|
72
|
+
return match !== null;
|
|
73
|
+
};
|
|
74
|
+
const initialPath = window.location.pathname;
|
|
75
|
+
let styleElem = null;
|
|
76
|
+
if (isAuthRoute(initialPath) && !isLogoutInProgress) {
|
|
77
|
+
styleElem = document.createElement("style");
|
|
78
|
+
styleElem.innerHTML = "body { display: none !important; }";
|
|
79
|
+
document.head.appendChild(styleElem);
|
|
80
|
+
}
|
|
81
|
+
let willRedirect = false;
|
|
69
82
|
const checkEnforceOIDC = async () => {
|
|
70
83
|
try {
|
|
71
84
|
const response = await window.fetch("/strapi-plugin-oidc/settings/public");
|
|
@@ -73,15 +86,17 @@ const index = {
|
|
|
73
86
|
const data = await response.json();
|
|
74
87
|
if (data.enforceOIDC) {
|
|
75
88
|
const currentPath = window.location.pathname;
|
|
76
|
-
if (currentPath
|
|
89
|
+
if (isAuthRoute(currentPath) && !isLogoutInProgress) {
|
|
90
|
+
willRedirect = true;
|
|
77
91
|
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
92
|
+
return;
|
|
78
93
|
}
|
|
79
94
|
const interceptHistory = (originalMethod) => {
|
|
80
95
|
return function(...args) {
|
|
81
96
|
const url = args[2];
|
|
82
97
|
if (url && typeof url === "string") {
|
|
83
98
|
const urlWithoutQuery = url.split("?")[0].split("#")[0];
|
|
84
|
-
if (urlWithoutQuery
|
|
99
|
+
if (isAuthRoute(urlWithoutQuery) && !isLogoutInProgress) {
|
|
85
100
|
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
86
101
|
return;
|
|
87
102
|
}
|
|
@@ -95,6 +110,10 @@ const index = {
|
|
|
95
110
|
}
|
|
96
111
|
} catch (error) {
|
|
97
112
|
console.error("Failed to check OIDC enforcement setting:", error);
|
|
113
|
+
} finally {
|
|
114
|
+
if (!willRedirect && styleElem && styleElem.parentNode) {
|
|
115
|
+
styleElem.parentNode.removeChild(styleElem);
|
|
116
|
+
}
|
|
98
117
|
}
|
|
99
118
|
};
|
|
100
119
|
checkEnforceOIDC();
|
|
@@ -102,9 +121,14 @@ const index = {
|
|
|
102
121
|
window.fetch = async (...args) => {
|
|
103
122
|
const url = typeof args[0] === "string" ? args[0] : args[0].url;
|
|
104
123
|
const isLogout = url && url.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
|
|
124
|
+
if (isLogout) {
|
|
125
|
+
isLogoutInProgress = true;
|
|
126
|
+
}
|
|
105
127
|
const response = await originalFetch(...args);
|
|
106
128
|
if (isLogout && response.ok) {
|
|
107
129
|
window.location.href = "/strapi-plugin-oidc/logout";
|
|
130
|
+
} else if (isLogout) {
|
|
131
|
+
isLogoutInProgress = false;
|
|
108
132
|
}
|
|
109
133
|
return response;
|
|
110
134
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Routes, Route } from "react-router-dom";
|
|
3
|
-
import { useFetchClient, Page, Layouts } from "@strapi/strapi/admin";
|
|
3
|
+
import { useNotification, useFetchClient, Page, Layouts } from "@strapi/strapi/admin";
|
|
4
4
|
import { useState, useCallback, useEffect, memo } from "react";
|
|
5
5
|
import { Typography, Flex, Box, MultiSelect, MultiSelectOption, Field, Button, Divider, Thead, Tr, Th, Tbody, Td, Dialog, IconButton, Pagination, PreviousLink, PageLink, NextLink, Table, Alert } from "@strapi/design-system";
|
|
6
6
|
import { Plus, Trash, WarningCircle } from "@strapi/icons";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
|
-
import { p as pluginId } from "./index-
|
|
8
|
+
import { p as pluginId } from "./index-BBRKt8XS.mjs";
|
|
9
9
|
import en from "./en-DInn-mdh.mjs";
|
|
10
10
|
import styled from "styled-components";
|
|
11
11
|
function getTrad(id) {
|
|
@@ -66,19 +66,23 @@ function Whitelist({
|
|
|
66
66
|
const [selectedRoles, setSelectedRoles] = useState([]);
|
|
67
67
|
const [page, setPage] = useState(1);
|
|
68
68
|
const { formatMessage } = useIntl();
|
|
69
|
+
const { toggleNotification } = useNotification();
|
|
69
70
|
const PAGE_SIZE = 10;
|
|
70
71
|
const pageCount = Math.ceil(users.length / PAGE_SIZE) || 1;
|
|
71
72
|
const paginatedUsers = users.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
|
|
72
73
|
const onSaveEmail = useCallback(async () => {
|
|
73
74
|
const emailText = email.trim();
|
|
74
75
|
if (users.some((user) => user.email === emailText)) {
|
|
75
|
-
|
|
76
|
+
toggleNotification({
|
|
77
|
+
type: "warning",
|
|
78
|
+
message: formatMessage(getTrad("whitelist.error.unique"))
|
|
79
|
+
});
|
|
76
80
|
} else {
|
|
77
81
|
await onSave(emailText, selectedRoles);
|
|
78
82
|
setEmail("");
|
|
79
83
|
setSelectedRoles([]);
|
|
80
84
|
}
|
|
81
|
-
}, [email, selectedRoles, users, onSave, formatMessage]);
|
|
85
|
+
}, [email, selectedRoles, users, onSave, formatMessage, toggleNotification]);
|
|
82
86
|
const isValidEmail = useCallback(() => {
|
|
83
87
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
84
88
|
return emailRegex.test(email);
|
|
@@ -55,7 +55,7 @@ const index = {
|
|
|
55
55
|
defaultMessage: "Configuration"
|
|
56
56
|
},
|
|
57
57
|
Component: async () => {
|
|
58
|
-
return await Promise.resolve().then(() => require("./index-
|
|
58
|
+
return await Promise.resolve().then(() => require("./index-Dw-jQQYI.js"));
|
|
59
59
|
},
|
|
60
60
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
61
61
|
}
|
|
@@ -67,6 +67,19 @@ const index = {
|
|
|
67
67
|
});
|
|
68
68
|
},
|
|
69
69
|
bootstrap() {
|
|
70
|
+
let isLogoutInProgress = false;
|
|
71
|
+
const isAuthRoute = (path) => {
|
|
72
|
+
const match = path.match(/\/auth\/(login|register|forgot-password|reset-password)/);
|
|
73
|
+
return match !== null;
|
|
74
|
+
};
|
|
75
|
+
const initialPath = window.location.pathname;
|
|
76
|
+
let styleElem = null;
|
|
77
|
+
if (isAuthRoute(initialPath) && !isLogoutInProgress) {
|
|
78
|
+
styleElem = document.createElement("style");
|
|
79
|
+
styleElem.innerHTML = "body { display: none !important; }";
|
|
80
|
+
document.head.appendChild(styleElem);
|
|
81
|
+
}
|
|
82
|
+
let willRedirect = false;
|
|
70
83
|
const checkEnforceOIDC = async () => {
|
|
71
84
|
try {
|
|
72
85
|
const response = await window.fetch("/strapi-plugin-oidc/settings/public");
|
|
@@ -74,15 +87,17 @@ const index = {
|
|
|
74
87
|
const data = await response.json();
|
|
75
88
|
if (data.enforceOIDC) {
|
|
76
89
|
const currentPath = window.location.pathname;
|
|
77
|
-
if (currentPath
|
|
90
|
+
if (isAuthRoute(currentPath) && !isLogoutInProgress) {
|
|
91
|
+
willRedirect = true;
|
|
78
92
|
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
93
|
+
return;
|
|
79
94
|
}
|
|
80
95
|
const interceptHistory = (originalMethod) => {
|
|
81
96
|
return function(...args) {
|
|
82
97
|
const url = args[2];
|
|
83
98
|
if (url && typeof url === "string") {
|
|
84
99
|
const urlWithoutQuery = url.split("?")[0].split("#")[0];
|
|
85
|
-
if (urlWithoutQuery
|
|
100
|
+
if (isAuthRoute(urlWithoutQuery) && !isLogoutInProgress) {
|
|
86
101
|
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
87
102
|
return;
|
|
88
103
|
}
|
|
@@ -96,6 +111,10 @@ const index = {
|
|
|
96
111
|
}
|
|
97
112
|
} catch (error) {
|
|
98
113
|
console.error("Failed to check OIDC enforcement setting:", error);
|
|
114
|
+
} finally {
|
|
115
|
+
if (!willRedirect && styleElem && styleElem.parentNode) {
|
|
116
|
+
styleElem.parentNode.removeChild(styleElem);
|
|
117
|
+
}
|
|
99
118
|
}
|
|
100
119
|
};
|
|
101
120
|
checkEnforceOIDC();
|
|
@@ -103,9 +122,14 @@ const index = {
|
|
|
103
122
|
window.fetch = async (...args) => {
|
|
104
123
|
const url = typeof args[0] === "string" ? args[0] : args[0].url;
|
|
105
124
|
const isLogout = url && url.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
|
|
125
|
+
if (isLogout) {
|
|
126
|
+
isLogoutInProgress = true;
|
|
127
|
+
}
|
|
106
128
|
const response = await originalFetch(...args);
|
|
107
129
|
if (isLogout && response.ok) {
|
|
108
130
|
window.location.href = "/strapi-plugin-oidc/logout";
|
|
131
|
+
} else if (isLogout) {
|
|
132
|
+
isLogoutInProgress = false;
|
|
109
133
|
}
|
|
110
134
|
return response;
|
|
111
135
|
};
|
|
@@ -7,7 +7,7 @@ const react = require("react");
|
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const reactIntl = require("react-intl");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-D-EIdjjQ.js");
|
|
11
11
|
const en = require("./en-8UlbiAHW.js");
|
|
12
12
|
const styled = require("styled-components");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
@@ -70,19 +70,23 @@ function Whitelist({
|
|
|
70
70
|
const [selectedRoles, setSelectedRoles] = react.useState([]);
|
|
71
71
|
const [page, setPage] = react.useState(1);
|
|
72
72
|
const { formatMessage } = reactIntl.useIntl();
|
|
73
|
+
const { toggleNotification } = admin.useNotification();
|
|
73
74
|
const PAGE_SIZE = 10;
|
|
74
75
|
const pageCount = Math.ceil(users.length / PAGE_SIZE) || 1;
|
|
75
76
|
const paginatedUsers = users.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
|
|
76
77
|
const onSaveEmail = react.useCallback(async () => {
|
|
77
78
|
const emailText = email.trim();
|
|
78
79
|
if (users.some((user) => user.email === emailText)) {
|
|
79
|
-
|
|
80
|
+
toggleNotification({
|
|
81
|
+
type: "warning",
|
|
82
|
+
message: formatMessage(getTrad("whitelist.error.unique"))
|
|
83
|
+
});
|
|
80
84
|
} else {
|
|
81
85
|
await onSave(emailText, selectedRoles);
|
|
82
86
|
setEmail("");
|
|
83
87
|
setSelectedRoles([]);
|
|
84
88
|
}
|
|
85
|
-
}, [email, selectedRoles, users, onSave, formatMessage]);
|
|
89
|
+
}, [email, selectedRoles, users, onSave, formatMessage, toggleNotification]);
|
|
86
90
|
const isValidEmail = react.useCallback(() => {
|
|
87
91
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
88
92
|
return emailRegex.test(email);
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -12,7 +12,8 @@ function register$1() {
|
|
|
12
12
|
}
|
|
13
13
|
async function bootstrap({ strapi: strapi2 }) {
|
|
14
14
|
strapi2.server.use(async (ctx, next) => {
|
|
15
|
-
|
|
15
|
+
const adminUrl = strapi2.config.get("admin.url", "/admin");
|
|
16
|
+
if (ctx.request.path === `${adminUrl}/login` && ctx.request.method === "POST") {
|
|
16
17
|
try {
|
|
17
18
|
const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
|
|
18
19
|
const settings = await whitelistService2.getSettings();
|
|
@@ -33,6 +34,18 @@ async function bootstrap({ strapi: strapi2 }) {
|
|
|
33
34
|
strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
if (ctx.request.method === "GET" && (ctx.request.path.startsWith(`${adminUrl}/auth/login`) || ctx.request.path.startsWith(`${adminUrl}/auth/register`) || ctx.request.path.startsWith(`${adminUrl}/auth/forgot-password`) || ctx.request.path.startsWith(`${adminUrl}/auth/reset-password`))) {
|
|
38
|
+
try {
|
|
39
|
+
const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
|
|
40
|
+
const settings = await whitelistService2.getSettings();
|
|
41
|
+
if (settings && settings.enforceOIDC) {
|
|
42
|
+
ctx.redirect("/strapi-plugin-oidc/oidc");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
strapi2.log.error("Error checking OIDC enforcement in GET middleware:", err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
36
49
|
await next();
|
|
37
50
|
});
|
|
38
51
|
const actions = [
|
package/dist/server/index.mjs
CHANGED
|
@@ -6,7 +6,8 @@ function register$1() {
|
|
|
6
6
|
}
|
|
7
7
|
async function bootstrap({ strapi: strapi2 }) {
|
|
8
8
|
strapi2.server.use(async (ctx, next) => {
|
|
9
|
-
|
|
9
|
+
const adminUrl = strapi2.config.get("admin.url", "/admin");
|
|
10
|
+
if (ctx.request.path === `${adminUrl}/login` && ctx.request.method === "POST") {
|
|
10
11
|
try {
|
|
11
12
|
const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
|
|
12
13
|
const settings = await whitelistService2.getSettings();
|
|
@@ -27,6 +28,18 @@ async function bootstrap({ strapi: strapi2 }) {
|
|
|
27
28
|
strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
if (ctx.request.method === "GET" && (ctx.request.path.startsWith(`${adminUrl}/auth/login`) || ctx.request.path.startsWith(`${adminUrl}/auth/register`) || ctx.request.path.startsWith(`${adminUrl}/auth/forgot-password`) || ctx.request.path.startsWith(`${adminUrl}/auth/reset-password`))) {
|
|
32
|
+
try {
|
|
33
|
+
const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
|
|
34
|
+
const settings = await whitelistService2.getSettings();
|
|
35
|
+
if (settings && settings.enforceOIDC) {
|
|
36
|
+
ctx.redirect("/strapi-plugin-oidc/oidc");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
strapi2.log.error("Error checking OIDC enforcement in GET middleware:", err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
30
43
|
await next();
|
|
31
44
|
});
|
|
32
45
|
const actions = [
|
package/package.json
CHANGED