strapi-plugin-oidc 1.1.2 → 1.2.1
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-BJPMfkrf.js +254 -0
- package/dist/admin/{index-aBuEmqza.js → index-CQSLiYnE.js} +57 -21
- package/dist/admin/index-DEfdDZQV.mjs +255 -0
- package/dist/admin/{index-DDUvU8_H.mjs → index-Dua1LXcu.mjs} +57 -21
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +51 -5
- package/dist/server/index.mjs +51 -5
- package/package.json +1 -1
- package/dist/admin/en-8UlbiAHW.js +0 -42
- package/dist/admin/en-DInn-mdh.mjs +0 -42
- package/dist/admin/index-Csm9fJS0.js +0 -155
- package/dist/admin/index-DxsqJhUk.mjs +0 -156
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from "react";
|
|
2
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
3
|
-
const v = glob[path];
|
|
4
|
-
if (v) {
|
|
5
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
6
|
-
}
|
|
7
|
-
return new Promise((_, reject) => {
|
|
8
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
9
|
-
reject.bind(
|
|
10
|
-
null,
|
|
11
|
-
new Error(
|
|
12
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
13
|
-
)
|
|
14
|
-
)
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
const name$1 = "strapi-plugin-oidc";
|
|
19
|
-
const strapi = { "displayName": "OIDC Plugin" };
|
|
20
|
-
const pluginPkg = {
|
|
21
|
-
name: name$1,
|
|
22
|
-
strapi
|
|
23
|
-
};
|
|
24
|
-
const pluginId = pluginPkg.name.replace(/^@strapi\/plugin-/i, "");
|
|
25
|
-
function getTranslation(id) {
|
|
26
|
-
return `${pluginId}.${id}`;
|
|
27
|
-
}
|
|
28
|
-
function Initializer({ setPlugin }) {
|
|
29
|
-
const ref = useRef();
|
|
30
|
-
ref.current = setPlugin;
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (ref.current) {
|
|
33
|
-
ref.current(pluginId);
|
|
34
|
-
}
|
|
35
|
-
}, []);
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const name = pluginPkg.strapi.displayName;
|
|
39
|
-
const index = {
|
|
40
|
-
register(app) {
|
|
41
|
-
app.addSettingsLink(
|
|
42
|
-
{
|
|
43
|
-
id: "oidc",
|
|
44
|
-
intlLabel: {
|
|
45
|
-
id: `${pluginId}.settings.section`,
|
|
46
|
-
defaultMessage: "OIDC"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "configuration",
|
|
51
|
-
to: `/settings/${pluginId}`,
|
|
52
|
-
intlLabel: {
|
|
53
|
-
id: `${pluginId}.settings.configuration`,
|
|
54
|
-
defaultMessage: "Configuration"
|
|
55
|
-
},
|
|
56
|
-
Component: async () => {
|
|
57
|
-
return await import("./index-DDUvU8_H.mjs");
|
|
58
|
-
},
|
|
59
|
-
permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
app.registerPlugin({
|
|
63
|
-
id: pluginId,
|
|
64
|
-
initializer: Initializer,
|
|
65
|
-
name
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
bootstrap() {
|
|
69
|
-
let isLogoutInProgress = false;
|
|
70
|
-
const isAuthRoute = (path) => /\/auth\/(login|register|forgot-password|reset-password)/.test(path);
|
|
71
|
-
const checkEnforceOIDC = async () => {
|
|
72
|
-
try {
|
|
73
|
-
const response = await window.fetch("/strapi-plugin-oidc/settings/public");
|
|
74
|
-
if (response.ok) {
|
|
75
|
-
const data = await response.json();
|
|
76
|
-
if (data.enforceOIDC) {
|
|
77
|
-
const interceptHistory = (originalMethod) => {
|
|
78
|
-
return function(...args) {
|
|
79
|
-
const url = args[2];
|
|
80
|
-
if (url && typeof url === "string") {
|
|
81
|
-
const urlWithoutQuery = url.split("?")[0].split("#")[0];
|
|
82
|
-
if (isAuthRoute(urlWithoutQuery)) {
|
|
83
|
-
if (isLogoutInProgress) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
window.location.href = "/strapi-plugin-oidc/oidc";
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return originalMethod.apply(window.history, args);
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
window.history.pushState = interceptHistory(window.history.pushState);
|
|
94
|
-
window.history.replaceState = interceptHistory(window.history.replaceState);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("Failed to check OIDC enforcement setting:", error);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
checkEnforceOIDC();
|
|
102
|
-
const originalFetch = window.fetch;
|
|
103
|
-
window.fetch = async (...args) => {
|
|
104
|
-
const url = typeof args[0] === "string" ? args[0] : args[0].url;
|
|
105
|
-
const isLogout = url && url.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
|
|
106
|
-
if (isLogout) {
|
|
107
|
-
isLogoutInProgress = true;
|
|
108
|
-
}
|
|
109
|
-
const response = await originalFetch(...args);
|
|
110
|
-
if (isLogout && response.ok) {
|
|
111
|
-
window.localStorage.removeItem("jwtToken");
|
|
112
|
-
window.localStorage.removeItem("isLoggedIn");
|
|
113
|
-
window.sessionStorage.removeItem("jwtToken");
|
|
114
|
-
window.sessionStorage.removeItem("isLoggedIn");
|
|
115
|
-
document.cookie = "jwtToken=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/";
|
|
116
|
-
document.cookie = "jwtToken=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/admin";
|
|
117
|
-
document.cookie = "strapi_admin_refresh=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/";
|
|
118
|
-
document.cookie = "strapi_admin_refresh=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/admin";
|
|
119
|
-
window.location.href = "/strapi-plugin-oidc/logout";
|
|
120
|
-
return new Promise(() => {
|
|
121
|
-
});
|
|
122
|
-
} else if (isLogout) {
|
|
123
|
-
isLogoutInProgress = false;
|
|
124
|
-
}
|
|
125
|
-
return response;
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
async registerTrads({ locales }) {
|
|
129
|
-
const importedTrads = await Promise.all(
|
|
130
|
-
locales.map((locale) => {
|
|
131
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-DInn-mdh.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
|
132
|
-
const newData = Object.fromEntries(
|
|
133
|
-
Object.entries(data).map(([key, value]) => [
|
|
134
|
-
key.startsWith("global.") ? key : getTranslation(key),
|
|
135
|
-
value
|
|
136
|
-
])
|
|
137
|
-
);
|
|
138
|
-
return {
|
|
139
|
-
data: newData,
|
|
140
|
-
locale
|
|
141
|
-
};
|
|
142
|
-
}).catch(() => {
|
|
143
|
-
return {
|
|
144
|
-
data: {},
|
|
145
|
-
locale
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
})
|
|
149
|
-
);
|
|
150
|
-
return Promise.resolve(importedTrads);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
export {
|
|
154
|
-
index as i,
|
|
155
|
-
pluginId as p
|
|
156
|
-
};
|