Skip to content

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

Open
sureshanaparti wants to merge 1 commit into
apache:4.22from
shapeblue:project-view-switching-fix
Open

sureshanaparti wants to merge 1 commit 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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 4.08%. Comparing base (6489766) to head (a35e429).

❗ There is a different number of reports uploaded between BASE (6489766) and HEAD (a35e429). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (6489766) HEAD (a35e429)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               4.22   #14870       +/-   ##
=============================================
- Coverage     18.34%    4.08%   -14.26%     
=============================================
  Files          5939      449     -5490     
  Lines        537819    38282   -499537     
  Branches      65941     7083    -58858     
=============================================
- Hits          98638     1564    -97074     
+ Misses       427960    36503   -391457     
+ Partials      11221      215    -11006     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests ?

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.

This branch has not been deployed

No deployments
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

3 participants