opencode-codebuddy-external-auth 1.0.19 → 1.0.20

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.
Files changed (2) hide show
  1. package/dist/plugin.js +12 -0
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -82,14 +82,26 @@ function resolveTenantId(accessToken) {
82
82
  extractTenantIdFromRoles(roles) ||
83
83
  extractTenantIdFromIss(payload?.iss));
84
84
  }
85
+ function extractEnterpriseIdFromRoles(roles) {
86
+ if (!roles || roles.length === 0)
87
+ return "";
88
+ for (const role of roles) {
89
+ const match = role.match(/group-admin:([A-Za-z0-9-]+)/);
90
+ if (match?.[1])
91
+ return match[1];
92
+ }
93
+ return "";
94
+ }
85
95
  function resolveEnterpriseId(accessToken) {
86
96
  if (CONFIG.enterpriseId)
87
97
  return CONFIG.enterpriseId;
88
98
  const payload = decodeJwtPayload(accessToken);
99
+ const roles = payload?.realm_access?.roles || payload?.resource_access?.account?.roles;
89
100
  return (payload?.enterprise_id ||
90
101
  payload?.enterpriseId ||
91
102
  payload?.ent_id ||
92
103
  payload?.entId ||
104
+ extractEnterpriseIdFromRoles(roles) ||
93
105
  "");
94
106
  }
95
107
  function resolveUserId(accessToken) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codebuddy-external-auth",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "OpenCode plugin for CodeBuddy External (IOA) authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",