fix: don't throw error if group claim is missing
This commit is contained in:
@@ -147,14 +147,19 @@ export abstract class GenericOidcProvider implements OAuthProvider<OidcToken> {
|
|||||||
|
|
||||||
if (roleConfig?.path) {
|
if (roleConfig?.path) {
|
||||||
// A path to read roles from the token is configured
|
// A path to read roles from the token is configured
|
||||||
let roles: string[] | null;
|
let roles: string[] = [];
|
||||||
try {
|
try {
|
||||||
roles = jmespath.search(idTokenData, roleConfig.path);
|
roles = jmespath.search(idTokenData, roleConfig.path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
roles = null;
|
this.logger.warn(
|
||||||
|
`Roles not found at path ${roleConfig.path} in ID Token ${JSON.stringify(
|
||||||
|
idTokenData,
|
||||||
|
undefined,
|
||||||
|
2,
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (Array.isArray(roles)) {
|
|
||||||
// Roles are found in the token
|
|
||||||
if (
|
if (
|
||||||
roleConfig.generalAccess &&
|
roleConfig.generalAccess &&
|
||||||
!roles.includes(roleConfig.generalAccess)
|
!roles.includes(roleConfig.generalAccess)
|
||||||
@@ -169,16 +174,6 @@ export abstract class GenericOidcProvider implements OAuthProvider<OidcToken> {
|
|||||||
// Role for admin access is configured
|
// Role for admin access is configured
|
||||||
isAdmin = roles.includes(roleConfig.adminAccess);
|
isAdmin = roles.includes(roleConfig.adminAccess);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.logger.error(
|
|
||||||
`Roles not found at path ${roleConfig.path} in ID Token ${JSON.stringify(
|
|
||||||
idTokenData,
|
|
||||||
undefined,
|
|
||||||
2,
|
|
||||||
)}`,
|
|
||||||
);
|
|
||||||
throw new ErrorPageException("user_not_allowed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
|
|||||||
Reference in New Issue
Block a user