use of com.sequenceiq.authorization.annotation.CustomPermissionCheck in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getResourceGroups.
@Override
@CustomPermissionCheck
public PlatformResourceGroupsResponse getResourceGroups(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone) {
customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
String accountId = getAccountId();
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone, CdpResourceType.DEFAULT);
LOGGER.info("Get /platform_resources/resource_groups, request: {}", request);
CloudResourceGroups resourceGroups = platformParameterService.getResourceGroups(request);
List<PlatformResourceGroupResponse> platformResourceGroups = resourceGroups.getResourceGroups().stream().map(rg -> new PlatformResourceGroupResponse(rg.getName())).collect(Collectors.toList());
PlatformResourceGroupsResponse response = new PlatformResourceGroupsResponse(platformResourceGroups);
LOGGER.info("Resp /platform_resources/resource_groups, request: {}, resourceGroups: {}, response: {}", request, resourceGroups, response);
return response;
}
use of com.sequenceiq.authorization.annotation.CustomPermissionCheck in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getSecurityGroups.
@Override
@CustomPermissionCheck
public PlatformSecurityGroupsResponse getSecurityGroups(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, String sharedProjectId) {
customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
String accountId = getAccountId();
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone, sharedProjectId);
LOGGER.info("Get /platform_resources/security_groups, request: {}", request);
CloudSecurityGroups securityGroups = platformParameterService.getSecurityGroups(request);
PlatformSecurityGroupsResponse response = cloudSecurityGroupsToPlatformSecurityGroupsV1ResponseConverter.convert(securityGroups);
LOGGER.info("Resp /platform_resources/security_groups, request: {}, securityGroups: {}, response: {}", request, securityGroups, response);
return response;
}
use of com.sequenceiq.authorization.annotation.CustomPermissionCheck in project cloudbreak by hortonworks.
the class UserV1Controller method synchronizeAllUsers.
@Override
@AccountIdNotNeeded
@CustomPermissionCheck
public SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request) {
String userCrn = checkActorCrn();
String accountId = determineAccountId(userCrn, request.getAccountId());
LOGGER.debug("synchronizeAllUsers() requested for account {}", accountId);
UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(nullToEmpty(request.getUsers()), nullToEmpty(request.getMachineUsers()), getOptionalDeletedWorkloadUser(request.getDeletedWorkloadUsers()));
Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, nullToEmpty(request.getEnvironments()), userSyncFilter, request.getWorkloadCredentialsUpdateType(), AuthorizationResourceAction.DESCRIBE_ENVIRONMENT);
return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation));
}
use of com.sequenceiq.authorization.annotation.CustomPermissionCheck in project cloudbreak by hortonworks.
the class UserV1Controller method synchronizeUser.
@Override
@CustomPermissionCheck
public SyncOperationStatus synchronizeUser(SynchronizeUserRequest request) {
String userCrn = checkActorCrn();
String accountId = ThreadBasedUserCrnProvider.getAccountId();
LOGGER.debug("synchronizeUser() requested for user {} in account {}", userCrn, accountId);
Set<String> environmentCrnFilter = request == null ? Set.of() : nullToEmpty(request.getEnvironments());
Set<String> userCrnFilter = Set.of();
Set<String> machineUserCrnFilter = Set.of();
Crn crn = Crn.safeFromString(userCrn);
switch(crn.getResourceType()) {
case USER:
userCrnFilter = Set.of(userCrn);
break;
case MACHINE_USER:
machineUserCrnFilter = Set.of(userCrn);
break;
default:
throw new BadRequestException(String.format("UserCrn %s is not of resoure type USER or MACHINE_USER", userCrn));
}
UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(userCrnFilter, machineUserCrnFilter, Optional.empty());
Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, environmentCrnFilter, userSyncFilter, WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT);
return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation));
}
use of com.sequenceiq.authorization.annotation.CustomPermissionCheck in project cloudbreak by hortonworks.
the class UserV1Controller method setPassword.
@Override
@CustomPermissionCheck
public SyncOperationStatus setPassword(SetPasswordRequest request) {
String userCrn = checkActorCrn();
String accountId = ThreadBasedUserCrnProvider.getAccountId();
LOGGER.debug("setPassword() requested for user {} in account {}", userCrn, accountId);
Operation setPasswordOperation = passwordService.setPasswordWithCustomPermissionCheck(accountId, userCrn, request.getPassword(), nullToEmpty(request.getEnvironments()), AuthorizationResourceAction.DESCRIBE_ENVIRONMENT);
return checkOperationRejected(operationToSyncOperationStatus.convert(setPasswordOperation));
}
Aggregations