Spaceman1984 commented on a change in pull request #4717:
URL: https://github.com/apache/cloudstack/pull/4717#discussion_r584491107
##########
File path: server/src/main/java/com/cloud/usage/UsageServiceImpl.java
##########
@@ -210,12 +212,45 @@ public boolean
generateUsageRecords(GenerateUsageRecordsCmd cmd) {
//If account_id or account_name is explicitly mentioned, list
records for the specified account only even if the caller is of type admin
if (_accountService.isRootAdmin(caller.getId())) {
isAdmin = true;
- } else if (_accountService.isDomainAdmin(caller.getId())) {
- isDomainAdmin = true;
}
s_logger.debug("Account details not available. Using userContext
accountId: " + accountId);
}
+ // Check if a domain admin is allowed to access the requested domain id
+ if (isDomainAdmin) {
+ if (domainId != null) {
+ Account callerAccount =
_accountService.getAccount(caller.getId());
+ Domain domain = _domainDao.findById(domainId);
+ _accountService.checkAccess(callerAccount, domain);
+ } else {
+ // Domain admins can only access their own domain's usage
records.
+ // Set the domain if not specified.
+ domainId = caller.getDomainId();
+ }
+
+ // Check if a domain admin is allowed to access the requested
account info.
+ Account account = _accountService.getAccount(accountId);
+ Domain domain = _domainDao.findById(caller.getDomainId());
+ _accountService.checkAccess(account, domain);
Review comment:
This is checking if the requested account exists in the same domain and
sub domains as the caller. I don't see anything wrong here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]