fix(proxy): [OCISDEV-1464] log why the guest role mapping does not apply

mapGuestRole dropped the extractRoles error without a log line. When
PROXY_ROLE_ASSIGNMENT_OIDC_CLAIM had a wrong claim name, each guest kept
the guest role, and the admin could not find the cause.

mapGuestRole now writes a debug log line with the claim name and the
error. A guest without a roles claim is valid, and the role assigner runs
on each request, so the log level is debug and not warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roman PerekhodandClaude Opus 5.5 committed 2026-10-27 17:39:33 +01:00
1 parent 7b05512162
commit 3e312af456
1 file changed
+2
@@ -260,6 +260,8 @@ func GuestRoleMapping(cfg *config.Config) ([]config.RoleMapping, error) {
func (ra oidcRoleAssigner) mapGuestRole(claims map[string]interface{}, guestRole string, roleNamesToRoleIDs map[string]string) (string, error) {
claimRoles, err := extractRoles(ra.rolesClaim, claims)
if err != nil || len(claimRoles) == 0 {
// a guest without roles claim is valid, log at debug level to help find a wrong claim name
ra.logger.Debug().Err(err).Str("claim", ra.rolesClaim).Msg("no roles in claim, the guest keeps the guest role")
return guestRole, nil
}