Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit e7b3c48

Browse files
committed
fix: don't throw error if group claim is missing
1 parent 0dfd4d0 commit e7b3c48

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

backend/src/oauth/provider/genericOidc.provider.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,38 +147,33 @@ export abstract class GenericOidcProvider implements OAuthProvider<OidcToken> {
147147

148148
if (roleConfig?.path) {
149149
// A path to read roles from the token is configured
150-
let roles: string[] | null;
150+
let roles: string[] = [];
151151
try {
152152
roles = jmespath.search(idTokenData, roleConfig.path);
153153
} catch (e) {
154-
roles = null;
155-
}
156-
if (Array.isArray(roles)) {
157-
// Roles are found in the token
158-
if (
159-
roleConfig.generalAccess &&
160-
!roles.includes(roleConfig.generalAccess)
161-
) {
162-
// Role for general access is configured and the user does not have it
163-
this.logger.error(
164-
`User roles ${roles} do not include ${roleConfig.generalAccess}`,
165-
);
166-
throw new ErrorPageException("user_not_allowed");
167-
}
168-
if (roleConfig.adminAccess) {
169-
// Role for admin access is configured
170-
isAdmin = roles.includes(roleConfig.adminAccess);
171-
}
172-
} else {
173-
this.logger.error(
154+
this.logger.warn(
174155
`Roles not found at path ${roleConfig.path} in ID Token ${JSON.stringify(
175156
idTokenData,
176157
undefined,
177158
2,
178159
)}`,
179160
);
161+
}
162+
163+
if (
164+
roleConfig.generalAccess &&
165+
!roles.includes(roleConfig.generalAccess)
166+
) {
167+
// Role for general access is configured and the user does not have it
168+
this.logger.error(
169+
`User roles ${roles} do not include ${roleConfig.generalAccess}`,
170+
);
180171
throw new ErrorPageException("user_not_allowed");
181172
}
173+
if (roleConfig.adminAccess) {
174+
// Role for admin access is configured
175+
isAdmin = roles.includes(roleConfig.adminAccess);
176+
}
182177
}
183178

184179
if (!username) {

0 commit comments

Comments
 (0)