Repository navigation
Allow project members to resolve their own project role - #14870
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Human validation is needed because the change alters project-role authorization at a security boundary, including domain-hierarchy isolation, lookup-versus-mutation access, and end-to-end API-checker behavior.
No open issues 🎉
What changed in this PR
This PR fixes project-view access for members assigned custom project roles by separating read-only role resolution from admin-only role mutations.
Changes:
- Adds membership-based authorization for project role and permission lookups.
- Retains administrator and dynamic-checker restrictions for mutating operations.
- Adds regression coverage for project membership, account-level membership, domain boundaries, and dynamic-checker behavior.
| File | Description |
|---|---|
| server/src/test/java/org/apache/cloudstack/acl/ProjectRoleManagerImplTest.java | Adds regression tests covering member role resolution, account-level membership, authorization boundaries, and mutation restrictions. |
| server/src/main/java/org/apache/cloudstack/acl/ProjectRoleManagerImpl.java | Separates read authorization from mutation authorization and permits authorized project members to resolve project roles and permissions. |
Review effort: Lite
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14870 +/- ##
=========================================
Coverage 18.34% 18.34%
- Complexity 16669 16671 +2
=========================================
Files 5939 5939
Lines 537819 537817 -2
Branches 65941 65938 -3
=========================================
+ Hits 98638 98640 +2
+ Misses 427960 427954 -6
- Partials 11221 11223 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20188 |
|
@blueorangutan test |
|
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-17639)
|
| ProjectAccount projectAccount = checkProjectMembership(project); | ||
| if (projectAccount != null && ProjectAccount.Role.Admin != projectAccount.getAccountRole()) { | ||
| throw new PermissionDeniedException("User unauthorized to perform operation in the project"); | ||
| } |
There was a problem hiding this comment.
can you add javadoc to checkAccess, or rename it ?
vladimirpetrov
left a comment
There was a problem hiding this comment.
LGTM based on testing with the following objects:
- A project.
- Project roles:
allow *, andlistZones denyfollowed by* allow. - Members:
- user-level Regular with a role
- user-level Regular without a role
- account-level Regular with a role
- Admin with a role
- Domain admins: one in the project's domain, one in another domain.
- A non-member.
|
@blueorangutan package |
|
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
weizhouapache
left a comment
There was a problem hiding this comment.
code lgtm
thanks @sureshanaparti for the update
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20210 |
|
@blueorangutan test |
|
@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-17647)
|
Description
This PR allows project members to resolve their own project role.
Earlier hardening that confined domain admins to their own domain hierarchy also added checkAccess() to the project role lookup methods. That guard requires the caller to be a project Admin, but the API access checkers (ProjectRoleBasedApiAccessChecker, DomainChecker) call findProjectRole / findAllProjectRolePermissions on every request made in project context to resolve the caller's own role. A member assigned any custom project role was therefore denied before the role's permission rules were evaluated, and ApiServer surfaced it as "The given command
either does not exist, is not available for user", with nothing logged.
Keep the admin-only guard for the mutating methods and give the lookups a membership guard: root admin, domain admin within the project's domain hierarchy, or any member of the project. Non-members stay denied. The
read guard does not depend on dynamic.apichecker.enabled, because DomainChecker resolves roles regardless of that setting.
Fixes #14014
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
allow *, add a non-admin user with that role, switch to project viewHow did you try to break this feature and the system with this change?