DaanHoogland commented on a change in pull request #5854:
URL: https://github.com/apache/cloudstack/pull/5854#discussion_r784815472
##########
File path:
plugins/acl/static-role-based/src/main/java/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
##########
@@ -80,10 +80,16 @@ public boolean checkAccess(User user, String commandName)
throws PermissionDenie
throw new PermissionDeniedException("The account id=" +
user.getAccountId() + "for user id=" + user.getId() + "is null");
}
- RoleType roleType = accountService.getRoleType(account);
+ final Role accountRole = roleService.findRole(account.getRoleId());
+ return checkAccessWithoutEnabledCheck(account, user, commandName,
accountRole);
+ }
+
+ @Override
+ public boolean checkAccessWithoutEnabledCheck(Account account, User user,
String commandName, Role accountRole) throws PermissionDeniedException {
+ RoleType roleType = accountRole.getRoleType();
boolean isAllowed =
- commandsPropertiesOverrides.contains(commandName) ?
commandsPropertiesRoleBasedApisMap.get(roleType).contains(commandName) :
annotationRoleBasedApisMap.get(
- roleType).contains(commandName);
+ commandsPropertiesOverrides.contains(commandName) ?
commandsPropertiesRoleBasedApisMap.get(roleType).contains(commandName) :
annotationRoleBasedApisMap.get(
+ roleType).contains(commandName);
Review comment:
Are these extra indentation on purpose?
##########
File path:
plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java
##########
@@ -139,24 +139,33 @@ public boolean resetApiLimit(Long accountId) {
return true;
}
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
@Override
public boolean checkAccess(User user, String apiCommandName) throws
PermissionDeniedException {
// check if api rate limiting is enabled or not
if (!enabled) {
return true;
}
- Long accountId = user.getAccountId();
- Account account = _accountService.getAccount(accountId);
+ Account account = _accountService.getAccount(user.getAccountId());
+ return checkAccessWithoutEnabledCheck(account, user, apiCommandName,
null);
+ }
+
+ @Override
+ public boolean checkAccessWithoutEnabledCheck(Account account, User user,
String apiCommandName, Role role) throws PermissionDeniedException {
Review comment:
i'd say, pass accountId instead of account and leave the accountName out
of the trace message.
##########
File path:
plugins/api/discovery/src/test/java/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
##########
@@ -16,10 +16,27 @@
// under the License.
package org.apache.cloudstack.discovery;
-import com.cloud.user.User;
-import com.cloud.user.UserVO;
-import com.cloud.utils.component.PluggableService;
+import static org.junit.Assert.assertEquals;
Review comment:
can you undo the import reorganisation, please?
--
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]