Skip to content

Commit 5b33967

Browse files
hsato03Henrique Sato
andauthored
Fix role escalation prevention (#7853)
Co-authored-by: Henrique Sato <henrique.sato@scclouds.com.br>
1 parent 87d6c4f commit 5b33967

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

plugins/acl/static-role-based/src/main/java/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ public boolean isEnabled() {
7676
if (roleService.isEnabled()) {
7777
LOGGER.debug("RoleService is enabled. We will use it instead of StaticRoleBasedAPIAccessChecker.");
7878
}
79-
return roleService.isEnabled();
79+
return !roleService.isEnabled();
8080
}
8181

8282
@Override
8383
public List<String> getApisAllowedToUser(Role role, User user, List<String> apiNames) throws PermissionDeniedException {
84-
if (isEnabled()) {
84+
if (!isEnabled()) {
8585
return apiNames;
8686
}
8787

@@ -93,7 +93,7 @@ public List<String> getApisAllowedToUser(Role role, User user, List<String> apiN
9393

9494
@Override
9595
public boolean checkAccess(User user, String commandName) throws PermissionDeniedException {
96-
if (isEnabled()) {
96+
if (!isEnabled()) {
9797
return true;
9898
}
9999

@@ -107,6 +107,10 @@ public boolean checkAccess(User user, String commandName) throws PermissionDenie
107107

108108
@Override
109109
public boolean checkAccess(Account account, String commandName) {
110+
if (!isEnabled()) {
111+
return true;
112+
}
113+
110114
RoleType roleType = accountService.getRoleType(account);
111115
if (isApiAllowed(commandName, roleType)) {
112116
return true;

0 commit comments

Comments
 (0)