strapi-plugin-oidc 1.6.2 → 1.6.4
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/README.md +4 -5
- package/dist/admin/{index-P9HriRms.mjs → index-AxBC5YLT.mjs} +8 -5
- package/dist/admin/{index-DTOcUHZi.js → index-DowwUs07.js} +81 -110
- package/dist/admin/{index-f3cmU_tE.js → index-EAfqxfV4.js} +8 -5
- package/dist/admin/{index-DmJadA2p.mjs → index-MnV7H8G6.mjs} +81 -110
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +143 -192
- package/dist/server/index.mjs +143 -192
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,14 +119,13 @@ Role names are the **display names** shown in **Settings → Roles** (e.g. `"Edi
|
|
|
119
119
|
### Role assignment precedence
|
|
120
120
|
|
|
121
121
|
1. **User's OIDC groups match `OIDC_GROUP_ROLE_MAP`** → use the mapped Strapi roles
|
|
122
|
-
2. **No group match or no mapping configured** → use the default OIDC roles
|
|
122
|
+
2. **No group match or no mapping configured** → use the default OIDC roles (new users only — see below)
|
|
123
123
|
|
|
124
124
|
### Role updates on subsequent logins
|
|
125
125
|
|
|
126
|
-
- **New users** —
|
|
127
|
-
- **Existing users with
|
|
128
|
-
- **Existing users with
|
|
129
|
-
- **Mapping removed or user's groups don't map** — If the `OIDC_GROUP_ROLE_MAP` is removed, a user's groups no longer match any mapping, or there are no default OIDC roles configured, the user keeps their last known roles.
|
|
126
|
+
- **New users** — Roles are always assigned on first login: group-mapped roles if a match is found, otherwise the configured default OIDC roles.
|
|
127
|
+
- **Existing users with a group mapping match** — Roles are updated to reflect the current mapping. If a user's groups change between logins, their Strapi roles are updated accordingly.
|
|
128
|
+
- **Existing users with no group mapping match** — Roles are left unchanged, regardless of what the default OIDC roles are set to. Manually-assigned roles are never overwritten by a default fallback.
|
|
130
129
|
|
|
131
130
|
## Whitelist API
|
|
132
131
|
|
|
@@ -99,6 +99,7 @@ const en = {
|
|
|
99
99
|
"auditlog.table.ip": "IP",
|
|
100
100
|
"auditlog.table.details": "Details",
|
|
101
101
|
"auditlog.table.empty": "No audit log entries",
|
|
102
|
+
"auditlog.loading": "Loading…",
|
|
102
103
|
"auditlog.clear": "Clear Logs",
|
|
103
104
|
"auditlog.clear.title": "Clear All Logs",
|
|
104
105
|
"auditlog.clear.description": "This will permanently delete all {count, plural, one {# audit log entry} other {# audit log entries}}. This action cannot be undone.",
|
|
@@ -117,7 +118,9 @@ const en = {
|
|
|
117
118
|
"auditlog.action.whitelist_rejected": "The user's email address is not on the whitelist. Access was denied.",
|
|
118
119
|
"user.missing_code": "Authorisation code was not received from the OIDC provider.",
|
|
119
120
|
"user.invalid_state": "State parameter mismatch. Please restart the login flow.",
|
|
120
|
-
"user.signInError": "Authentication failed. Please try again."
|
|
121
|
+
"user.signInError": "Authentication failed. Please try again.",
|
|
122
|
+
"settings.section": "OIDC",
|
|
123
|
+
"settings.configuration": "Configuration"
|
|
121
124
|
};
|
|
122
125
|
function getTrad(id) {
|
|
123
126
|
const pluginIdWithId = `${pluginId}.${id}`;
|
|
@@ -136,7 +139,7 @@ const index = {
|
|
|
136
139
|
{
|
|
137
140
|
id: "oidc",
|
|
138
141
|
intlLabel: {
|
|
139
|
-
id:
|
|
142
|
+
id: "settings.section",
|
|
140
143
|
defaultMessage: "OIDC"
|
|
141
144
|
}
|
|
142
145
|
},
|
|
@@ -144,11 +147,11 @@ const index = {
|
|
|
144
147
|
id: "configuration",
|
|
145
148
|
to: `/settings/${pluginId}`,
|
|
146
149
|
intlLabel: {
|
|
147
|
-
id:
|
|
150
|
+
id: "settings.configuration",
|
|
148
151
|
defaultMessage: "Configuration"
|
|
149
152
|
},
|
|
150
153
|
Component: async () => {
|
|
151
|
-
return await import("./index-
|
|
154
|
+
return await import("./index-MnV7H8G6.mjs");
|
|
152
155
|
},
|
|
153
156
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
154
157
|
}
|
|
@@ -242,7 +245,7 @@ const index = {
|
|
|
242
245
|
const originalFetch = window.fetch;
|
|
243
246
|
window.fetch = async (...args) => {
|
|
244
247
|
const url = typeof args[0] === "string" ? args[0] : args[0].url;
|
|
245
|
-
const isLogout = url
|
|
248
|
+
const isLogout = url?.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
|
|
246
249
|
const response = await originalFetch(...args);
|
|
247
250
|
if (isLogout && response.ok) {
|
|
248
251
|
window.localStorage.removeItem("jwtToken");
|
|
@@ -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-EAfqxfV4.js");
|
|
11
11
|
const styled = require("styled-components");
|
|
12
12
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
13
13
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -22,9 +22,7 @@ function Role({ oidcRoles, roles, onChangeRole }) {
|
|
|
22
22
|
placeholder: formatMessage(index.getTrad("roles.placeholder")),
|
|
23
23
|
value: oidcRole.role ? oidcRole.role.map((r) => String(r)) : [],
|
|
24
24
|
onChange: (value) => {
|
|
25
|
-
if (value && value.length > 0)
|
|
26
|
-
onChangeRole(value, oidcRole.oauth_type);
|
|
27
|
-
}
|
|
25
|
+
if (value && value.length > 0) onChangeRole(value, oidcRole.oauth_type);
|
|
28
26
|
},
|
|
29
27
|
children: roles.map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: String(role.id), children: role.name }, role.id))
|
|
30
28
|
}
|
|
@@ -77,19 +75,11 @@ function ConfirmDialog({
|
|
|
77
75
|
function TablePagination({ page, pageCount, onPageChange }) {
|
|
78
76
|
const { formatMessage } = reactIntl.useIntl();
|
|
79
77
|
if (pageCount <= 1) return null;
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
onClick: (e) => {
|
|
86
|
-
e.preventDefault();
|
|
87
|
-
onPageChange(num);
|
|
88
|
-
},
|
|
89
|
-
children: formatMessage(index.getTrad("pagination.page"), { page: num })
|
|
90
|
-
},
|
|
91
|
-
num
|
|
92
|
-
);
|
|
78
|
+
const handleClick = (e, num) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
onPageChange(num);
|
|
81
|
+
};
|
|
82
|
+
const pageLink = (num) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.PageLink, { number: num, href: "#", onClick: (e) => handleClick(e, num), children: formatMessage(index.getTrad("pagination.page"), { page: num }) }, num);
|
|
93
83
|
const Ellipsis = () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", paddingLeft: 2, paddingRight: 2, children: "…" });
|
|
94
84
|
let pages;
|
|
95
85
|
if (pageCount <= 10) {
|
|
@@ -116,31 +106,13 @@ function TablePagination({ page, pageCount, onPageChange }) {
|
|
|
116
106
|
] });
|
|
117
107
|
}
|
|
118
108
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Pagination, { activePage: page, pageCount, children: [
|
|
119
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
-
designSystem.PreviousLink,
|
|
121
|
-
{
|
|
122
|
-
href: "#",
|
|
123
|
-
onClick: (e) => {
|
|
124
|
-
e.preventDefault();
|
|
125
|
-
onPageChange(Math.max(1, page - 1));
|
|
126
|
-
},
|
|
127
|
-
children: formatMessage(index.getTrad("pagination.previous"))
|
|
128
|
-
}
|
|
129
|
-
),
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.PreviousLink, { href: "#", onClick: (e) => handleClick(e, Math.max(1, page - 1)), children: formatMessage(index.getTrad("pagination.previous")) }),
|
|
130
110
|
pages,
|
|
131
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
132
|
-
designSystem.NextLink,
|
|
133
|
-
{
|
|
134
|
-
href: "#",
|
|
135
|
-
onClick: (e) => {
|
|
136
|
-
e.preventDefault();
|
|
137
|
-
onPageChange(Math.min(pageCount, page + 1));
|
|
138
|
-
},
|
|
139
|
-
children: formatMessage(index.getTrad("pagination.next"))
|
|
140
|
-
}
|
|
141
|
-
)
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.NextLink, { href: "#", onClick: (e) => handleClick(e, Math.min(pageCount, page + 1)), children: formatMessage(index.getTrad("pagination.next")) })
|
|
142
112
|
] }) }) });
|
|
143
113
|
}
|
|
114
|
+
const PAGE_SIZE$1 = 10;
|
|
115
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
144
116
|
function Whitelist({
|
|
145
117
|
users,
|
|
146
118
|
useWhitelist,
|
|
@@ -156,11 +128,8 @@ function Whitelist({
|
|
|
156
128
|
const { formatMessage } = reactIntl.useIntl();
|
|
157
129
|
const { toggleNotification } = admin.useNotification();
|
|
158
130
|
const fileInputRef = react.useRef(null);
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const paginatedUsers = users.slice((page - 1) * PAGE_SIZE2, page * PAGE_SIZE2);
|
|
162
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
163
|
-
const isValidEmail = emailRegex.test(email);
|
|
131
|
+
const pageCount = Math.ceil(users.length / PAGE_SIZE$1) || 1;
|
|
132
|
+
const paginatedUsers = users.slice((page - 1) * PAGE_SIZE$1, page * PAGE_SIZE$1);
|
|
164
133
|
const onSaveEmail = react.useCallback(() => {
|
|
165
134
|
const emailText = email.trim();
|
|
166
135
|
if (users.some((user) => user.email === emailText)) {
|
|
@@ -176,14 +145,15 @@ function Whitelist({
|
|
|
176
145
|
const handleImport = react.useCallback(
|
|
177
146
|
async (e) => {
|
|
178
147
|
const file = e.target.files?.[0];
|
|
179
|
-
if (!fileInputRef.current) return;
|
|
148
|
+
if (!fileInputRef.current || !file) return;
|
|
180
149
|
fileInputRef.current.value = "";
|
|
181
|
-
if (!file) return;
|
|
182
150
|
try {
|
|
183
151
|
const text = await file.text();
|
|
184
152
|
const parsed = JSON.parse(text);
|
|
185
153
|
if (!Array.isArray(parsed)) throw new Error();
|
|
186
|
-
const emails = parsed.filter((item) => item?.email).map(
|
|
154
|
+
const emails = parsed.filter((item) => item?.email).map(
|
|
155
|
+
(item) => String(item.email).trim().toLowerCase()
|
|
156
|
+
).filter((email2) => EMAIL_REGEX.test(email2));
|
|
187
157
|
const count = await onImport(emails);
|
|
188
158
|
if (count === 0) {
|
|
189
159
|
toggleNotification({
|
|
@@ -263,7 +233,7 @@ function Whitelist({
|
|
|
263
233
|
type: "text",
|
|
264
234
|
disabled: loading,
|
|
265
235
|
value: email,
|
|
266
|
-
hasError: Boolean(email && !
|
|
236
|
+
hasError: Boolean(email && !EMAIL_REGEX.test(email)),
|
|
267
237
|
onChange: (e) => setEmail(e.currentTarget.value),
|
|
268
238
|
placeholder: formatMessage(index.getTrad("whitelist.email.placeholder"))
|
|
269
239
|
}
|
|
@@ -273,7 +243,7 @@ function Whitelist({
|
|
|
273
243
|
{
|
|
274
244
|
size: "L",
|
|
275
245
|
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
276
|
-
disabled: loading || email.trim() === "" || !
|
|
246
|
+
disabled: loading || email.trim() === "" || !EMAIL_REGEX.test(email),
|
|
277
247
|
loading,
|
|
278
248
|
onClick: onSaveEmail,
|
|
279
249
|
children: formatMessage(index.getTrad("page.add"))
|
|
@@ -289,7 +259,7 @@ function Whitelist({
|
|
|
289
259
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { paddingRight: 0 }, children: " " })
|
|
290
260
|
] }) }),
|
|
291
261
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: users.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage(index.getTrad("whitelist.table.empty")) }) }) }) }) : paginatedUsers.map((user, index$1) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
292
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: index$1 + 1 + (page - 1) *
|
|
262
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: index$1 + 1 + (page - 1) * PAGE_SIZE$1 }),
|
|
293
263
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: user.email }),
|
|
294
264
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LocalizedDate, { date: user.createdAt, options: { month: "long" } }) }),
|
|
295
265
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { paddingRight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -467,7 +437,7 @@ function AuditLog() {
|
|
|
467
437
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(index.getTrad("auditlog.table.details")) })
|
|
468
438
|
] }) }),
|
|
469
439
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tbody, { children: [
|
|
470
|
-
loading && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "
|
|
440
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage(index.getTrad("auditlog.loading")) }) }) }) }),
|
|
471
441
|
!loading && records.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage(index.getTrad("auditlog.table.empty")) }) }) }) }),
|
|
472
442
|
!loading && records.map((record) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
473
443
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: /* @__PURE__ */ jsxRuntime.jsx(LocalizedDate, { date: record.createdAt, options: { second: "2-digit" } }) }) }),
|
|
@@ -633,47 +603,52 @@ function useOidcSettings() {
|
|
|
633
603
|
setRoles(response.data.data);
|
|
634
604
|
});
|
|
635
605
|
get("/strapi-plugin-oidc/whitelist").then((response) => {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
606
|
+
const data = response.data;
|
|
607
|
+
setWhitelistResponse(data);
|
|
608
|
+
setUsers(data.whitelistUsers);
|
|
609
|
+
setInitialUsers(deepClone(data.whitelistUsers));
|
|
610
|
+
setUseWhitelist(data.useWhitelist);
|
|
611
|
+
setInitialUseWhitelist(data.useWhitelist);
|
|
612
|
+
setEnforceOIDC(data.enforceOIDC);
|
|
613
|
+
setInitialEnforceOIDC(data.enforceOIDC);
|
|
614
|
+
setEnforceOIDCConfig(data.enforceOIDCConfig ?? null);
|
|
644
615
|
});
|
|
645
616
|
}, [get]);
|
|
646
|
-
const onChangeRole = (values, oidcId) => {
|
|
647
|
-
|
|
648
|
-
(role) => role.oauth_type === oidcId ? { ...role, role: values } : role
|
|
617
|
+
const onChangeRole = react.useCallback((values, oidcId) => {
|
|
618
|
+
setOIDCRoles(
|
|
619
|
+
(prev) => prev.map((role) => role.oauth_type === oidcId ? { ...role, role: values } : role)
|
|
649
620
|
);
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
|
|
621
|
+
}, []);
|
|
622
|
+
const onRegisterWhitelist = react.useCallback((email) => {
|
|
623
|
+
setUsers((prev) => [...prev, { email, createdAt: (/* @__PURE__ */ new Date()).toISOString() }]);
|
|
624
|
+
}, []);
|
|
625
|
+
const onDeleteWhitelist = react.useCallback(
|
|
626
|
+
(email) => {
|
|
627
|
+
setUsers((prev) => {
|
|
628
|
+
const updated = prev.filter((u) => u.email !== email);
|
|
629
|
+
if (useWhitelist && updated.length === 0) setEnforceOIDC(false);
|
|
630
|
+
return updated;
|
|
631
|
+
});
|
|
632
|
+
},
|
|
633
|
+
[useWhitelist]
|
|
634
|
+
);
|
|
635
|
+
const onDeleteAll = react.useCallback(() => {
|
|
664
636
|
setUsers([]);
|
|
665
637
|
if (useWhitelist) setEnforceOIDC(false);
|
|
666
|
-
};
|
|
667
|
-
const onImport =
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
638
|
+
}, [useWhitelist]);
|
|
639
|
+
const onImport = react.useCallback(
|
|
640
|
+
async (emails) => {
|
|
641
|
+
const response = await post("/strapi-plugin-oidc/whitelist/import", {
|
|
642
|
+
users: emails.map((e) => ({ email: e }))
|
|
643
|
+
});
|
|
644
|
+
const refreshed = await get("/strapi-plugin-oidc/whitelist");
|
|
645
|
+
setUsers(refreshed.data.whitelistUsers);
|
|
646
|
+
setInitialUsers(deepClone(refreshed.data.whitelistUsers));
|
|
647
|
+
return response.data.importedCount;
|
|
648
|
+
},
|
|
649
|
+
[post, get]
|
|
650
|
+
);
|
|
651
|
+
const onExport = react.useCallback(async () => {
|
|
677
652
|
const response = await get("/strapi-plugin-oidc/whitelist/export");
|
|
678
653
|
const data = response.data;
|
|
679
654
|
const datetime = formatDatetimeForFilename(/* @__PURE__ */ new Date());
|
|
@@ -684,41 +659,37 @@ function useOidcSettings() {
|
|
|
684
659
|
a.download = `strapi-oidc-whitelist-${datetime}.json`;
|
|
685
660
|
a.click();
|
|
686
661
|
URL.revokeObjectURL(url);
|
|
687
|
-
};
|
|
688
|
-
const onToggleWhitelist = (
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
setEnforceOIDC(false);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
|
|
662
|
+
}, [get]);
|
|
663
|
+
const onToggleWhitelist = react.useCallback(
|
|
664
|
+
(e) => {
|
|
665
|
+
const checked = e.target.checked;
|
|
666
|
+
setUseWhitelist(checked);
|
|
667
|
+
if (checked && users.length === 0) setEnforceOIDC(false);
|
|
668
|
+
},
|
|
669
|
+
[users.length]
|
|
670
|
+
);
|
|
671
|
+
const onToggleEnforce = react.useCallback((e) => {
|
|
696
672
|
setEnforceOIDC(e.target.checked);
|
|
697
|
-
};
|
|
673
|
+
}, []);
|
|
698
674
|
const isDirty = useWhitelist !== initialUseWhitelist || enforceOIDC !== initialEnforceOIDC || JSON.stringify(oidcRoles) !== JSON.stringify(initialOidcRoles) || JSON.stringify(users) !== JSON.stringify(initialUsers);
|
|
699
|
-
const onSaveAll = async () => {
|
|
675
|
+
const onSaveAll = react.useCallback(async () => {
|
|
700
676
|
setLoading(true);
|
|
701
677
|
try {
|
|
702
678
|
await put("/strapi-plugin-oidc/oidc-roles", {
|
|
703
|
-
roles: oidcRoles.map((role) => ({
|
|
704
|
-
oauth_type: role.oauth_type,
|
|
705
|
-
role: role.role
|
|
706
|
-
}))
|
|
679
|
+
roles: oidcRoles.map((role) => ({ oauth_type: role.oauth_type, role: role.role }))
|
|
707
680
|
});
|
|
708
681
|
await put("/strapi-plugin-oidc/whitelist/sync", {
|
|
709
682
|
users: users.map((u) => ({ email: u.email }))
|
|
710
683
|
});
|
|
711
|
-
await put("/strapi-plugin-oidc/whitelist/settings", {
|
|
712
|
-
useWhitelist,
|
|
713
|
-
enforceOIDC
|
|
714
|
-
});
|
|
684
|
+
await put("/strapi-plugin-oidc/whitelist/settings", { useWhitelist, enforceOIDC });
|
|
715
685
|
setInitialOIDCRoles(deepClone(oidcRoles));
|
|
716
686
|
setInitialUseWhitelist(useWhitelist);
|
|
717
687
|
setInitialEnforceOIDC(enforceOIDC);
|
|
718
688
|
get("/strapi-plugin-oidc/whitelist").then((getResponse) => {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
689
|
+
const data = getResponse.data;
|
|
690
|
+
setWhitelistResponse(data);
|
|
691
|
+
setUsers(data.whitelistUsers);
|
|
692
|
+
setInitialUsers(deepClone(data.whitelistUsers));
|
|
722
693
|
});
|
|
723
694
|
setSuccess(true);
|
|
724
695
|
setTimeout(() => setSuccess(false), 3e3);
|
|
@@ -729,7 +700,7 @@ function useOidcSettings() {
|
|
|
729
700
|
} finally {
|
|
730
701
|
setLoading(false);
|
|
731
702
|
}
|
|
732
|
-
};
|
|
703
|
+
}, [put, get, oidcRoles, users, useWhitelist, enforceOIDC]);
|
|
733
704
|
return {
|
|
734
705
|
state: {
|
|
735
706
|
loading,
|
|
@@ -100,6 +100,7 @@ const en = {
|
|
|
100
100
|
"auditlog.table.ip": "IP",
|
|
101
101
|
"auditlog.table.details": "Details",
|
|
102
102
|
"auditlog.table.empty": "No audit log entries",
|
|
103
|
+
"auditlog.loading": "Loading…",
|
|
103
104
|
"auditlog.clear": "Clear Logs",
|
|
104
105
|
"auditlog.clear.title": "Clear All Logs",
|
|
105
106
|
"auditlog.clear.description": "This will permanently delete all {count, plural, one {# audit log entry} other {# audit log entries}}. This action cannot be undone.",
|
|
@@ -118,7 +119,9 @@ const en = {
|
|
|
118
119
|
"auditlog.action.whitelist_rejected": "The user's email address is not on the whitelist. Access was denied.",
|
|
119
120
|
"user.missing_code": "Authorisation code was not received from the OIDC provider.",
|
|
120
121
|
"user.invalid_state": "State parameter mismatch. Please restart the login flow.",
|
|
121
|
-
"user.signInError": "Authentication failed. Please try again."
|
|
122
|
+
"user.signInError": "Authentication failed. Please try again.",
|
|
123
|
+
"settings.section": "OIDC",
|
|
124
|
+
"settings.configuration": "Configuration"
|
|
122
125
|
};
|
|
123
126
|
function getTrad(id) {
|
|
124
127
|
const pluginIdWithId = `${pluginId}.${id}`;
|
|
@@ -137,7 +140,7 @@ const index = {
|
|
|
137
140
|
{
|
|
138
141
|
id: "oidc",
|
|
139
142
|
intlLabel: {
|
|
140
|
-
id:
|
|
143
|
+
id: "settings.section",
|
|
141
144
|
defaultMessage: "OIDC"
|
|
142
145
|
}
|
|
143
146
|
},
|
|
@@ -145,11 +148,11 @@ const index = {
|
|
|
145
148
|
id: "configuration",
|
|
146
149
|
to: `/settings/${pluginId}`,
|
|
147
150
|
intlLabel: {
|
|
148
|
-
id:
|
|
151
|
+
id: "settings.configuration",
|
|
149
152
|
defaultMessage: "Configuration"
|
|
150
153
|
},
|
|
151
154
|
Component: async () => {
|
|
152
|
-
return await Promise.resolve().then(() => require("./index-
|
|
155
|
+
return await Promise.resolve().then(() => require("./index-DowwUs07.js"));
|
|
153
156
|
},
|
|
154
157
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
155
158
|
}
|
|
@@ -243,7 +246,7 @@ const index = {
|
|
|
243
246
|
const originalFetch = window.fetch;
|
|
244
247
|
window.fetch = async (...args) => {
|
|
245
248
|
const url = typeof args[0] === "string" ? args[0] : args[0].url;
|
|
246
|
-
const isLogout = url
|
|
249
|
+
const isLogout = url?.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
|
|
247
250
|
const response = await originalFetch(...args);
|
|
248
251
|
if (isLogout && response.ok) {
|
|
249
252
|
window.localStorage.removeItem("jwtToken");
|