Skip to content

Allow project members to resolve their own project role - #14870

Merged
sureshanaparti merged 2 commits into
apache:4.22from
shapeblue:project-view-switching-fix
Nov 27, 2026
Merged

sureshanaparti merged 2 commits into
apache:4.22from
shapeblue:project-view-switching-fix

Conversation

@sureshanaparti

Copy link
Copy Markdown
Contributor

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

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  • Unit tests
  • Create project, create a project role with allow *, add a non-admin user with that role, switch to project view

How did you try to break this feature and the system with this change?

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.

🔵 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

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.34%. Comparing base (6489766) to head (f07dfb8).
⚠️ Report is 3 commits behind head on 4.22.

Files with missing lines Patch % Lines
.../apache/cloudstack/acl/ProjectRoleManagerImpl.java 76.92% 6 Missing ⚠️
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     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.43% <76.92%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20188

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

blueorangutan commented Nov 27, 2026 •

Copy link
Copy Markdown

[SF] Trillian test result (tid-17639)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52356 seconds
Marvin logs: [archive removed]
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

ProjectAccount projectAccount = checkProjectMembership(project);
if (projectAccount != null && ProjectAccount.Role.Admin != projectAccount.getAccountRole()) {
throw new PermissionDeniedException("User unauthorized to perform operation in the project");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add javadoc to checkAccess, or rename it ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vladimirpetrov vladimirpetrov 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.

LGTM based on testing with the following objects:

  • A project.
  • Project roles: allow *, and listZones deny followed 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.

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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 weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code lgtm

thanks @sureshanaparti for the update

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20210

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@sureshanaparti
sureshanaparti merged commit 0d8a9b6 into apache:4.22 Nov 27, 2026
25 of 26 checks passed
@sureshanaparti
sureshanaparti deleted the project-view-switching-fix branch November 27, 2026 18:21
@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17647)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 53068 seconds
Marvin logs: not retained - PR was already closed when the run finished
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switching to project view not working when user is assigned custom Project Role

5 participants