strapi-plugin-oidc 1.0.6 → 1.0.8
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/{en-jFPbEFeK.js → en-8UlbiAHW.js} +1 -0
- package/dist/admin/{en-f0TxVfx7.mjs → en-DInn-mdh.mjs} +1 -0
- package/dist/admin/{index-BITZIRCD.js → index-Bc2bQNhu.js} +2 -2
- package/dist/admin/{index-YOG9buUz.mjs → index-Cz9Q6j4e.mjs} +2 -2
- package/dist/admin/{index-CLDWnBI9.js → index-DNIqscJT.js} +159 -181
- package/dist/admin/{index-p9ncVp1G.mjs → index-V4-lA3hu.mjs} +159 -181
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +24 -10
- package/dist/server/index.mjs +24 -9
- package/package.json +2 -3
|
@@ -11,6 +11,7 @@ const en = {
|
|
|
11
11
|
"page.cancel": "Cancel",
|
|
12
12
|
"page.ok": "OK",
|
|
13
13
|
"roles.title": "Default Role(s)",
|
|
14
|
+
"roles.placeholder": "Select default role(s)",
|
|
14
15
|
"whitelist.title": "Whitelist",
|
|
15
16
|
"whitelist.error.unique": "Already registered email address.",
|
|
16
17
|
"whitelist.enabled": "Whitelist is currently enabled.",
|
|
@@ -9,6 +9,7 @@ const en = {
|
|
|
9
9
|
"page.cancel": "Cancel",
|
|
10
10
|
"page.ok": "OK",
|
|
11
11
|
"roles.title": "Default Role(s)",
|
|
12
|
+
"roles.placeholder": "Select default role(s)",
|
|
12
13
|
"whitelist.title": "Whitelist",
|
|
13
14
|
"whitelist.error.unique": "Already registered email address.",
|
|
14
15
|
"whitelist.enabled": "Whitelist is currently enabled.",
|
|
@@ -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-DNIqscJT.js"));
|
|
59
59
|
},
|
|
60
60
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
61
61
|
}
|
|
@@ -110,7 +110,7 @@ const index = {
|
|
|
110
110
|
async registerTrads({ locales }) {
|
|
111
111
|
const importedTrads = await Promise.all(
|
|
112
112
|
locales.map((locale) => {
|
|
113
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
|
113
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-8UlbiAHW.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
|
114
114
|
const newData = Object.fromEntries(
|
|
115
115
|
Object.entries(data).map(([key, value]) => [
|
|
116
116
|
key.startsWith("global.") ? key : getTranslation(key),
|
|
@@ -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-V4-lA3hu.mjs");
|
|
58
58
|
},
|
|
59
59
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
60
60
|
}
|
|
@@ -109,7 +109,7 @@ const index = {
|
|
|
109
109
|
async registerTrads({ locales }) {
|
|
110
110
|
const importedTrads = await Promise.all(
|
|
111
111
|
locales.map((locale) => {
|
|
112
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-
|
|
112
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-DInn-mdh.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
|
113
113
|
const newData = Object.fromEntries(
|
|
114
114
|
Object.entries(data).map(([key, value]) => [
|
|
115
115
|
key.startsWith("global.") ? key : getTranslation(key),
|
|
@@ -7,8 +7,8 @@ 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-
|
|
11
|
-
const en = require("./en-
|
|
10
|
+
const index = require("./index-Bc2bQNhu.js");
|
|
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 };
|
|
14
14
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -89,199 +89,177 @@ function Whitelist({
|
|
|
89
89
|
}, [email]);
|
|
90
90
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
|
91
91
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textColor: "neutral600", marginBottom: 4, children: formatMessage(getTrad("whitelist.description")) }),
|
|
92
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
93
|
-
/* @__PURE__ */ jsxRuntime.
|
|
94
|
-
designSystem.Field.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
designSystem.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
designSystem.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/* @__PURE__ */ jsxRuntime.
|
|
131
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/* @__PURE__ */ jsxRuntime.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
designSystem.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/* @__PURE__ */ jsxRuntime.
|
|
163
|
-
designSystem.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/* @__PURE__ */ jsxRuntime.
|
|
172
|
-
|
|
173
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/* @__PURE__ */ jsxRuntime.
|
|
179
|
-
|
|
180
|
-
designSystem.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
92
|
+
useWhitelist && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, marginTop: 5, marginBottom: 5, alignItems: "flex-start", children: [
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
95
|
+
designSystem.Field.Input,
|
|
96
|
+
{
|
|
97
|
+
type: "text",
|
|
98
|
+
disabled: loading,
|
|
99
|
+
value: email,
|
|
100
|
+
hasError: Boolean(email && !isValidEmail()),
|
|
101
|
+
onChange: (e) => setEmail(e.currentTarget.value),
|
|
102
|
+
placeholder: formatMessage(getTrad("whitelist.email.placeholder"))
|
|
103
|
+
}
|
|
104
|
+
) }) }),
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
106
|
+
designSystem.MultiSelect,
|
|
107
|
+
{
|
|
108
|
+
withTags: true,
|
|
109
|
+
placeholder: formatMessage(getTrad("whitelist.roles.placeholder")),
|
|
110
|
+
value: selectedRoles,
|
|
111
|
+
onChange: (value) => {
|
|
112
|
+
setSelectedRoles(value || []);
|
|
113
|
+
},
|
|
114
|
+
children: roles.map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: role.id.toString(), children: role.name }, role.id))
|
|
115
|
+
}
|
|
116
|
+
) }) }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
+
designSystem.Button,
|
|
119
|
+
{
|
|
120
|
+
size: "L",
|
|
121
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
122
|
+
disabled: loading || email.trim() === "" || !isValidEmail(),
|
|
123
|
+
loading,
|
|
124
|
+
onClick: onSaveEmail,
|
|
125
|
+
children: formatMessage(getTrad("page.add"))
|
|
126
|
+
}
|
|
127
|
+
) })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CustomTable, { colCount: 5, rowCount: users.length, children: [
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.no")) }),
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.email")) }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.roles")) }),
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.created")) }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { paddingRight: 0 }, children: " " })
|
|
137
|
+
] }) }),
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: users.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(getTrad("whitelist.table.empty")) }) }) }) }) : paginatedUsers.map((user, index2) => {
|
|
139
|
+
const getRoleNames = (roleIds) => roleIds.map((roleId) => {
|
|
140
|
+
const r = roles.find((ro) => String(ro.id) === String(roleId));
|
|
141
|
+
return r ? r.name : roleId;
|
|
142
|
+
}).join(", ");
|
|
143
|
+
let userRolesNames = getRoleNames(user.roles || []);
|
|
144
|
+
if (!userRolesNames) {
|
|
145
|
+
const defaultRolesIds = oidcRoles.reduce((acc, oidc) => {
|
|
146
|
+
if (oidc.role) acc.push(...oidc.role);
|
|
147
|
+
return acc;
|
|
148
|
+
}, []);
|
|
149
|
+
userRolesNames = getRoleNames(defaultRolesIds);
|
|
150
|
+
}
|
|
151
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: index2 + 1 + (page - 1) * PAGE_SIZE }),
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: user.email }),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: userRolesNames || "-" }),
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LocalizedDate, { date: user.createdAt }) }),
|
|
156
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { paddingRight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
157
|
+
designSystem.Flex,
|
|
158
|
+
{
|
|
159
|
+
justifyContent: "flex-end",
|
|
160
|
+
onClick: (e) => e.stopPropagation(),
|
|
161
|
+
style: { width: "100%" },
|
|
162
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { children: [
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
164
|
+
designSystem.IconButton,
|
|
165
|
+
{
|
|
166
|
+
label: formatMessage(getTrad("whitelist.delete.label")),
|
|
167
|
+
withTooltip: false,
|
|
168
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
169
|
+
}
|
|
170
|
+
) }),
|
|
171
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage(getTrad("whitelist.delete.title")) }),
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { fill: "danger600" }), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", children: formatMessage(getTrad("whitelist.delete.description")) }) }),
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", children: user.email }) }),
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(getTrad("whitelist.delete.note")) }) })
|
|
177
|
+
] }) }),
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant: "tertiary", children: formatMessage(getTrad("page.cancel")) }) }),
|
|
180
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
+
designSystem.Button,
|
|
182
|
+
{
|
|
183
|
+
fullWidth: true,
|
|
184
|
+
variant: "danger-light",
|
|
185
|
+
onClick: () => onDelete(user.email),
|
|
186
|
+
children: formatMessage(getTrad("page.ok"))
|
|
187
|
+
}
|
|
188
|
+
) })
|
|
189
|
+
] })
|
|
188
190
|
] })
|
|
189
191
|
] })
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
]
|
|
221
|
-
},
|
|
222
|
-
i + 1
|
|
223
|
-
)),
|
|
224
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
225
|
-
designSystem.NextLink,
|
|
226
|
-
{
|
|
227
|
-
href: "#",
|
|
228
|
-
onClick: (e) => {
|
|
229
|
-
e.preventDefault();
|
|
230
|
-
setPage((p) => Math.min(pageCount, p + 1));
|
|
192
|
+
}
|
|
193
|
+
) })
|
|
194
|
+
] }, user.email);
|
|
195
|
+
}) })
|
|
196
|
+
] }),
|
|
197
|
+
pageCount > 1 && /* @__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: [
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
199
|
+
designSystem.PreviousLink,
|
|
200
|
+
{
|
|
201
|
+
href: "#",
|
|
202
|
+
onClick: (e) => {
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
setPage((p) => Math.max(1, p - 1));
|
|
205
|
+
},
|
|
206
|
+
children: "Go to previous page"
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
Array.from({ length: pageCount }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
210
|
+
designSystem.PageLink,
|
|
211
|
+
{
|
|
212
|
+
number: i + 1,
|
|
213
|
+
href: "#",
|
|
214
|
+
onClick: (e) => {
|
|
215
|
+
e.preventDefault();
|
|
216
|
+
setPage(i + 1);
|
|
217
|
+
},
|
|
218
|
+
children: [
|
|
219
|
+
"Go to page ",
|
|
220
|
+
i + 1
|
|
221
|
+
]
|
|
231
222
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
223
|
+
i + 1
|
|
224
|
+
)),
|
|
225
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
226
|
+
designSystem.NextLink,
|
|
227
|
+
{
|
|
228
|
+
href: "#",
|
|
229
|
+
onClick: (e) => {
|
|
230
|
+
e.preventDefault();
|
|
231
|
+
setPage((p) => Math.min(pageCount, p + 1));
|
|
232
|
+
},
|
|
233
|
+
children: "Go to next page"
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
] }) }) })
|
|
237
|
+
] })
|
|
236
238
|
] }) });
|
|
237
239
|
}
|
|
238
240
|
const AlertMessage = styled__default.default.div`
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
position: fixed;
|
|
242
|
+
left: 50%;
|
|
243
|
+
transform: translateX(-50%);
|
|
244
|
+
top: 2.875rem;
|
|
245
|
+
z-index: 10;
|
|
246
|
+
width: 31.25rem;
|
|
245
247
|
`;
|
|
246
248
|
function SuccessAlertMessage({ onClose }) {
|
|
247
249
|
const { formatMessage } = reactIntl.useIntl();
|
|
248
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
249
|
-
designSystem.Alert,
|
|
250
|
-
{
|
|
251
|
-
title: "Success",
|
|
252
|
-
variant: "success",
|
|
253
|
-
closeLabel: "",
|
|
254
|
-
onClose,
|
|
255
|
-
children: formatMessage(getTrad("page.save.success"))
|
|
256
|
-
}
|
|
257
|
-
) });
|
|
250
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { title: "Success", variant: "success", closeLabel: "", onClose, children: formatMessage(getTrad("page.save.success")) }) });
|
|
258
251
|
}
|
|
259
252
|
function ErrorAlertMessage({ onClose }) {
|
|
260
253
|
const { formatMessage } = reactIntl.useIntl();
|
|
261
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
262
|
-
designSystem.Alert,
|
|
263
|
-
{
|
|
264
|
-
title: "Error",
|
|
265
|
-
variant: "danger",
|
|
266
|
-
closeLabel: "",
|
|
267
|
-
onClose,
|
|
268
|
-
children: formatMessage(getTrad("page.save.error"))
|
|
269
|
-
}
|
|
270
|
-
) });
|
|
254
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { title: "Error", variant: "danger", closeLabel: "", onClose, children: formatMessage(getTrad("page.save.error")) }) });
|
|
271
255
|
}
|
|
272
|
-
function MatchedUserAlertMessage({
|
|
256
|
+
function MatchedUserAlertMessage({
|
|
257
|
+
onClose,
|
|
258
|
+
count
|
|
259
|
+
}) {
|
|
273
260
|
const { formatMessage } = reactIntl.useIntl();
|
|
274
|
-
const id = count > 1 ? "
|
|
275
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
276
|
-
designSystem.Alert,
|
|
277
|
-
{
|
|
278
|
-
title: "Info",
|
|
279
|
-
variant: "default",
|
|
280
|
-
closeLabel: "",
|
|
281
|
-
onClose,
|
|
282
|
-
children: formatMessage(getTrad(id))
|
|
283
|
-
}
|
|
284
|
-
) });
|
|
261
|
+
const id = count > 1 ? "whitelist.users_exists" : "whitelist.user_exists";
|
|
262
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { title: "Info", variant: "default", closeLabel: "", onClose, children: formatMessage(getTrad(id)) }) });
|
|
285
263
|
}
|
|
286
264
|
const SwitchContainer = styled__default.default.label`
|
|
287
265
|
position: relative;
|
|
@@ -5,8 +5,8 @@ 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-
|
|
9
|
-
import en from "./en-
|
|
8
|
+
import { p as pluginId } from "./index-Cz9Q6j4e.mjs";
|
|
9
|
+
import en from "./en-DInn-mdh.mjs";
|
|
10
10
|
import styled from "styled-components";
|
|
11
11
|
function getTrad(id) {
|
|
12
12
|
const pluginIdWithId = `${pluginId}.${id}`;
|
|
@@ -85,199 +85,177 @@ function Whitelist({
|
|
|
85
85
|
}, [email]);
|
|
86
86
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
87
87
|
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textColor: "neutral600", marginBottom: 4, children: formatMessage(getTrad("whitelist.description")) }),
|
|
88
|
-
/* @__PURE__ */ jsxs(
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
Field.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */ jsx(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
|
|
169
|
-
/* @__PURE__ */ jsx(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
88
|
+
useWhitelist && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
89
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 4, marginTop: 5, marginBottom: 5, alignItems: "flex-start", children: [
|
|
90
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
|
|
91
|
+
Field.Input,
|
|
92
|
+
{
|
|
93
|
+
type: "text",
|
|
94
|
+
disabled: loading,
|
|
95
|
+
value: email,
|
|
96
|
+
hasError: Boolean(email && !isValidEmail()),
|
|
97
|
+
onChange: (e) => setEmail(e.currentTarget.value),
|
|
98
|
+
placeholder: formatMessage(getTrad("whitelist.email.placeholder"))
|
|
99
|
+
}
|
|
100
|
+
) }) }),
|
|
101
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
|
|
102
|
+
MultiSelect,
|
|
103
|
+
{
|
|
104
|
+
withTags: true,
|
|
105
|
+
placeholder: formatMessage(getTrad("whitelist.roles.placeholder")),
|
|
106
|
+
value: selectedRoles,
|
|
107
|
+
onChange: (value) => {
|
|
108
|
+
setSelectedRoles(value || []);
|
|
109
|
+
},
|
|
110
|
+
children: roles.map((role) => /* @__PURE__ */ jsx(MultiSelectOption, { value: role.id.toString(), children: role.name }, role.id))
|
|
111
|
+
}
|
|
112
|
+
) }) }),
|
|
113
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
114
|
+
Button,
|
|
115
|
+
{
|
|
116
|
+
size: "L",
|
|
117
|
+
startIcon: /* @__PURE__ */ jsx(Plus, {}),
|
|
118
|
+
disabled: loading || email.trim() === "" || !isValidEmail(),
|
|
119
|
+
loading,
|
|
120
|
+
onClick: onSaveEmail,
|
|
121
|
+
children: formatMessage(getTrad("page.add"))
|
|
122
|
+
}
|
|
123
|
+
) })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
126
|
+
/* @__PURE__ */ jsxs(CustomTable, { colCount: 5, rowCount: users.length, children: [
|
|
127
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Th, { children: formatMessage(getTrad("whitelist.table.no")) }),
|
|
129
|
+
/* @__PURE__ */ jsx(Th, { children: formatMessage(getTrad("whitelist.table.email")) }),
|
|
130
|
+
/* @__PURE__ */ jsx(Th, { children: formatMessage(getTrad("whitelist.table.roles")) }),
|
|
131
|
+
/* @__PURE__ */ jsx(Th, { children: formatMessage(getTrad("whitelist.table.created")) }),
|
|
132
|
+
/* @__PURE__ */ jsx(Th, { style: { paddingRight: 0 }, children: " " })
|
|
133
|
+
] }) }),
|
|
134
|
+
/* @__PURE__ */ jsx(Tbody, { children: users.length === 0 ? /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: 5, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage(getTrad("whitelist.table.empty")) }) }) }) }) : paginatedUsers.map((user, index) => {
|
|
135
|
+
const getRoleNames = (roleIds) => roleIds.map((roleId) => {
|
|
136
|
+
const r = roles.find((ro) => String(ro.id) === String(roleId));
|
|
137
|
+
return r ? r.name : roleId;
|
|
138
|
+
}).join(", ");
|
|
139
|
+
let userRolesNames = getRoleNames(user.roles || []);
|
|
140
|
+
if (!userRolesNames) {
|
|
141
|
+
const defaultRolesIds = oidcRoles.reduce((acc, oidc) => {
|
|
142
|
+
if (oidc.role) acc.push(...oidc.role);
|
|
143
|
+
return acc;
|
|
144
|
+
}, []);
|
|
145
|
+
userRolesNames = getRoleNames(defaultRolesIds);
|
|
146
|
+
}
|
|
147
|
+
return /* @__PURE__ */ jsxs(Tr, { children: [
|
|
148
|
+
/* @__PURE__ */ jsx(Td, { children: index + 1 + (page - 1) * PAGE_SIZE }),
|
|
149
|
+
/* @__PURE__ */ jsx(Td, { children: user.email }),
|
|
150
|
+
/* @__PURE__ */ jsx(Td, { children: userRolesNames || "-" }),
|
|
151
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(LocalizedDate, { date: user.createdAt }) }),
|
|
152
|
+
/* @__PURE__ */ jsx(Td, { style: { paddingRight: 0 }, children: /* @__PURE__ */ jsx(
|
|
153
|
+
Flex,
|
|
154
|
+
{
|
|
155
|
+
justifyContent: "flex-end",
|
|
156
|
+
onClick: (e) => e.stopPropagation(),
|
|
157
|
+
style: { width: "100%" },
|
|
158
|
+
children: /* @__PURE__ */ jsxs(Dialog.Root, { children: [
|
|
159
|
+
/* @__PURE__ */ jsx(Dialog.Trigger, { children: /* @__PURE__ */ jsx(
|
|
160
|
+
IconButton,
|
|
161
|
+
{
|
|
162
|
+
label: formatMessage(getTrad("whitelist.delete.label")),
|
|
163
|
+
withTooltip: false,
|
|
164
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
|
165
|
+
}
|
|
166
|
+
) }),
|
|
167
|
+
/* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
|
168
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage(getTrad("whitelist.delete.title")) }),
|
|
169
|
+
/* @__PURE__ */ jsx(Dialog.Body, { icon: /* @__PURE__ */ jsx(WarningCircle, { fill: "danger600" }), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
|
170
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { id: "confirm-description", children: formatMessage(getTrad("whitelist.delete.description")) }) }),
|
|
171
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", children: user.email }) }),
|
|
172
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", marginTop: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(getTrad("whitelist.delete.note")) }) })
|
|
173
|
+
] }) }),
|
|
174
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
|
175
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, variant: "tertiary", children: formatMessage(getTrad("page.cancel")) }) }),
|
|
176
|
+
/* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(
|
|
177
|
+
Button,
|
|
178
|
+
{
|
|
179
|
+
fullWidth: true,
|
|
180
|
+
variant: "danger-light",
|
|
181
|
+
onClick: () => onDelete(user.email),
|
|
182
|
+
children: formatMessage(getTrad("page.ok"))
|
|
183
|
+
}
|
|
184
|
+
) })
|
|
185
|
+
] })
|
|
184
186
|
] })
|
|
185
187
|
] })
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
]
|
|
217
|
-
},
|
|
218
|
-
i + 1
|
|
219
|
-
)),
|
|
220
|
-
/* @__PURE__ */ jsx(
|
|
221
|
-
NextLink,
|
|
222
|
-
{
|
|
223
|
-
href: "#",
|
|
224
|
-
onClick: (e) => {
|
|
225
|
-
e.preventDefault();
|
|
226
|
-
setPage((p) => Math.min(pageCount, p + 1));
|
|
188
|
+
}
|
|
189
|
+
) })
|
|
190
|
+
] }, user.email);
|
|
191
|
+
}) })
|
|
192
|
+
] }),
|
|
193
|
+
pageCount > 1 && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxs(Pagination, { activePage: page, pageCount, children: [
|
|
194
|
+
/* @__PURE__ */ jsx(
|
|
195
|
+
PreviousLink,
|
|
196
|
+
{
|
|
197
|
+
href: "#",
|
|
198
|
+
onClick: (e) => {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
setPage((p) => Math.max(1, p - 1));
|
|
201
|
+
},
|
|
202
|
+
children: "Go to previous page"
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
Array.from({ length: pageCount }).map((_, i) => /* @__PURE__ */ jsxs(
|
|
206
|
+
PageLink,
|
|
207
|
+
{
|
|
208
|
+
number: i + 1,
|
|
209
|
+
href: "#",
|
|
210
|
+
onClick: (e) => {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
setPage(i + 1);
|
|
213
|
+
},
|
|
214
|
+
children: [
|
|
215
|
+
"Go to page ",
|
|
216
|
+
i + 1
|
|
217
|
+
]
|
|
227
218
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
i + 1
|
|
220
|
+
)),
|
|
221
|
+
/* @__PURE__ */ jsx(
|
|
222
|
+
NextLink,
|
|
223
|
+
{
|
|
224
|
+
href: "#",
|
|
225
|
+
onClick: (e) => {
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
setPage((p) => Math.min(pageCount, p + 1));
|
|
228
|
+
},
|
|
229
|
+
children: "Go to next page"
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
] }) }) })
|
|
233
|
+
] })
|
|
232
234
|
] }) });
|
|
233
235
|
}
|
|
234
236
|
const AlertMessage = styled.div`
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
position: fixed;
|
|
238
|
+
left: 50%;
|
|
239
|
+
transform: translateX(-50%);
|
|
240
|
+
top: 2.875rem;
|
|
241
|
+
z-index: 10;
|
|
242
|
+
width: 31.25rem;
|
|
241
243
|
`;
|
|
242
244
|
function SuccessAlertMessage({ onClose }) {
|
|
243
245
|
const { formatMessage } = useIntl();
|
|
244
|
-
return /* @__PURE__ */ jsx(AlertMessage, { children: /* @__PURE__ */ jsx(
|
|
245
|
-
Alert,
|
|
246
|
-
{
|
|
247
|
-
title: "Success",
|
|
248
|
-
variant: "success",
|
|
249
|
-
closeLabel: "",
|
|
250
|
-
onClose,
|
|
251
|
-
children: formatMessage(getTrad("page.save.success"))
|
|
252
|
-
}
|
|
253
|
-
) });
|
|
246
|
+
return /* @__PURE__ */ jsx(AlertMessage, { children: /* @__PURE__ */ jsx(Alert, { title: "Success", variant: "success", closeLabel: "", onClose, children: formatMessage(getTrad("page.save.success")) }) });
|
|
254
247
|
}
|
|
255
248
|
function ErrorAlertMessage({ onClose }) {
|
|
256
249
|
const { formatMessage } = useIntl();
|
|
257
|
-
return /* @__PURE__ */ jsx(AlertMessage, { children: /* @__PURE__ */ jsx(
|
|
258
|
-
Alert,
|
|
259
|
-
{
|
|
260
|
-
title: "Error",
|
|
261
|
-
variant: "danger",
|
|
262
|
-
closeLabel: "",
|
|
263
|
-
onClose,
|
|
264
|
-
children: formatMessage(getTrad("page.save.error"))
|
|
265
|
-
}
|
|
266
|
-
) });
|
|
250
|
+
return /* @__PURE__ */ jsx(AlertMessage, { children: /* @__PURE__ */ jsx(Alert, { title: "Error", variant: "danger", closeLabel: "", onClose, children: formatMessage(getTrad("page.save.error")) }) });
|
|
267
251
|
}
|
|
268
|
-
function MatchedUserAlertMessage({
|
|
252
|
+
function MatchedUserAlertMessage({
|
|
253
|
+
onClose,
|
|
254
|
+
count
|
|
255
|
+
}) {
|
|
269
256
|
const { formatMessage } = useIntl();
|
|
270
|
-
const id = count > 1 ? "
|
|
271
|
-
return /* @__PURE__ */ jsx(AlertMessage, { children: /* @__PURE__ */ jsx(
|
|
272
|
-
Alert,
|
|
273
|
-
{
|
|
274
|
-
title: "Info",
|
|
275
|
-
variant: "default",
|
|
276
|
-
closeLabel: "",
|
|
277
|
-
onClose,
|
|
278
|
-
children: formatMessage(getTrad(id))
|
|
279
|
-
}
|
|
280
|
-
) });
|
|
257
|
+
const id = count > 1 ? "whitelist.users_exists" : "whitelist.user_exists";
|
|
258
|
+
return /* @__PURE__ */ jsx(AlertMessage, { children: /* @__PURE__ */ jsx(Alert, { title: "Info", variant: "default", closeLabel: "", onClose, children: formatMessage(getTrad(id)) }) });
|
|
281
259
|
}
|
|
282
260
|
const SwitchContainer = styled.label`
|
|
283
261
|
position: relative;
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const axios = require("axios");
|
|
4
3
|
const node_crypto = require("node:crypto");
|
|
5
4
|
const pkceChallenge = require("pkce-challenge");
|
|
6
5
|
const strapiUtils = require("@strapi/utils");
|
|
7
6
|
const generator = require("generate-password");
|
|
8
7
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
-
const axios__default = /* @__PURE__ */ _interopDefault(axios);
|
|
10
8
|
const pkceChallenge__default = /* @__PURE__ */ _interopDefault(pkceChallenge);
|
|
11
9
|
const strapiUtils__default = /* @__PURE__ */ _interopDefault(strapiUtils);
|
|
12
10
|
const generator__default = /* @__PURE__ */ _interopDefault(generator);
|
|
@@ -163,23 +161,40 @@ async function oidcSignIn(ctx) {
|
|
|
163
161
|
ctx.set("Location", authorizationUrl);
|
|
164
162
|
return ctx.send({}, 302);
|
|
165
163
|
}
|
|
166
|
-
async function exchangeTokenAndFetchUserInfo(
|
|
167
|
-
const response = await
|
|
164
|
+
async function exchangeTokenAndFetchUserInfo(config2, params) {
|
|
165
|
+
const response = await fetch(config2.OIDC_TOKEN_ENDPOINT, {
|
|
166
|
+
method: "POST",
|
|
167
|
+
body: params,
|
|
168
168
|
headers: {
|
|
169
169
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
const errText = await response.text();
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Failed to exchange token: ${response.status} ${response.statusText} - ${errText}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const tokenData = await response.json();
|
|
172
179
|
let userInfoEndpointHeaders = {};
|
|
173
|
-
let userInfoEndpointParameters = `?access_token=${
|
|
180
|
+
let userInfoEndpointParameters = `?access_token=${tokenData.access_token}`;
|
|
174
181
|
if (config2.OIDC_USER_INFO_ENDPOINT_WITH_AUTH_HEADER) {
|
|
175
182
|
userInfoEndpointHeaders = {
|
|
176
|
-
|
|
183
|
+
Authorization: `Bearer ${tokenData.access_token}`
|
|
177
184
|
};
|
|
178
185
|
userInfoEndpointParameters = "";
|
|
179
186
|
}
|
|
180
187
|
const userInfoEndpoint = `${config2.OIDC_USER_INFO_ENDPOINT}${userInfoEndpointParameters}`;
|
|
181
|
-
const userResponse = await
|
|
182
|
-
|
|
188
|
+
const userResponse = await fetch(userInfoEndpoint, {
|
|
189
|
+
headers: userInfoEndpointHeaders
|
|
190
|
+
});
|
|
191
|
+
if (!userResponse.ok) {
|
|
192
|
+
const errText = await userResponse.text();
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Failed to fetch user info: ${userResponse.status} ${userResponse.statusText} - ${errText}`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return await userResponse.json();
|
|
183
198
|
}
|
|
184
199
|
async function registerNewUser(userService, oauthService2, roleService2, email, userResponseData, whitelistUser, config2, ctx) {
|
|
185
200
|
let roles2 = [];
|
|
@@ -225,7 +240,6 @@ async function handleUserAuthentication(userService, oauthService2, roleService2
|
|
|
225
240
|
}
|
|
226
241
|
async function oidcSignInCallback(ctx) {
|
|
227
242
|
const config2 = configValidation();
|
|
228
|
-
const httpClient = axios__default.default.create();
|
|
229
243
|
const userService = strapi.service("admin::user");
|
|
230
244
|
const oauthService2 = strapi.plugin("strapi-plugin-oidc").service("oauth");
|
|
231
245
|
const roleService2 = strapi.plugin("strapi-plugin-oidc").service("role");
|
|
@@ -244,7 +258,7 @@ async function oidcSignInCallback(ctx) {
|
|
|
244
258
|
params.append("grant_type", config2.OIDC_GRANT_TYPE);
|
|
245
259
|
params.append("code_verifier", ctx.session.codeVerifier);
|
|
246
260
|
try {
|
|
247
|
-
const userResponseData = await exchangeTokenAndFetchUserInfo(
|
|
261
|
+
const userResponseData = await exchangeTokenAndFetchUserInfo(config2, params);
|
|
248
262
|
const { activateUser, jwtToken } = await handleUserAuthentication(
|
|
249
263
|
userService,
|
|
250
264
|
oauthService2,
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
1
|
import { randomUUID, randomBytes } from "node:crypto";
|
|
3
2
|
import pkceChallenge from "pkce-challenge";
|
|
4
3
|
import strapiUtils from "@strapi/utils";
|
|
@@ -156,23 +155,40 @@ async function oidcSignIn(ctx) {
|
|
|
156
155
|
ctx.set("Location", authorizationUrl);
|
|
157
156
|
return ctx.send({}, 302);
|
|
158
157
|
}
|
|
159
|
-
async function exchangeTokenAndFetchUserInfo(
|
|
160
|
-
const response = await
|
|
158
|
+
async function exchangeTokenAndFetchUserInfo(config2, params) {
|
|
159
|
+
const response = await fetch(config2.OIDC_TOKEN_ENDPOINT, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: params,
|
|
161
162
|
headers: {
|
|
162
163
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
163
164
|
}
|
|
164
165
|
});
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
const errText = await response.text();
|
|
168
|
+
throw new Error(
|
|
169
|
+
`Failed to exchange token: ${response.status} ${response.statusText} - ${errText}`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const tokenData = await response.json();
|
|
165
173
|
let userInfoEndpointHeaders = {};
|
|
166
|
-
let userInfoEndpointParameters = `?access_token=${
|
|
174
|
+
let userInfoEndpointParameters = `?access_token=${tokenData.access_token}`;
|
|
167
175
|
if (config2.OIDC_USER_INFO_ENDPOINT_WITH_AUTH_HEADER) {
|
|
168
176
|
userInfoEndpointHeaders = {
|
|
169
|
-
|
|
177
|
+
Authorization: `Bearer ${tokenData.access_token}`
|
|
170
178
|
};
|
|
171
179
|
userInfoEndpointParameters = "";
|
|
172
180
|
}
|
|
173
181
|
const userInfoEndpoint = `${config2.OIDC_USER_INFO_ENDPOINT}${userInfoEndpointParameters}`;
|
|
174
|
-
const userResponse = await
|
|
175
|
-
|
|
182
|
+
const userResponse = await fetch(userInfoEndpoint, {
|
|
183
|
+
headers: userInfoEndpointHeaders
|
|
184
|
+
});
|
|
185
|
+
if (!userResponse.ok) {
|
|
186
|
+
const errText = await userResponse.text();
|
|
187
|
+
throw new Error(
|
|
188
|
+
`Failed to fetch user info: ${userResponse.status} ${userResponse.statusText} - ${errText}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
return await userResponse.json();
|
|
176
192
|
}
|
|
177
193
|
async function registerNewUser(userService, oauthService2, roleService2, email, userResponseData, whitelistUser, config2, ctx) {
|
|
178
194
|
let roles2 = [];
|
|
@@ -218,7 +234,6 @@ async function handleUserAuthentication(userService, oauthService2, roleService2
|
|
|
218
234
|
}
|
|
219
235
|
async function oidcSignInCallback(ctx) {
|
|
220
236
|
const config2 = configValidation();
|
|
221
|
-
const httpClient = axios.create();
|
|
222
237
|
const userService = strapi.service("admin::user");
|
|
223
238
|
const oauthService2 = strapi.plugin("strapi-plugin-oidc").service("oauth");
|
|
224
239
|
const roleService2 = strapi.plugin("strapi-plugin-oidc").service("role");
|
|
@@ -237,7 +252,7 @@ async function oidcSignInCallback(ctx) {
|
|
|
237
252
|
params.append("grant_type", config2.OIDC_GRANT_TYPE);
|
|
238
253
|
params.append("code_verifier", ctx.session.codeVerifier);
|
|
239
254
|
try {
|
|
240
|
-
const userResponseData = await exchangeTokenAndFetchUserInfo(
|
|
255
|
+
const userResponseData = await exchangeTokenAndFetchUserInfo(config2, params);
|
|
241
256
|
const { activateUser, jwtToken } = await handleUserAuthentication(
|
|
242
257
|
userService,
|
|
243
258
|
oauthService2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-oidc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A Strapi plugin that provides OpenID Connect (OIDC) authentication functionality for the Strapi Admin Panel.",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"displayName": "OIDC Plugin",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@strapi/design-system": "^2.2.0",
|
|
39
39
|
"@strapi/icons": "^2.2.0",
|
|
40
40
|
"@strapi/utils": "^5.41.1",
|
|
41
|
-
"axios": "^1.14.0",
|
|
42
41
|
"generate-password": "^1.7.1",
|
|
43
42
|
"pkce-challenge": "^6.0.0",
|
|
44
43
|
"react": "^18.3.1",
|
|
@@ -84,7 +83,7 @@
|
|
|
84
83
|
"globals": "^17.4.0",
|
|
85
84
|
"husky": "^9.1.7",
|
|
86
85
|
"lint-staged": "^16.4.0",
|
|
87
|
-
"msw": "^2.
|
|
86
|
+
"msw": "^2.13.0",
|
|
88
87
|
"prettier": "^3.8.1",
|
|
89
88
|
"supertest": "^7.2.2",
|
|
90
89
|
"typescript": "^5.9.3",
|