Skip to content

Commit 4c17c82

Browse files
committed
Invalidate cache also on updateRolePermission, importRole and updateAccount APIs
1 parent c7667d8 commit 4c17c82

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎server/src/main/java/com/cloud/user/AccountManagerImpl.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,7 @@ public AccountVO updateAccount(UpdateAccountCmd cmd) {
23562356
validateRoleChange(account, role, caller);
23572357
acctForUpdate.setRoleId(roleId);
23582358
acctForUpdate.setType(role.getRoleType().getAccountType());
2359+
refreshRoleCheckersCacheOnPermissionsChange(role);
23592360
checkRoleEscalation(getCurrentCallingAccount(), acctForUpdate);
23602361
}
23612362

‎server/src/main/java/org/apache/cloudstack/acl/RoleManagerImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ public RoleVO doInTransaction(TransactionStatus status) {
262262
throw new CloudRuntimeException("Unable to import the role: " + name + ", failed to persist in DB");
263263
}
264264

265+
accountManager.refreshRoleCheckersCacheOnPermissionsChange(newRole);
266+
265267
if (rules != null && !rules.isEmpty()) {
266268
for (Map<String, Object> ruleDetail : rules) {
267269
Rule rule = (Rule)ruleDetail.get(ApiConstants.RULE);
@@ -410,6 +412,7 @@ public boolean updateRolePermission(final Role role, final List<RolePermission>
410412
if (role.isDefault()) {
411413
throw new PermissionDeniedException("Role permission cannot be updated for Default roles");
412414
}
415+
accountManager.refreshRoleCheckersCacheOnPermissionsChange(role);
413416
return role != null && newOrder != null && rolePermissionsDao.update(role, newOrder);
414417
}
415418

@@ -419,6 +422,7 @@ public boolean updateRolePermission(Role role, RolePermission rolePermission, Pe
419422
if (role.isDefault()) {
420423
throw new PermissionDeniedException("Role permission cannot be updated for Default roles");
421424
}
425+
accountManager.refreshRoleCheckersCacheOnPermissionsChange(role);
422426
return role != null && rolePermissionsDao.update(role, rolePermission, permission);
423427
}
424428

0 commit comments

Comments
 (0)