fix: 1152 - vetters cannot reassign member roles - #1162
Draft
leahpeker wants to merge 4 commits into
Draft
Conversation
update_user_roles only checked MANAGE_USERS, so a vetter-tier role (member management without full admin) could reassign any role on an existing member, including the built-in admin role via the member detail screen. Gate the endpoint behind MANAGE_ROLES instead — the same permission that already gates the role editor. MANAGE_USERS still covers adding/managing members. Frontend: hide the editable role checklist on the member detail screen from users without manage_roles, showing their current roles read-only instead.
1 task
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.
Overview
Vetters (any role with
MANAGE_USERSbut not full admin) could reassign roles — including the built-in admin role — on any existing member via/admin/members/:id. The role-update endpoint (PATCH /api/auth/users/{id}/roles/) only checkedMANAGE_USERS, and the member detail screen rendered an unrestricted role checklist to anyone who could reach that page.Per Issue #1152: vetters should only be able to add members — any other role change should go through a full admin. So this gates role reassignment on
is_admin(holding the built-inadminrole), not a grantable permission —MANAGE_ROLESis itself assignable to a non-admin role, which would reopen the same escalation path.update_user_rolesinbackend/users/_management.pynow requires_is_admin(request.auth)instead ofPermissionKey.MANAGE_ROLES.isAdmin()tofrontend/src/models/permissions.ts(mirrors backend_is_admin);MemberRolesSectioninfrontend/src/screens/admin/MemberDetailScreen.tsxnow hides the editable role checkboxes from non-admins, showing the member's current roles read-only instead.Closes #1152
Test plan
backend/tests/users/test_users_admin_extended.py::TestUpdateUserRoles— aMANAGE_USERS-only user is denied (403); a non-admin role holdingMANAGE_ROLESis also denied; only the built-in admin succeedsfrontend/src/screens/admin/MemberDetailScreen.test.tsx— role checklist hidden for non-admins (with or withoutmanage_roles), shown for the built-in admin rolemake agent-lint(ruff) — cleanmake agent-typecheck(backendty) — cleanmake agent-frontend-typecheck(tsc) — cleanmake agent-frontend-lint(eslint) — clean