Skip to content

server: simplify role change validation - #9173

Merged
DaanHoogland merged 9 commits into
apache:4.19from
shapeblue:simplify-role-change-check
Dec 14, 2024
Merged

server: simplify role change validation#9173
DaanHoogland merged 9 commits into
apache:4.19from
shapeblue:simplify-role-change-check

Conversation

@shwstppr

@shwstpprshwstppr commented Jun 5, 2024

Copy link
Copy Markdown
Contributor

Description

Fixes#9015

Simplifies role change checks with the following conditions:

  • Caller should not be of Unknown role type
  • New role's type should not be Unknown
  • Caller should not be able to escalate or de-escalate an account's role which is of higher role type
  • New role should not be of type Admin with domain other than ROOT domain

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

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?

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

Fixesapache#9015
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@codecov

codecovBot commented Jun 5, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 15.12%. Comparing base (ef1a58d) to head (690188c).
Report is 10 commits behind head on 4.19.

Files with missing linesPatch %Lines
...c/main/java/com/cloud/user/AccountManagerImpl.java80.00%1 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## 4.19 #9173 +/- ##
=========================================
Coverage 15.12% 15.12% - Complexity 11255 11261 +6 
=========================================
Files 5408 5408 Lines 473838 473844 +6 Branches 57770 57774 +4 =========================================
+ Hits 71676 71687 +11 + Misses 394165 394157 -8 - Partials 7997 8000 +3 
FlagCoverage Δ
uitests4.30% <ø> (ø)
unittests15.84% <80.00%> (+<0.01%)⬆️

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

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

@blueorangutan

Copy link
Copy Markdown

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

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 9789

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9790

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

clgtm, good cleanup

Comment threadserver/src/main/java/com/cloud/user/AccountManagerImpl.java Outdated
Co-authored-by: dahn <daan.hoogland@gmail.com>
Comment threadserver/src/main/java/com/cloud/user/AccountManagerImpl.java Outdated
@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-10374)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42525 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9173-t10374-kvm-centos7.zip
Smoke tests completed. 125 look OK, 6 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_DeployVmAntiAffinityGroup_in_projectError85.90test_affinity_groups_projects.py
test_DeployVmAntiAffinityGroupError35.64test_affinity_groups.py
test_03_deploy_and_scale_kubernetes_clusterFailure26.74test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_clusterFailure0.06test_kubernetes_clusters.py
test_01_non_strict_host_anti_affinityFailure116.25test_nonstrict_affinity_group.py
test_02_non_strict_host_affinityError82.31test_nonstrict_affinity_group.py
test_02_trigger_shutdownFailure346.80test_safe_shutdown.py
test_hostha_enable_ha_when_host_in_maintenanceError302.83test_hostha_kvm.py

@yadvryadvr added this to the 4.19.1.0 milestone Jun 10, 2024

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

LGTM - didn't test it though

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@DaanHoogland@rohityadavcloud
Thanks for the review but I'm not sure if we agree on the behaviour which is why this is still in draft. I will try to summarise impact of this change

  • ROOT admin can promote or demote all roles except when it tries to make a domain-admin from a subdomain to admin there will be an error
  • Domain-admins (if allowed based on API permission) can promote or demote an account to roles lower than domain-admin level. They won't be able to make a normal user account into domain-admin or vice-versa.
  • Normal user accounts (if allowed based on API permission) can promote or demote an account to roles lower than normal account level (probably none).

@DaanHoogland

Copy link
Copy Markdown
Contributor

Thanks @shwstppr

  • Domain-admins (if allowed based on API permission) can promote or demote an account to roles lower than domain-admin level. They won't be able to make a normal user account into domain-admin or vice-versa.

I would expect a Domain Admin to promote a user up to their own level.

  • Normal user accounts (if allowed based on API permission) can promote or demote an account to roles lower than normal account level (probably none).

well, that mean they can make other users read only. I am not sure if this is desired.

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

I would expect a Domain Admin to promote a user up to their own level.

I feel this shouldn't be allowed. It should be done by account with higher privileges, ROOT admin here. We can change if others agree on the same.

well, that mean they can make other users read only. I am not sure if this is desired.

No, they won't be able to. Check is based on the RoleType (https://github.com/apache/cloudstack/blob/4.19/api/src/main/java/org/apache/cloudstack/acl/RoleType.java#L30-L34). So, they won't be able to do anything even if API allows unless we add a new RoleType in the code.

@DaanHooglandDaanHoogland modified the milestones: 4.19.1.0, 4.19.2Jun 18, 2024
@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10430

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-11512)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 46532 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9173-t11512-kvm-ol8.zip
Smoke tests completed. 133 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@shwstppr , do we still have functional doubts on the current state of the code? (or can we postpone further discussion to a next issue/PR)

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@DaanHoogland I think this is okay from my side but will need some testing.

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@DaanHoogland
DaanHoogland marked this pull request as ready for review December 4, 2024 07:39
@DaanHoogland

Copy link
Copy Markdown
Contributor

thanks @shwstppr , on the list ;)

@blueorangutan

Copy link
Copy Markdown

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

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test keepEnv

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-11844)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 52403 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9173-t11844-kvm-ol8.zip
Smoke tests completed. 133 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

tested with a user-, user+, domadmin- and domadmin+ role to see wich was possible.
I gave the domadmin roles updateRole and updateRolePermissions to try and edit roles betond their priviledges.
the - accounts had no activateProject permission
and the + account had createAccount
the domadmin- could not assign a + role to a user
no rootadmin could be assigned in a child domain.

@DaanHoogland
DaanHoogland merged commit 8639ba8 into apache:4.19Dec 14, 2024
@DaanHoogland
DaanHoogland deleted the simplify-role-change-check branch December 14, 2024 19:26
DaanHoogland added a commit that referenced this pull request Dec 20, 2024
* 4.20:
VR: apply iptables rules when add/remove static routes (#10064)
Certificate and VM hostname validation improvements (#10051)
set ulimit for server according to redhat spec (#10040)
kvm-storage: provide isVMMigrate information to storage plugins (#10093)
Allow config drive deletion of migrated VM, on host maintenance (#10045)
linstor: improve heartbeat check with also asking linstor (#10105)
server: simplify role change validation (#9173)
UI: create VPC network offering with conserve mode (#10082)
server: fix typo removeaccessvpn in VirtualRouterElement (#10086)
UI: remove duplicated Instance Name in Public IP details page (#10087)
UI: Fixes in the Usage UI (#10000)
SAML2: add cookie with HttpOnly too #10013 (#10047)
ui: Allow font-awesome icon usage and optimise icon size inconsistency (#9744)
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Dec 26, 2024
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Co-authored-by: dahn <daan.hoogland@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Abhishek's Bugfix List

Development

Successfully merging this pull request may close these issues.

admin should be allowed to elevate user from role User to Domain Admin

5 participants

@shwstppr@blueorangutan@DaanHoogland@yadvr@borisstoyanov