@@ -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