strapi-plugin-oidc 1.2.3 → 1.2.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/dist/admin/{index-CZ_FdaEz.mjs → index-B2dKk7YS.mjs} +20 -4
- package/dist/admin/{index-DuJfeoFu.mjs → index-BD7cK7Hf.mjs} +25 -3
- package/dist/admin/{index-DZwncy7E.js → index-CYL_geya.js} +25 -3
- package/dist/admin/{index-ENl8_IZn.js → index-Cxj6lwW7.js} +20 -4
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +16 -7
- package/dist/server/index.mjs +16 -7
- package/package.json +1 -1
|
@@ -73,7 +73,10 @@ const en = {
|
|
|
73
73
|
"enforce.toggle.enabled": "Enabled",
|
|
74
74
|
"enforce.toggle.disabled": "Disabled",
|
|
75
75
|
"enforce.warning": "Make sure OIDC is setup correctly before saving changes, you won't be able to login normally.",
|
|
76
|
-
"login.
|
|
76
|
+
"login.settings.title": "Login Settings",
|
|
77
|
+
"login.sso": "Login via SSO",
|
|
78
|
+
"login.sso.show": "Add button for OIDC on login screen",
|
|
79
|
+
"login.sso.button.text.label": "Login button text"
|
|
77
80
|
};
|
|
78
81
|
const en$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
79
82
|
__proto__: null,
|
|
@@ -98,7 +101,7 @@ const index = {
|
|
|
98
101
|
defaultMessage: "Configuration"
|
|
99
102
|
},
|
|
100
103
|
Component: async () => {
|
|
101
|
-
return await import("./index-
|
|
104
|
+
return await import("./index-BD7cK7Hf.mjs");
|
|
102
105
|
},
|
|
103
106
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
104
107
|
}
|
|
@@ -126,6 +129,10 @@ const index = {
|
|
|
126
129
|
if (isLogoutInProgress) {
|
|
127
130
|
return;
|
|
128
131
|
}
|
|
132
|
+
if (sessionStorage.getItem("oidc_logout")) {
|
|
133
|
+
sessionStorage.removeItem("oidc_logout");
|
|
134
|
+
return originalMethod.apply(window.history, args);
|
|
135
|
+
}
|
|
129
136
|
document.documentElement.style.visibility = "hidden";
|
|
130
137
|
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
131
138
|
return;
|
|
@@ -137,8 +144,13 @@ const index = {
|
|
|
137
144
|
window.history.pushState = interceptHistory(window.history.pushState);
|
|
138
145
|
window.history.replaceState = interceptHistory(window.history.replaceState);
|
|
139
146
|
if (isAuthRoute(window.location.pathname)) {
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
if (sessionStorage.getItem("oidc_logout")) {
|
|
148
|
+
sessionStorage.removeItem("oidc_logout");
|
|
149
|
+
document.documentElement.style.visibility = "";
|
|
150
|
+
} else {
|
|
151
|
+
document.documentElement.style.visibility = "hidden";
|
|
152
|
+
window.location.replace("/strapi-plugin-oidc/oidc");
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
155
|
};
|
|
144
156
|
let ssoButtonInjected = false;
|
|
@@ -180,6 +192,9 @@ const index = {
|
|
|
180
192
|
document.getElementById("strapi-oidc-sso-btn")?.remove();
|
|
181
193
|
ssoButtonInjected = false;
|
|
182
194
|
};
|
|
195
|
+
if (!localStorage.getItem("jwtToken") && !sessionStorage.getItem("oidc_logout")) {
|
|
196
|
+
document.documentElement.style.visibility = "hidden";
|
|
197
|
+
}
|
|
183
198
|
if (localStorage.getItem(ENFORCE_CACHE_KEY) === "1") {
|
|
184
199
|
patchHistory();
|
|
185
200
|
}
|
|
@@ -227,6 +242,7 @@ const index = {
|
|
|
227
242
|
window.sessionStorage.removeItem("isLoggedIn");
|
|
228
243
|
document.cookie = "jwtToken=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/";
|
|
229
244
|
document.cookie = "jwtToken=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/admin";
|
|
245
|
+
sessionStorage.setItem("oidc_logout", "1");
|
|
230
246
|
window.location.href = "/strapi-plugin-oidc/logout";
|
|
231
247
|
return new Promise(() => {
|
|
232
248
|
});
|
|
@@ -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, TextInput } from "@strapi/design-system";
|
|
6
6
|
import { Plus, Trash, WarningCircle } from "@strapi/icons";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
|
-
import { e as en, p as pluginId } from "./index-
|
|
8
|
+
import { e as en, p as pluginId } from "./index-B2dKk7YS.mjs";
|
|
9
9
|
import styled from "styled-components";
|
|
10
10
|
function getTrad(id) {
|
|
11
11
|
const pluginIdWithId = `${pluginId}.${id}`;
|
|
@@ -344,6 +344,10 @@ function useOidcSettings() {
|
|
|
344
344
|
const [enforceOIDC, setEnforceOIDC] = useState(false);
|
|
345
345
|
const [initialUsers, setInitialUsers] = useState([]);
|
|
346
346
|
const [users, setUsers] = useState([]);
|
|
347
|
+
const [initialShowSSOButton, setInitialShowSSOButton] = useState(true);
|
|
348
|
+
const [showSSOButton, setShowSSOButton] = useState(true);
|
|
349
|
+
const [initialSSOButtonText, setInitialSSOButtonText] = useState("Login via SSO");
|
|
350
|
+
const [ssoButtonText, setSSOButtonText] = useState("Login via SSO");
|
|
347
351
|
useEffect(() => {
|
|
348
352
|
get(`/strapi-plugin-oidc/oidc-roles`).then((response) => {
|
|
349
353
|
setOIDCRoles(response.data);
|
|
@@ -359,6 +363,10 @@ function useOidcSettings() {
|
|
|
359
363
|
setInitialUseWhitelist(response.data.useWhitelist);
|
|
360
364
|
setEnforceOIDC(response.data.enforceOIDC);
|
|
361
365
|
setInitialEnforceOIDC(response.data.enforceOIDC);
|
|
366
|
+
setShowSSOButton(response.data.showSSOButton !== false);
|
|
367
|
+
setInitialShowSSOButton(response.data.showSSOButton !== false);
|
|
368
|
+
setSSOButtonText(response.data.ssoButtonText || "Login via SSO");
|
|
369
|
+
setInitialSSOButtonText(response.data.ssoButtonText || "Login via SSO");
|
|
362
370
|
});
|
|
363
371
|
}, [get]);
|
|
364
372
|
const onChangeRole = (values, oidcId) => {
|
|
@@ -388,7 +396,13 @@ function useOidcSettings() {
|
|
|
388
396
|
const onToggleEnforce = (e) => {
|
|
389
397
|
setEnforceOIDC(e.target.checked);
|
|
390
398
|
};
|
|
391
|
-
const
|
|
399
|
+
const onToggleShowSSOButton = (e) => {
|
|
400
|
+
setShowSSOButton(e.target.checked);
|
|
401
|
+
};
|
|
402
|
+
const onChangeSSOButtonText = (e) => {
|
|
403
|
+
setSSOButtonText(e.target.value);
|
|
404
|
+
};
|
|
405
|
+
const isDirty = useWhitelist !== initialUseWhitelist || enforceOIDC !== initialEnforceOIDC || showSSOButton !== initialShowSSOButton || ssoButtonText !== initialSSOButtonText || JSON.stringify(oidcRoles) !== JSON.stringify(initialOidcRoles) || JSON.stringify(users) !== JSON.stringify(initialUsers);
|
|
392
406
|
const onSaveAll = async () => {
|
|
393
407
|
setLoading(true);
|
|
394
408
|
try {
|
|
@@ -403,11 +417,15 @@ function useOidcSettings() {
|
|
|
403
417
|
});
|
|
404
418
|
await put("/strapi-plugin-oidc/whitelist/settings", {
|
|
405
419
|
useWhitelist,
|
|
406
|
-
enforceOIDC
|
|
420
|
+
enforceOIDC,
|
|
421
|
+
showSSOButton,
|
|
422
|
+
ssoButtonText
|
|
407
423
|
});
|
|
408
424
|
setInitialOIDCRoles(JSON.parse(JSON.stringify(oidcRoles)));
|
|
409
425
|
setInitialUseWhitelist(useWhitelist);
|
|
410
426
|
setInitialEnforceOIDC(enforceOIDC);
|
|
427
|
+
setInitialShowSSOButton(showSSOButton);
|
|
428
|
+
setInitialSSOButtonText(ssoButtonText);
|
|
411
429
|
get("/strapi-plugin-oidc/whitelist").then((getResponse) => {
|
|
412
430
|
setUsers(getResponse.data.whitelistUsers);
|
|
413
431
|
setInitialUsers(JSON.parse(JSON.stringify(getResponse.data.whitelistUsers)));
|
|
@@ -439,6 +457,8 @@ function useOidcSettings() {
|
|
|
439
457
|
enforceOIDC,
|
|
440
458
|
initialEnforceOIDC,
|
|
441
459
|
users,
|
|
460
|
+
showSSOButton,
|
|
461
|
+
ssoButtonText,
|
|
442
462
|
isDirty
|
|
443
463
|
},
|
|
444
464
|
actions: {
|
|
@@ -450,6 +470,8 @@ function useOidcSettings() {
|
|
|
450
470
|
onDeleteWhitelist,
|
|
451
471
|
onToggleWhitelist,
|
|
452
472
|
onToggleEnforce,
|
|
473
|
+
onToggleShowSSOButton,
|
|
474
|
+
onChangeSSOButtonText,
|
|
453
475
|
onSaveAll
|
|
454
476
|
}
|
|
455
477
|
};
|
|
@@ -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-Cxj6lwW7.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);
|
|
@@ -348,6 +348,10 @@ function useOidcSettings() {
|
|
|
348
348
|
const [enforceOIDC, setEnforceOIDC] = react.useState(false);
|
|
349
349
|
const [initialUsers, setInitialUsers] = react.useState([]);
|
|
350
350
|
const [users, setUsers] = react.useState([]);
|
|
351
|
+
const [initialShowSSOButton, setInitialShowSSOButton] = react.useState(true);
|
|
352
|
+
const [showSSOButton, setShowSSOButton] = react.useState(true);
|
|
353
|
+
const [initialSSOButtonText, setInitialSSOButtonText] = react.useState("Login via SSO");
|
|
354
|
+
const [ssoButtonText, setSSOButtonText] = react.useState("Login via SSO");
|
|
351
355
|
react.useEffect(() => {
|
|
352
356
|
get(`/strapi-plugin-oidc/oidc-roles`).then((response) => {
|
|
353
357
|
setOIDCRoles(response.data);
|
|
@@ -363,6 +367,10 @@ function useOidcSettings() {
|
|
|
363
367
|
setInitialUseWhitelist(response.data.useWhitelist);
|
|
364
368
|
setEnforceOIDC(response.data.enforceOIDC);
|
|
365
369
|
setInitialEnforceOIDC(response.data.enforceOIDC);
|
|
370
|
+
setShowSSOButton(response.data.showSSOButton !== false);
|
|
371
|
+
setInitialShowSSOButton(response.data.showSSOButton !== false);
|
|
372
|
+
setSSOButtonText(response.data.ssoButtonText || "Login via SSO");
|
|
373
|
+
setInitialSSOButtonText(response.data.ssoButtonText || "Login via SSO");
|
|
366
374
|
});
|
|
367
375
|
}, [get]);
|
|
368
376
|
const onChangeRole = (values, oidcId) => {
|
|
@@ -392,7 +400,13 @@ function useOidcSettings() {
|
|
|
392
400
|
const onToggleEnforce = (e) => {
|
|
393
401
|
setEnforceOIDC(e.target.checked);
|
|
394
402
|
};
|
|
395
|
-
const
|
|
403
|
+
const onToggleShowSSOButton = (e) => {
|
|
404
|
+
setShowSSOButton(e.target.checked);
|
|
405
|
+
};
|
|
406
|
+
const onChangeSSOButtonText = (e) => {
|
|
407
|
+
setSSOButtonText(e.target.value);
|
|
408
|
+
};
|
|
409
|
+
const isDirty = useWhitelist !== initialUseWhitelist || enforceOIDC !== initialEnforceOIDC || showSSOButton !== initialShowSSOButton || ssoButtonText !== initialSSOButtonText || JSON.stringify(oidcRoles) !== JSON.stringify(initialOidcRoles) || JSON.stringify(users) !== JSON.stringify(initialUsers);
|
|
396
410
|
const onSaveAll = async () => {
|
|
397
411
|
setLoading(true);
|
|
398
412
|
try {
|
|
@@ -407,11 +421,15 @@ function useOidcSettings() {
|
|
|
407
421
|
});
|
|
408
422
|
await put("/strapi-plugin-oidc/whitelist/settings", {
|
|
409
423
|
useWhitelist,
|
|
410
|
-
enforceOIDC
|
|
424
|
+
enforceOIDC,
|
|
425
|
+
showSSOButton,
|
|
426
|
+
ssoButtonText
|
|
411
427
|
});
|
|
412
428
|
setInitialOIDCRoles(JSON.parse(JSON.stringify(oidcRoles)));
|
|
413
429
|
setInitialUseWhitelist(useWhitelist);
|
|
414
430
|
setInitialEnforceOIDC(enforceOIDC);
|
|
431
|
+
setInitialShowSSOButton(showSSOButton);
|
|
432
|
+
setInitialSSOButtonText(ssoButtonText);
|
|
415
433
|
get("/strapi-plugin-oidc/whitelist").then((getResponse) => {
|
|
416
434
|
setUsers(getResponse.data.whitelistUsers);
|
|
417
435
|
setInitialUsers(JSON.parse(JSON.stringify(getResponse.data.whitelistUsers)));
|
|
@@ -443,6 +461,8 @@ function useOidcSettings() {
|
|
|
443
461
|
enforceOIDC,
|
|
444
462
|
initialEnforceOIDC,
|
|
445
463
|
users,
|
|
464
|
+
showSSOButton,
|
|
465
|
+
ssoButtonText,
|
|
446
466
|
isDirty
|
|
447
467
|
},
|
|
448
468
|
actions: {
|
|
@@ -454,6 +474,8 @@ function useOidcSettings() {
|
|
|
454
474
|
onDeleteWhitelist,
|
|
455
475
|
onToggleWhitelist,
|
|
456
476
|
onToggleEnforce,
|
|
477
|
+
onToggleShowSSOButton,
|
|
478
|
+
onChangeSSOButtonText,
|
|
457
479
|
onSaveAll
|
|
458
480
|
}
|
|
459
481
|
};
|
|
@@ -74,7 +74,10 @@ const en = {
|
|
|
74
74
|
"enforce.toggle.enabled": "Enabled",
|
|
75
75
|
"enforce.toggle.disabled": "Disabled",
|
|
76
76
|
"enforce.warning": "Make sure OIDC is setup correctly before saving changes, you won't be able to login normally.",
|
|
77
|
-
"login.
|
|
77
|
+
"login.settings.title": "Login Settings",
|
|
78
|
+
"login.sso": "Login via SSO",
|
|
79
|
+
"login.sso.show": "Add button for OIDC on login screen",
|
|
80
|
+
"login.sso.button.text.label": "Login button text"
|
|
78
81
|
};
|
|
79
82
|
const en$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
80
83
|
__proto__: null,
|
|
@@ -99,7 +102,7 @@ const index = {
|
|
|
99
102
|
defaultMessage: "Configuration"
|
|
100
103
|
},
|
|
101
104
|
Component: async () => {
|
|
102
|
-
return await Promise.resolve().then(() => require("./index-
|
|
105
|
+
return await Promise.resolve().then(() => require("./index-CYL_geya.js"));
|
|
103
106
|
},
|
|
104
107
|
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
105
108
|
}
|
|
@@ -127,6 +130,10 @@ const index = {
|
|
|
127
130
|
if (isLogoutInProgress) {
|
|
128
131
|
return;
|
|
129
132
|
}
|
|
133
|
+
if (sessionStorage.getItem("oidc_logout")) {
|
|
134
|
+
sessionStorage.removeItem("oidc_logout");
|
|
135
|
+
return originalMethod.apply(window.history, args);
|
|
136
|
+
}
|
|
130
137
|
document.documentElement.style.visibility = "hidden";
|
|
131
138
|
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
132
139
|
return;
|
|
@@ -138,8 +145,13 @@ const index = {
|
|
|
138
145
|
window.history.pushState = interceptHistory(window.history.pushState);
|
|
139
146
|
window.history.replaceState = interceptHistory(window.history.replaceState);
|
|
140
147
|
if (isAuthRoute(window.location.pathname)) {
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
if (sessionStorage.getItem("oidc_logout")) {
|
|
149
|
+
sessionStorage.removeItem("oidc_logout");
|
|
150
|
+
document.documentElement.style.visibility = "";
|
|
151
|
+
} else {
|
|
152
|
+
document.documentElement.style.visibility = "hidden";
|
|
153
|
+
window.location.replace("/strapi-plugin-oidc/oidc");
|
|
154
|
+
}
|
|
143
155
|
}
|
|
144
156
|
};
|
|
145
157
|
let ssoButtonInjected = false;
|
|
@@ -181,6 +193,9 @@ const index = {
|
|
|
181
193
|
document.getElementById("strapi-oidc-sso-btn")?.remove();
|
|
182
194
|
ssoButtonInjected = false;
|
|
183
195
|
};
|
|
196
|
+
if (!localStorage.getItem("jwtToken") && !sessionStorage.getItem("oidc_logout")) {
|
|
197
|
+
document.documentElement.style.visibility = "hidden";
|
|
198
|
+
}
|
|
184
199
|
if (localStorage.getItem(ENFORCE_CACHE_KEY) === "1") {
|
|
185
200
|
patchHistory();
|
|
186
201
|
}
|
|
@@ -228,6 +243,7 @@ const index = {
|
|
|
228
243
|
window.sessionStorage.removeItem("isLoggedIn");
|
|
229
244
|
document.cookie = "jwtToken=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/";
|
|
230
245
|
document.cookie = "jwtToken=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/admin";
|
|
246
|
+
sessionStorage.setItem("oidc_logout", "1");
|
|
231
247
|
window.location.href = "/strapi-plugin-oidc/logout";
|
|
232
248
|
return new Promise(() => {
|
|
233
249
|
});
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -25,7 +25,7 @@ function getExpiredCookieOptions(strapi2, ctx) {
|
|
|
25
25
|
function clearAuthCookies(strapi2, ctx) {
|
|
26
26
|
const options2 = getExpiredCookieOptions(strapi2, ctx);
|
|
27
27
|
ctx.cookies.set("strapi_admin_refresh", "", options2);
|
|
28
|
-
ctx.cookies.set("oidc_authenticated", "", options2);
|
|
28
|
+
ctx.cookies.set("oidc_authenticated", "", { ...options2, path: "/" });
|
|
29
29
|
}
|
|
30
30
|
async function bootstrap({ strapi: strapi2 }) {
|
|
31
31
|
const enforceOidcMiddleware = async (ctx, next) => {
|
|
@@ -426,11 +426,13 @@ async function info(ctx) {
|
|
|
426
426
|
ctx.body = {
|
|
427
427
|
useWhitelist: settings.useWhitelist,
|
|
428
428
|
enforceOIDC: settings.enforceOIDC || false,
|
|
429
|
+
showSSOButton: settings.showSSOButton !== false,
|
|
430
|
+
ssoButtonText: settings.ssoButtonText || "Login via SSO",
|
|
429
431
|
whitelistUsers
|
|
430
432
|
};
|
|
431
433
|
}
|
|
432
434
|
async function updateSettings(ctx) {
|
|
433
|
-
let { useWhitelist, enforceOIDC } = ctx.request.body;
|
|
435
|
+
let { useWhitelist, enforceOIDC, showSSOButton, ssoButtonText } = ctx.request.body;
|
|
434
436
|
const whitelistService2 = strapi.plugin("strapi-plugin-oidc").service("whitelist");
|
|
435
437
|
if (useWhitelist && enforceOIDC) {
|
|
436
438
|
const users = await whitelistService2.getUsers();
|
|
@@ -438,14 +440,16 @@ async function updateSettings(ctx) {
|
|
|
438
440
|
enforceOIDC = false;
|
|
439
441
|
}
|
|
440
442
|
}
|
|
441
|
-
await whitelistService2.setSettings({ useWhitelist, enforceOIDC });
|
|
442
|
-
ctx.body = { useWhitelist, enforceOIDC };
|
|
443
|
+
await whitelistService2.setSettings({ useWhitelist, enforceOIDC, showSSOButton, ssoButtonText });
|
|
444
|
+
ctx.body = { useWhitelist, enforceOIDC, showSSOButton, ssoButtonText };
|
|
443
445
|
}
|
|
444
446
|
async function publicSettings(ctx) {
|
|
445
447
|
const whitelistService2 = strapi.plugin("strapi-plugin-oidc").service("whitelist");
|
|
446
448
|
const settings = await whitelistService2.getSettings();
|
|
447
449
|
ctx.body = {
|
|
448
|
-
enforceOIDC: settings.enforceOIDC || false
|
|
450
|
+
enforceOIDC: settings.enforceOIDC || false,
|
|
451
|
+
showSSOButton: settings.showSSOButton !== false,
|
|
452
|
+
ssoButtonText: settings.ssoButtonText || "Login via SSO"
|
|
449
453
|
};
|
|
450
454
|
}
|
|
451
455
|
async function register(ctx) {
|
|
@@ -956,7 +960,7 @@ function oauthService({ strapi: strapi2 }) {
|
|
|
956
960
|
cookieOptions.expires = new Date(Date.now() + durationInMs);
|
|
957
961
|
}
|
|
958
962
|
ctx.cookies.set("strapi_admin_refresh", refreshToken, cookieOptions);
|
|
959
|
-
ctx.cookies.set("oidc_authenticated", "1", cookieOptions);
|
|
963
|
+
ctx.cookies.set("oidc_authenticated", "1", { ...cookieOptions, path: "/" });
|
|
960
964
|
const accessResult = await sessionManager("admin").generateAccessToken(refreshToken);
|
|
961
965
|
if ("error" in accessResult) {
|
|
962
966
|
throw new Error(accessResult.error);
|
|
@@ -1027,7 +1031,12 @@ function whitelistService({ strapi: strapi2 }) {
|
|
|
1027
1031
|
}
|
|
1028
1032
|
let settings = await getPluginStore().get({ key: "settings" });
|
|
1029
1033
|
if (!settings) {
|
|
1030
|
-
settings = {
|
|
1034
|
+
settings = {
|
|
1035
|
+
useWhitelist: true,
|
|
1036
|
+
enforceOIDC: false,
|
|
1037
|
+
showSSOButton: true,
|
|
1038
|
+
ssoButtonText: "Login via SSO"
|
|
1039
|
+
};
|
|
1031
1040
|
await getPluginStore().set({ key: "settings", value: settings });
|
|
1032
1041
|
}
|
|
1033
1042
|
settingsCache = { value: settings, ts: now };
|
package/dist/server/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ function getExpiredCookieOptions(strapi2, ctx) {
|
|
|
19
19
|
function clearAuthCookies(strapi2, ctx) {
|
|
20
20
|
const options2 = getExpiredCookieOptions(strapi2, ctx);
|
|
21
21
|
ctx.cookies.set("strapi_admin_refresh", "", options2);
|
|
22
|
-
ctx.cookies.set("oidc_authenticated", "", options2);
|
|
22
|
+
ctx.cookies.set("oidc_authenticated", "", { ...options2, path: "/" });
|
|
23
23
|
}
|
|
24
24
|
async function bootstrap({ strapi: strapi2 }) {
|
|
25
25
|
const enforceOidcMiddleware = async (ctx, next) => {
|
|
@@ -420,11 +420,13 @@ async function info(ctx) {
|
|
|
420
420
|
ctx.body = {
|
|
421
421
|
useWhitelist: settings.useWhitelist,
|
|
422
422
|
enforceOIDC: settings.enforceOIDC || false,
|
|
423
|
+
showSSOButton: settings.showSSOButton !== false,
|
|
424
|
+
ssoButtonText: settings.ssoButtonText || "Login via SSO",
|
|
423
425
|
whitelistUsers
|
|
424
426
|
};
|
|
425
427
|
}
|
|
426
428
|
async function updateSettings(ctx) {
|
|
427
|
-
let { useWhitelist, enforceOIDC } = ctx.request.body;
|
|
429
|
+
let { useWhitelist, enforceOIDC, showSSOButton, ssoButtonText } = ctx.request.body;
|
|
428
430
|
const whitelistService2 = strapi.plugin("strapi-plugin-oidc").service("whitelist");
|
|
429
431
|
if (useWhitelist && enforceOIDC) {
|
|
430
432
|
const users = await whitelistService2.getUsers();
|
|
@@ -432,14 +434,16 @@ async function updateSettings(ctx) {
|
|
|
432
434
|
enforceOIDC = false;
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
|
-
await whitelistService2.setSettings({ useWhitelist, enforceOIDC });
|
|
436
|
-
ctx.body = { useWhitelist, enforceOIDC };
|
|
437
|
+
await whitelistService2.setSettings({ useWhitelist, enforceOIDC, showSSOButton, ssoButtonText });
|
|
438
|
+
ctx.body = { useWhitelist, enforceOIDC, showSSOButton, ssoButtonText };
|
|
437
439
|
}
|
|
438
440
|
async function publicSettings(ctx) {
|
|
439
441
|
const whitelistService2 = strapi.plugin("strapi-plugin-oidc").service("whitelist");
|
|
440
442
|
const settings = await whitelistService2.getSettings();
|
|
441
443
|
ctx.body = {
|
|
442
|
-
enforceOIDC: settings.enforceOIDC || false
|
|
444
|
+
enforceOIDC: settings.enforceOIDC || false,
|
|
445
|
+
showSSOButton: settings.showSSOButton !== false,
|
|
446
|
+
ssoButtonText: settings.ssoButtonText || "Login via SSO"
|
|
443
447
|
};
|
|
444
448
|
}
|
|
445
449
|
async function register(ctx) {
|
|
@@ -950,7 +954,7 @@ function oauthService({ strapi: strapi2 }) {
|
|
|
950
954
|
cookieOptions.expires = new Date(Date.now() + durationInMs);
|
|
951
955
|
}
|
|
952
956
|
ctx.cookies.set("strapi_admin_refresh", refreshToken, cookieOptions);
|
|
953
|
-
ctx.cookies.set("oidc_authenticated", "1", cookieOptions);
|
|
957
|
+
ctx.cookies.set("oidc_authenticated", "1", { ...cookieOptions, path: "/" });
|
|
954
958
|
const accessResult = await sessionManager("admin").generateAccessToken(refreshToken);
|
|
955
959
|
if ("error" in accessResult) {
|
|
956
960
|
throw new Error(accessResult.error);
|
|
@@ -1021,7 +1025,12 @@ function whitelistService({ strapi: strapi2 }) {
|
|
|
1021
1025
|
}
|
|
1022
1026
|
let settings = await getPluginStore().get({ key: "settings" });
|
|
1023
1027
|
if (!settings) {
|
|
1024
|
-
settings = {
|
|
1028
|
+
settings = {
|
|
1029
|
+
useWhitelist: true,
|
|
1030
|
+
enforceOIDC: false,
|
|
1031
|
+
showSSOButton: true,
|
|
1032
|
+
ssoButtonText: "Login via SSO"
|
|
1033
|
+
};
|
|
1025
1034
|
await getPluginStore().set({ key: "settings", value: settings });
|
|
1026
1035
|
}
|
|
1027
1036
|
settingsCache = { value: settings, ts: now };
|
package/package.json
CHANGED