-
Notifications
You must be signed in to change notification settings - Fork 186
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
add permission check to role management #894
Conversation
settings/pkg/service/v0/service.go
Outdated
req.AccountUuid = getValidatedAccountUUID(c, req.AccountUuid) | ||
func (g Service) AssignRoleToUser(ctx context.Context, req *proto.AssignRoleToUserRequest, res *proto.AssignRoleToUserResponse) error { | ||
if !g.hasRoleManagementPermission(ctx) { | ||
return merrors.BadRequest(g.id, "the user is not allowed to assign roles") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return merrors.Forbidden
settings/pkg/service/v0/service.go
Outdated
func (g Service) RemoveRoleFromUser(c context.Context, req *proto.RemoveRoleFromUserRequest, _ *empty.Empty) error { | ||
func (g Service) RemoveRoleFromUser(ctx context.Context, req *proto.RemoveRoleFromUserRequest, _ *empty.Empty) error { | ||
if !g.hasRoleManagementPermission(ctx) { | ||
return merrors.BadRequest(g.id, "the user is not allowed to assign roles") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return merrors.Forbidden
dec4657
to
2f69265
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🚀
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
Enhancement: add permission check when assigning and removing roles
Everyone could add and remove roles from users.
Added a new permission and a check so that only users with the role management permissions can assign and unassign roles.
Fixes #879