Skip to content

Let only administrators give or take the Administrators role and set an administrator's password - #1109

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/only-admins-manage-admins
Nov 23, 2026
Merged

KrzysztofPajak merged 1 commit into
developfrom
fix/only-admins-manage-admins

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Staff with the Customers permission could take control of an administrator's account:

  • In the admin panel the customer validator refused to give the Administrators role to someone else, but not to take it away. Once the role was gone, the same staff member could edit the account, its password included.
  • In the API (/api/Customer) nothing checked the role: a customer could be created or updated with the Administrators group, an administrator's account could be changed, and SetPassword set any administrator's password.

Changes

  • Admin panel CustomerValidator (edit): taking the Administrators role away from an administrator fails unless the editor is an administrator. Giving the role was already refused.
  • API CustomerValidator: unless the caller is an administrator, a customer cannot be saved with the Administrators group, and an existing administrator cannot be changed.
  • API 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 through ChangePassword(customer, ...), so the account checked is the account changed.

Notes

  • Deleting an administrator through the API is not changed here.

Tests

  • CustomerValidatorTests (panel): role removed by a non-administrator is refused, by an administrator allowed, other customers unaffected.
  • CustomerValidatorAdministratorsTests (API, new) and CustomerControllerSetPasswordTests (API, new).
  • Grand.Web.Admin.Tests (2112), Grand.Module.Api.Tests (118) pass.

…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.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 06:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@KrzysztofPajak
KrzysztofPajak merged commit 5d71e7b into develop Nov 23, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/only-admins-manage-admins branch November 23, 2026 17:09
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.

2 participants