Repository navigation
Allow project admin to update template/ISO permissions in projects - #14510
DaanHoogland wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #14510 +/- ##
============================================
+ Coverage 16.42% 16.47% +0.04%
- Complexity 13676 13724 +48
============================================
Files 5669 5670 +1
Lines 501634 501782 +148
Branches 60939 60968 +29
============================================
+ Hits 82416 82644 +228
+ Misses 409982 409864 -118
- Partials 9236 9274 +38
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:
|
…ed templates Only a CloudStack admin or the template's owner account can change the permissions (ispublic, isextractable, launch permissions) of a template. For a project-owned template the owner is the project account, so every project member was rejected, including the Project Admin who registered the template. A Project Admin of the project that owns the template now passes both ownership checks in updateTemplateOrIsoPermissions(). The role is looked up in the template's owning project, with the user-level project role taking precedence over the account-level one. Fixes apache#14174 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b7d3a8c to
378f745
Compare
|
@blueorangutan package |
|
@DaanHoogland 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. |
|
@prashanthr2 , this solves an issue you encountered. Can you test/ review it? |
|
Packaging result [SF]: ✔️ el8 ✔️ debian. SL-JID 19884 |
|
@RosiKyu , I monkey tested this as a user creating a project and a template in it. NOTA BENE: creating a template as root admin in the project will also allow the project admin (a normal user in this case) to edit the permissions of the template. Please consider this from a functional point of view. cc @prashanthr2 |
|
Following up on my NB above: I think this is the intended behaviour, not a side effect. A template registered into a project is owned by the project account, whoever uploaded it, root admin included. That is how other project resources work too (VMs, volumes, networks created in a project by an admin are managed by the project). The Project Admin is acting for the owner here, so letting them manage the template's permissions is consistent. To be explicit about scope: only members with the project Admin role get this. Regular project members are still refused, even though registration lets any member set @RosiKyu @prashanthr2 if you see a functional reason to treat admin-uploaded templates differently, please say so. |
Check the Project Admin role of the owning project only for callers that are neither a CloudStack admin nor the template owner, and fold the result into a single isOwner flag. Add tests that the owner and admin paths do not consult the project role, and update the isextractable parameter description, which still said root admin only. Tests ported from apache#14529 by HawkForge. Co-authored-by: HawkForge <75696486+HawkForge@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Description
Only a CloudStack admin or the template's owner account can change the permissions (
ispublic,isextractable, launch permissions) of a template or ISO. For a project-owned template the owner is the project account, which no real account can match. So every project member was rejected byupdateTemplateOrIsoPermissions(), including the Project Admin who registered the template.With this PR, a Project Admin of the project that owns the template passes both ownership checks: the general permission check and the
isextractablecheck. The newisAdminOfOwningProject()looks up the project from the template's owner account and checks the caller's role in that project. A user-level project role, if present, takes precedence over the account-level role. Regular project members are still rejected, as before.Scope: only members with the project Admin role act as owner. Regular project members are still refused, even though registration lets any member set
ispublic/isextractable; the stricter rule on update is intentional. The project role is only looked up when the caller is neither a CloudStack admin nor the owner. Theisextractableparameter description is updated to match.Scope: only members with the project Admin role act as owner. Regular project members are still refused, even though registration lets any member set
ispublic/isextractable; the stricter rule on update is intentional. The project role is only looked up when the caller is neither a CloudStack admin nor the owner. Theisextractableparameter description is updated to match.Fixes: #14174
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests in
TemplateManagerImplTest:testUpdateTemplatePermissionsAllowsProjectAdminToActAsOwner: fails with the old code (InvalidParameterValueException) and passes with the fix.testUpdateTemplatePermissionsRejectsProjectMemberThatIsNotProjectAdmin: a regular project member is still rejected.testUpdateTemplatePermissionsOwnerDoesNotConsultProjectRole/testUpdateTemplatePermissionsAdminDoesNotConsultProjectRole: owner and admin callers never look up the project role (ported from server: allow project admins to update permissions of project templates #14529, thanks @HawkForge).isAdminOfOwningProjectTest*: covers a non-project owner, a missing project, and a user-level project role taking precedence over the account-level role.testUpdateTemplatePermissionsOwnerDoesNotConsultProjectRole/testUpdateTemplatePermissionsAdminDoesNotConsultProjectRole: owner and admin callers never look up the project role (ported from server: allow project admins to update permissions of project templates #14529, thanks @HawkForge).manually tested by having admin upload a template in a project owned by user. user could change permission settings.
(partly 🤖 Generated with Claude Code)