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

add permission check to role management #894

Merged
merged 1 commit into from
Nov 18, 2020

Conversation

C0rby
Copy link
Contributor

@C0rby C0rby commented Nov 18, 2020

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

@C0rby C0rby requested review from butonic and kulmann November 18, 2020 15:21
@C0rby C0rby self-assigned this Nov 18, 2020
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")
Copy link
Contributor

Choose a reason for hiding this comment

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

should return merrors.Forbidden

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

should return merrors.Forbidden

@C0rby C0rby force-pushed the check-role-management-permissions branch from dec4657 to 2f69265 Compare November 18, 2020 15:31
Copy link
Contributor

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

Nice! 🚀

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@C0rby C0rby merged commit f51890c into master Nov 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the check-role-management-permissions branch November 18, 2020 16:34
ownclouders pushed a commit that referenced this pull request Nov 18, 2020
Merge: 731e2f7 2f69265
Author: David Christofas <C0rby@users.noreply.github.com>
Date:   Wed Nov 18 17:34:00 2020 +0100

    Merge pull request #894 from owncloud/check-role-management-permissions

    add permission check to role management
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[QA] unprivileged users can promote themselves to admin
2 participants