mirror of https://github.com/apache/cloudstack.git
Fix role escalation prevention (#7853)
Co-authored-by: Henrique Sato <henrique.sato@scclouds.com.br>
This commit is contained in:
parent
87d6c4fbd5
commit
5b33967310
|
|
@ -76,12 +76,12 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
|||
if (roleService.isEnabled()) {
|
||||
LOGGER.debug("RoleService is enabled. We will use it instead of StaticRoleBasedAPIAccessChecker.");
|
||||
}
|
||||
return roleService.isEnabled();
|
||||
return !roleService.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getApisAllowedToUser(Role role, User user, List<String> apiNames) throws PermissionDeniedException {
|
||||
if (isEnabled()) {
|
||||
if (!isEnabled()) {
|
||||
return apiNames;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
|||
|
||||
@Override
|
||||
public boolean checkAccess(User user, String commandName) throws PermissionDeniedException {
|
||||
if (isEnabled()) {
|
||||
if (!isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +107,10 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
|||
|
||||
@Override
|
||||
public boolean checkAccess(Account account, String commandName) {
|
||||
if (!isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RoleType roleType = accountService.getRoleType(account);
|
||||
if (isApiAllowed(commandName, roleType)) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue