Copilot commented on code in PR #13952:
URL: https://github.com/apache/cloudstack/pull/13952#discussion_r4754121576


##########
engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql:
##########
@@ -309,3 +309,25 @@ JOIN (
     GROUP BY object_store_id
 ) buckets_quota_sum_view ON `object_store`.id = 
buckets_quota_sum_view.object_store_id
 SET `object_store`.allocated_size = buckets_quota_sum_view.total_quota;
+
+-- @APICommand(authorized=...) alone doesn't grant access under dynamic RBAC 
(the default).
+-- Backfill the LDAP account APIs for any role that can already create 
accounts natively.
+INSERT INTO cloud.role_permissions (uuid, role_id, rule, permission, 
sort_order)
+SELECT uuid(), role_id, 'listLdapUsers', permission, sort_order
+FROM cloud.role_permissions rp
+WHERE rule = 'createAccount' AND NOT EXISTS(SELECT 1 FROM 
cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 
'listLdapUsers');
+
+INSERT INTO cloud.role_permissions (uuid, role_id, rule, permission, 
sort_order)
+SELECT uuid(), role_id, 'ldapCreateAccount', permission, sort_order
+FROM cloud.role_permissions rp
+WHERE rule = 'createAccount' AND NOT EXISTS(SELECT 1 FROM 
cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 
'ldapCreateAccount');
+
+INSERT INTO cloud.role_permissions (uuid, role_id, rule, permission, 
sort_order)
+SELECT uuid(), role_id, 'linkAccountToLdap', permission, sort_order
+FROM cloud.role_permissions rp
+WHERE rule = 'createAccount' AND NOT EXISTS(SELECT 1 FROM 
cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 
'linkAccountToLdap');

Review Comment:
   This backfill grants `linkAccountToLdap` to additional restricted roles, 
including the default Resource Admin role and custom domain-admin roles that 
allow `createAccount`. The linking service directly persists accounts and LDAP 
mappings without checking access to the target domain or restricting the 
requested role, allowing newly authorized callers to create privileged accounts 
or replace mappings outside their domain when LDAP is configured there. Omit 
this grant until domain-access and role-escalation checks are enforced in the 
linking service.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to