Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OIDC role assigner #6605

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-oidc-role-assigner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix the oidc role assigner

The update role method did not allow to set a role when the user already has two roles.
This makes no sense as the user is supposed to have only one and the update will fix that.
We still log an error level log to make the admin aware of that.

https://github.com/owncloud/ocis/pull/6605
4 changes: 1 addition & 3 deletions services/proxy/pkg/userroles/oidcroles.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ func (ra oidcRoleAssigner) UpdateUserRoleAssignment(ctx context.Context, user *c
return nil, err
}
if len(assignedRoles) > 1 {
err := errors.New("too many roles assigned")
logger.Error().Err(err).Msg("The user has too many roles assigned")
return nil, err
logger.Error().Str("userID", user.GetId().GetOpaqueId()).Int("numRoles", len(assignedRoles)).Msg("The user has too many roles assigned")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kobergj I know I am a bit late to the party, but I fear this is not enough. We need to make sure that the assignment is re-written when len(assignedRoles) > 1. Otherwise other code reading the assigments might get confused.

It should be enough to turn the if len(assignedRoles) == 0 || (assignedRoles[0] != roleIDFromClaim) on line 96 into if len(assignedRoles) != 1 || (assignedRoles[0] != roleIDFromClaim) for that to happen.

}
logger.Debug().Interface("assignedRoleIds", assignedRoles).Msg("Currently assigned roles")

Expand Down