From 864327b8365fe9790b9fdb7021069083966812f3 Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Wed, 28 May 2025 13:40:19 +0530 Subject: [PATCH] Skip verification of privileges on project accounts --- .../com/cloud/user/AccountManagerImpl.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java index cd07303a82d..2f64d04fc56 100644 --- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java +++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java @@ -1539,16 +1539,20 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M public void verifyCallerPrivilegeForUserOrAccountOperations(Account userAccount) { s_logger.debug(String.format("Verifying whether the caller has the correct privileges based on the user's role type and API permissions: %s", userAccount)); - checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, null); - checkCallerApiPermissionsForUserOrAccountOperations(userAccount); + if (!Account.Type.PROJECT.equals(userAccount.getType())) { + checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, null); + checkCallerApiPermissionsForUserOrAccountOperations(userAccount); + } } protected void verifyCallerPrivilegeForUserOrAccountOperations(User user) { s_logger.debug(String.format("Verifying whether the caller has the correct privileges based on the user's role type and API permissions: %s", user)); Account userAccount = getAccount(user.getAccountId()); - checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, user); - checkCallerApiPermissionsForUserOrAccountOperations(userAccount); + if (!Account.Type.PROJECT.equals(userAccount.getType())) { + checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, user); + checkCallerApiPermissionsForUserOrAccountOperations(userAccount); + } } protected void checkCallerRoleTypeAllowedForUserOrAccountOperations(Account userAccount, User user) { @@ -2626,10 +2630,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } } - if (!Account.Type.PROJECT.equals(accountType)) { - AccountVO newAccount = new AccountVO(accountName, domainId, networkDomain, accountType, roleId, uuid); - verifyCallerPrivilegeForUserOrAccountOperations(newAccount); - } + AccountVO newAccount = new AccountVO(accountName, domainId, networkDomain, accountType, roleId, uuid); + verifyCallerPrivilegeForUserOrAccountOperations(newAccount); // Create the account return Transaction.execute(new TransactionCallback() {