Repository navigation
fix: correct role reference for EXTENDS_ADMIN in workspace permissions - #7726
Merged
Merged
Conversation
shaohuzhang1
commented
Nov 6, 2026
| RoleConstants.EXTENDS_ADMIN, | ||
| RoleConstants.EXTENDS_WORKSPACE_MANAGE.get_workspace_role(), | ||
| RoleConstants.USER.get_workspace_role(), | ||
| RoleConstants.EXTENDS_USER.get_workspace_role(), |
Contributor
Author
There was a problem hiding this comment.
The diff is a small permission-decorator change:
- RoleConstants.EXTENDS_ADMIN.get_workspace_role(),
+ RoleConstants.EXTENDS_ADMIN,Assessment
- No syntax issue is visible in the diff.
- Correctness cannot be fully confirmed without seeing
RoleConstantsandhas_permissions(...). - The main risk is whether
has_permissionsexpects a workspace-scoped role or a global/base role.
Potential issues
-
Inconsistent role normalization
- Most entries call
.get_workspace_role(), butRoleConstants.ADMINand nowRoleConstants.EXTENDS_ADMINdo not. - If
EXTENDS_ADMINhas aget_workspace_role()method, this change may accidentally pass the wrong role representation and cause:- permission denial, or
- worse, unintended permission grant if the decorator compares loosely.
- If
EXTENDS_ADMINis already a workspace-level/global role and has no such method, the change is likely correct.
- Most entries call
-
Possible security impact
- This is authorization code. A wrong role constant can silently grant or revoke access.
- Verify that the raw
RoleConstants.EXTENDS_ADMINvalue matches the value stored/expected byhas_permissions.
-
Consistency with
ADMINRoleConstants.ADMINis already passed raw. If that is intentional because admins are global, thenEXTENDS_ADMINbeing raw may also be intentional.- If not, both should likely be normalized the same way as the other roles.
Recommendations
- Confirm the contract of
has_permissions: does it accept global roles, workspace roles, or both? - Check whether
RoleConstants.EXTENDS_ADMINhasget_workspace_role():- If yes, prefer calling it for consistency unless there is a documented reason not to.
- If no, the change is likely a bug fix.
- Add a short comment explaining why
ADMINandEXTENDS_ADMINare passed differently, if intentional.
Suggested refactor
Centralize the allowed roles to avoid forgetting or misusing .get_workspace_role():
WORKSPACE_USER_MEMBER_ROLES = (
RoleConstants.WORKSPACE_MANAGE.get_workspace_role(),
RoleConstants.ADMIN,
RoleConstants.EXTENDS_ADMIN,
RoleConstants.EXTENDS_WORKSPACE_MANAGE.get_workspace_role(),
RoleConstants.USER.get_workspace_role(),
RoleConstants.EXTENDS_USER.get_workspace_role(),
)Then:
@has_permissions(*WORKSPACE_USER_MEMBER_ROLES)This improves readability, consistency, and testability.
Tests to add
Add permission-matrix tests covering:
ADMINEXTENDS_ADMINWORKSPACE_MANAGEEXTENDS_WORKSPACE_MANAGEUSEREXTENDS_USER
Verify that each role gets the expected allow/deny result, especially around EXTENDS_ADMIN.
Verdict: The change may be correct if EXTENDS_ADMIN is already the value expected by has_permissions. Otherwise, it introduces a permission-matching bug. Verify the RoleConstants definition and add a regression test for EXTENDS_ADMIN.
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.
fix: correct role reference for EXTENDS_ADMIN in workspace permissions