strapi-plugin-oidc 1.0.7 → 1.0.9
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-Cz9Q6j4e.mjs → index-BADTLgSt.mjs} +7 -4
- package/dist/admin/{index-DNIqscJT.js → index-C762D8BZ.js} +1 -1
- package/dist/admin/{index-V4-lA3hu.mjs → index-CINLwPy3.mjs} +1 -1
- package/dist/admin/{index-Bc2bQNhu.js → index-Cq1ERJUV.js} +7 -4
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +48 -10
- package/dist/server/index.mjs +48 -9
- package/package.json +2 -3
|
@@ -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-CINLwPy3.mjs");
|
|
58
58
|
},
|
|
59
59
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
60
60
|
}
|
|
@@ -79,9 +79,12 @@ const index = {
|
|
|
79
79
|
const interceptHistory = (originalMethod) => {
|
|
80
80
|
return function(...args) {
|
|
81
81
|
const url = args[2];
|
|
82
|
-
if (url && typeof url === "string"
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
if (url && typeof url === "string") {
|
|
83
|
+
const urlWithoutQuery = url.split("?")[0].split("#")[0];
|
|
84
|
+
if (urlWithoutQuery.endsWith("/auth/login")) {
|
|
85
|
+
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
return originalMethod.apply(window.history, args);
|
|
87
90
|
};
|
|
@@ -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-Cq1ERJUV.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 };
|
|
@@ -5,7 +5,7 @@ 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-BADTLgSt.mjs";
|
|
9
9
|
import en from "./en-DInn-mdh.mjs";
|
|
10
10
|
import styled from "styled-components";
|
|
11
11
|
function getTrad(id) {
|
|
@@ -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-C762D8BZ.js"));
|
|
59
59
|
},
|
|
60
60
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
61
61
|
}
|
|
@@ -80,9 +80,12 @@ const index = {
|
|
|
80
80
|
const interceptHistory = (originalMethod) => {
|
|
81
81
|
return function(...args) {
|
|
82
82
|
const url = args[2];
|
|
83
|
-
if (url && typeof url === "string"
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
if (url && typeof url === "string") {
|
|
84
|
+
const urlWithoutQuery = url.split("?")[0].split("#")[0];
|
|
85
|
+
if (urlWithoutQuery.endsWith("/auth/login")) {
|
|
86
|
+
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
90
|
return originalMethod.apply(window.history, args);
|
|
88
91
|
};
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
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);
|
|
13
11
|
function register$1() {
|
|
14
12
|
}
|
|
15
13
|
async function bootstrap({ strapi: strapi2 }) {
|
|
14
|
+
strapi2.server.use(async (ctx, next) => {
|
|
15
|
+
if (ctx.request.path === "/admin/login" && ctx.request.method === "POST") {
|
|
16
|
+
try {
|
|
17
|
+
const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
|
|
18
|
+
const settings = await whitelistService2.getSettings();
|
|
19
|
+
if (settings && settings.enforceOIDC) {
|
|
20
|
+
ctx.status = 403;
|
|
21
|
+
ctx.body = {
|
|
22
|
+
data: null,
|
|
23
|
+
error: {
|
|
24
|
+
status: 403,
|
|
25
|
+
name: "ForbiddenError",
|
|
26
|
+
message: "Local login is disabled. Please use OIDC.",
|
|
27
|
+
details: {}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await next();
|
|
37
|
+
});
|
|
16
38
|
const actions = [
|
|
17
39
|
{
|
|
18
40
|
section: "plugins",
|
|
@@ -163,23 +185,40 @@ async function oidcSignIn(ctx) {
|
|
|
163
185
|
ctx.set("Location", authorizationUrl);
|
|
164
186
|
return ctx.send({}, 302);
|
|
165
187
|
}
|
|
166
|
-
async function exchangeTokenAndFetchUserInfo(
|
|
167
|
-
const response = await
|
|
188
|
+
async function exchangeTokenAndFetchUserInfo(config2, params) {
|
|
189
|
+
const response = await fetch(config2.OIDC_TOKEN_ENDPOINT, {
|
|
190
|
+
method: "POST",
|
|
191
|
+
body: params,
|
|
168
192
|
headers: {
|
|
169
193
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
170
194
|
}
|
|
171
195
|
});
|
|
196
|
+
if (!response.ok) {
|
|
197
|
+
const errText = await response.text();
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Failed to exchange token: ${response.status} ${response.statusText} - ${errText}`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
const tokenData = await response.json();
|
|
172
203
|
let userInfoEndpointHeaders = {};
|
|
173
|
-
let userInfoEndpointParameters = `?access_token=${
|
|
204
|
+
let userInfoEndpointParameters = `?access_token=${tokenData.access_token}`;
|
|
174
205
|
if (config2.OIDC_USER_INFO_ENDPOINT_WITH_AUTH_HEADER) {
|
|
175
206
|
userInfoEndpointHeaders = {
|
|
176
|
-
|
|
207
|
+
Authorization: `Bearer ${tokenData.access_token}`
|
|
177
208
|
};
|
|
178
209
|
userInfoEndpointParameters = "";
|
|
179
210
|
}
|
|
180
211
|
const userInfoEndpoint = `${config2.OIDC_USER_INFO_ENDPOINT}${userInfoEndpointParameters}`;
|
|
181
|
-
const userResponse = await
|
|
182
|
-
|
|
212
|
+
const userResponse = await fetch(userInfoEndpoint, {
|
|
213
|
+
headers: userInfoEndpointHeaders
|
|
214
|
+
});
|
|
215
|
+
if (!userResponse.ok) {
|
|
216
|
+
const errText = await userResponse.text();
|
|
217
|
+
throw new Error(
|
|
218
|
+
`Failed to fetch user info: ${userResponse.status} ${userResponse.statusText} - ${errText}`
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
return await userResponse.json();
|
|
183
222
|
}
|
|
184
223
|
async function registerNewUser(userService, oauthService2, roleService2, email, userResponseData, whitelistUser, config2, ctx) {
|
|
185
224
|
let roles2 = [];
|
|
@@ -225,7 +264,6 @@ async function handleUserAuthentication(userService, oauthService2, roleService2
|
|
|
225
264
|
}
|
|
226
265
|
async function oidcSignInCallback(ctx) {
|
|
227
266
|
const config2 = configValidation();
|
|
228
|
-
const httpClient = axios__default.default.create();
|
|
229
267
|
const userService = strapi.service("admin::user");
|
|
230
268
|
const oauthService2 = strapi.plugin("strapi-plugin-oidc").service("oauth");
|
|
231
269
|
const roleService2 = strapi.plugin("strapi-plugin-oidc").service("role");
|
|
@@ -244,7 +282,7 @@ async function oidcSignInCallback(ctx) {
|
|
|
244
282
|
params.append("grant_type", config2.OIDC_GRANT_TYPE);
|
|
245
283
|
params.append("code_verifier", ctx.session.codeVerifier);
|
|
246
284
|
try {
|
|
247
|
-
const userResponseData = await exchangeTokenAndFetchUserInfo(
|
|
285
|
+
const userResponseData = await exchangeTokenAndFetchUserInfo(config2, params);
|
|
248
286
|
const { activateUser, jwtToken } = await handleUserAuthentication(
|
|
249
287
|
userService,
|
|
250
288
|
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";
|
|
@@ -6,6 +5,30 @@ import generator from "generate-password";
|
|
|
6
5
|
function register$1() {
|
|
7
6
|
}
|
|
8
7
|
async function bootstrap({ strapi: strapi2 }) {
|
|
8
|
+
strapi2.server.use(async (ctx, next) => {
|
|
9
|
+
if (ctx.request.path === "/admin/login" && ctx.request.method === "POST") {
|
|
10
|
+
try {
|
|
11
|
+
const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
|
|
12
|
+
const settings = await whitelistService2.getSettings();
|
|
13
|
+
if (settings && settings.enforceOIDC) {
|
|
14
|
+
ctx.status = 403;
|
|
15
|
+
ctx.body = {
|
|
16
|
+
data: null,
|
|
17
|
+
error: {
|
|
18
|
+
status: 403,
|
|
19
|
+
name: "ForbiddenError",
|
|
20
|
+
message: "Local login is disabled. Please use OIDC.",
|
|
21
|
+
details: {}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
} catch (err) {
|
|
27
|
+
strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
await next();
|
|
31
|
+
});
|
|
9
32
|
const actions = [
|
|
10
33
|
{
|
|
11
34
|
section: "plugins",
|
|
@@ -156,23 +179,40 @@ async function oidcSignIn(ctx) {
|
|
|
156
179
|
ctx.set("Location", authorizationUrl);
|
|
157
180
|
return ctx.send({}, 302);
|
|
158
181
|
}
|
|
159
|
-
async function exchangeTokenAndFetchUserInfo(
|
|
160
|
-
const response = await
|
|
182
|
+
async function exchangeTokenAndFetchUserInfo(config2, params) {
|
|
183
|
+
const response = await fetch(config2.OIDC_TOKEN_ENDPOINT, {
|
|
184
|
+
method: "POST",
|
|
185
|
+
body: params,
|
|
161
186
|
headers: {
|
|
162
187
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
163
188
|
}
|
|
164
189
|
});
|
|
190
|
+
if (!response.ok) {
|
|
191
|
+
const errText = await response.text();
|
|
192
|
+
throw new Error(
|
|
193
|
+
`Failed to exchange token: ${response.status} ${response.statusText} - ${errText}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
const tokenData = await response.json();
|
|
165
197
|
let userInfoEndpointHeaders = {};
|
|
166
|
-
let userInfoEndpointParameters = `?access_token=${
|
|
198
|
+
let userInfoEndpointParameters = `?access_token=${tokenData.access_token}`;
|
|
167
199
|
if (config2.OIDC_USER_INFO_ENDPOINT_WITH_AUTH_HEADER) {
|
|
168
200
|
userInfoEndpointHeaders = {
|
|
169
|
-
|
|
201
|
+
Authorization: `Bearer ${tokenData.access_token}`
|
|
170
202
|
};
|
|
171
203
|
userInfoEndpointParameters = "";
|
|
172
204
|
}
|
|
173
205
|
const userInfoEndpoint = `${config2.OIDC_USER_INFO_ENDPOINT}${userInfoEndpointParameters}`;
|
|
174
|
-
const userResponse = await
|
|
175
|
-
|
|
206
|
+
const userResponse = await fetch(userInfoEndpoint, {
|
|
207
|
+
headers: userInfoEndpointHeaders
|
|
208
|
+
});
|
|
209
|
+
if (!userResponse.ok) {
|
|
210
|
+
const errText = await userResponse.text();
|
|
211
|
+
throw new Error(
|
|
212
|
+
`Failed to fetch user info: ${userResponse.status} ${userResponse.statusText} - ${errText}`
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return await userResponse.json();
|
|
176
216
|
}
|
|
177
217
|
async function registerNewUser(userService, oauthService2, roleService2, email, userResponseData, whitelistUser, config2, ctx) {
|
|
178
218
|
let roles2 = [];
|
|
@@ -218,7 +258,6 @@ async function handleUserAuthentication(userService, oauthService2, roleService2
|
|
|
218
258
|
}
|
|
219
259
|
async function oidcSignInCallback(ctx) {
|
|
220
260
|
const config2 = configValidation();
|
|
221
|
-
const httpClient = axios.create();
|
|
222
261
|
const userService = strapi.service("admin::user");
|
|
223
262
|
const oauthService2 = strapi.plugin("strapi-plugin-oidc").service("oauth");
|
|
224
263
|
const roleService2 = strapi.plugin("strapi-plugin-oidc").service("role");
|
|
@@ -237,7 +276,7 @@ async function oidcSignInCallback(ctx) {
|
|
|
237
276
|
params.append("grant_type", config2.OIDC_GRANT_TYPE);
|
|
238
277
|
params.append("code_verifier", ctx.session.codeVerifier);
|
|
239
278
|
try {
|
|
240
|
-
const userResponseData = await exchangeTokenAndFetchUserInfo(
|
|
279
|
+
const userResponseData = await exchangeTokenAndFetchUserInfo(config2, params);
|
|
241
280
|
const { activateUser, jwtToken } = await handleUserAuthentication(
|
|
242
281
|
userService,
|
|
243
282
|
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.9",
|
|
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",
|