Repository navigation
Let only administrators give or take the Administrators role and set an administrator's password - #1109
Merged
Conversation
…an administrator's password Staff with the Customers permission could not give the Administrators role in the admin panel, but they could take it away from an administrator and then change that account, password included. In the API they could give the role, change an administrator and set any administrator's password. The admin panel now refuses to take the role away unless the editor is an administrator. In the API, a customer is created or updated with the Administrators role, or an administrator is changed, only by an administrator, and SetPassword answers 403 for an administrator's account unless the caller is one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Staff with the Customers permission could take control of an administrator's account:
/api/Customer) nothing checked the role: a customer could be created or updated with the Administrators group, an administrator's account could be changed, andSetPasswordset any administrator's password.Changes
CustomerValidator(edit): taking the Administrators role away from an administrator fails unless the editor is an administrator. Giving the role was already refused.CustomerValidator: unless the caller is an administrator, a customer cannot be saved with the Administrators group, and an existing administrator cannot be changed.CustomerController.SetPassword: resolves the account first (404 when it does not exist) and answers 403 for an administrator's account unless the caller is an administrator. The password is changed throughChangePassword(customer, ...), so the account checked is the account changed.Notes
Tests
CustomerValidatorTests(panel): role removed by a non-administrator is refused, by an administrator allowed, other customers unaffected.CustomerValidatorAdministratorsTests(API, new) andCustomerControllerSetPasswordTests(API, new).Grand.Web.Admin.Tests(2112),Grand.Module.Api.Tests(118) pass.