Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ› Fixes OIDC is admin lookup for gitlab (#2202)

Alicia Sykesdf63217120fa
diff --git a/services/auth-oidc.js b/services/auth-oidc.js
index 54783109..9dbc29b0 100644
--- a/services/auth-oidc.js
+++ b/services/auth-oidc.js
@@ -79,13 +79,13 @@ async function getIssuerContext(issuer) {
return ctx;
}
-/* Pure helper: true when the token's claims map to the configured admin group/role.
- Handles standard OIDC top-level `groups`/`roles` claims plus Keycloak's nested
- realm_access / resource_access role shapes (mirrors what KeycloakAuth.js does
- client-side). */
+/* Helper is true when the token's claims map to the configured admin group/role.
+ Handles standard OIDC top-level `groups`/`roles` claims, GitLab's `groups_direct`
+ plus Keycloak's nested realm_access / resource_access role shapes */
function deriveIsAdmin(claims, settings) {
if (!claims) return false;
const groups = Array.isArray(claims.groups) ? [...claims.groups] : [];
+ if (Array.isArray(claims.groups_direct)) groups.push(...claims.groups_direct);
const roles = Array.isArray(claims.roles) ? [...claims.roles] : [];
if (settings.kind === 'keycloak') {
diff --git a/src/utils/auth/OidcAuth.js b/src/utils/auth/OidcAuth.js
index 87e92fef..7a96554a 100644
--- a/src/utils/auth/OidcAuth.js
+++ b/src/utils/auth/OidcAuth.js
@@ -148,7 +148,11 @@ class OidcAuth {
/* Mirror the OIDC user into the localStorage keys other parts of Dashy read */
persistUserInfo(user) {
- const { roles = [], groups = [] } = user.profile;
+ const { roles = [] } = user.profile;
+ // GitLab puts groups in `groups_direct`, so merge both claim names
+ const groups = [...new Set(
+ [user.profile.groups, user.profile.groups_direct].filter(Array.isArray).flat(),
+ )];
const info = { groups, roles };
const isAdmin = (Array.isArray(groups) && groups.includes(this.adminGroup))
|| (Array.isArray(roles) && roles.includes(this.adminRole))