opencode-codebuddy-external-auth 1.0.27 → 1.0.28
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/plugin.js +12 -0
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -59,6 +59,16 @@ function extractTenantIdFromIss(iss) {
|
|
|
59
59
|
const match = iss.match(/realms\/sso-([^/]+)$/);
|
|
60
60
|
return match?.[1] || "";
|
|
61
61
|
}
|
|
62
|
+
function extractEnterpriseIdFromRoles(roles) {
|
|
63
|
+
if (!roles || roles.length === 0)
|
|
64
|
+
return "";
|
|
65
|
+
for (const role of roles) {
|
|
66
|
+
const match = role.match(/group-admin:([A-Za-z0-9-]+)/);
|
|
67
|
+
if (match?.[1])
|
|
68
|
+
return match[1];
|
|
69
|
+
}
|
|
70
|
+
return "";
|
|
71
|
+
}
|
|
62
72
|
let warnedTenantId = false;
|
|
63
73
|
let warnedEnterpriseId = false;
|
|
64
74
|
let warnedUserId = false;
|
|
@@ -74,10 +84,12 @@ function resolveEnterpriseId(accessToken) {
|
|
|
74
84
|
if (CONFIG.enterpriseId)
|
|
75
85
|
return CONFIG.enterpriseId;
|
|
76
86
|
const payload = decodeJwtPayload(accessToken);
|
|
87
|
+
const roles = payload?.realm_access?.roles || payload?.resource_access?.account?.roles;
|
|
77
88
|
return (payload?.enterprise_id ||
|
|
78
89
|
payload?.enterpriseId ||
|
|
79
90
|
payload?.ent_id ||
|
|
80
91
|
payload?.entId ||
|
|
92
|
+
extractEnterpriseIdFromRoles(roles) ||
|
|
81
93
|
"");
|
|
82
94
|
}
|
|
83
95
|
function resolveUserId(accessToken) {
|