@kne/fastify-oidc 0.1.15 → 0.1.16
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.
|
@@ -43,9 +43,12 @@ module.exports = fp(async (fastify, options) => {
|
|
|
43
43
|
} else if (hintPlatform) {
|
|
44
44
|
const key = String(hintPlatform).replace(/\/+$/, '').toLowerCase();
|
|
45
45
|
selected = platforms.find(p => p.platformOrigin.toLowerCase() === key || p.platformName === hintPlatform);
|
|
46
|
-
} else if (platforms.length === 1) {
|
|
46
|
+
} else if (options.mode === 'central' && platforms.length === 1) {
|
|
47
|
+
// central 单平台:默认用该平台登录
|
|
47
48
|
selected = platforms[0];
|
|
48
49
|
}
|
|
50
|
+
// standalone:即使 hydrate 了配对主平台(供验运维令牌),默认登录仍用本进程 IdP,
|
|
51
|
+
// 否则前端会去主平台拿 token,本地 account 用户对不上 → getSuperAdminInfo 401
|
|
49
52
|
}
|
|
50
53
|
const issuer = selected?.issuer || runtime.issuer;
|
|
51
54
|
const clientId = selected?.clientId || runtime.clientId;
|
|
@@ -23,11 +23,8 @@ module.exports = ({ options, getLocalJWKS, getPlatforms }) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const resolveVerifyContext = (token, { audience } = {}) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return { jwks: local, issuer: runtime.issuer, audience: audience || runtime.audience };
|
|
29
|
-
}
|
|
30
|
-
|
|
26
|
+
// 先按 token.iss 匹配已配对 platforms(standalone 远程挂主平台时本地也有 IdP JWKS,
|
|
27
|
+
// 若优先走 local 会把主平台签发的运维令牌验成「服务令牌无效」)
|
|
31
28
|
const platforms = typeof getPlatforms === 'function' ? getPlatforms() : [];
|
|
32
29
|
if (platforms && platforms.length) {
|
|
33
30
|
let iss;
|
|
@@ -37,14 +34,18 @@ module.exports = ({ options, getLocalJWKS, getPlatforms }) => {
|
|
|
37
34
|
throw createError(null, 'authenticationFailed');
|
|
38
35
|
}
|
|
39
36
|
const platform = platforms.find(p => p.issuer === iss || p.issuer === String(iss || '').replace(/\/+$/, ''));
|
|
40
|
-
if (
|
|
41
|
-
|
|
37
|
+
if (platform && platform.status === 'paired') {
|
|
38
|
+
return {
|
|
39
|
+
jwks: getRemoteJWKS(platform.jwksUri || `${platform.issuer}/jwks`),
|
|
40
|
+
issuer: platform.issuer,
|
|
41
|
+
audience: audience || platform.audience || runtime.audience
|
|
42
|
+
};
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const local = getLocalJWKS && getLocalJWKS();
|
|
47
|
+
if (local) {
|
|
48
|
+
return { jwks: local, issuer: runtime.issuer, audience: audience || runtime.audience };
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kne/fastify-oidc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "基于 oidc-provider 的 Fastify OIDC 认证插件,支持 standalone / central 多项目单点登录、租户与跨项目令牌",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
],
|
|
26
26
|
"exports": {
|
|
27
27
|
".": "./index.js",
|
|
28
|
-
"./platform-assertion": "./platform-assertion.js"
|
|
28
|
+
"./platform-assertion": "./platform-assertion.js",
|
|
29
|
+
"./libs/utils/crypto": "./libs/utils/crypto.js"
|
|
29
30
|
},
|
|
30
31
|
"repository": {
|
|
31
32
|
"type": "git",
|