use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationSecurityController method grantAccessToUsers.
/**
*****************************************************************************************************************************
*
* SECURITY ON USERS
*
******************************************************************************************************************************
*/
/**
* Grant access to the location to the user (deploy on the location)
*
* @param locationId The location's id.
* @param userNames The authorized users.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Grant access to the location to the users, send back the new authorised users list", notes = "Only user with ADMIN role can grant access to another users.")
@RequestMapping(value = "/users", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public synchronized RestResponse<List<UserDTO>> grantAccessToUsers(@PathVariable String orchestratorId, @PathVariable String locationId, @RequestBody String[] userNames) {
Location location = locationService.getLocation(orchestratorId, locationId);
resourcePermissionService.grantPermission(location, Subject.USER, userNames);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(location));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationSecurityController method getAuthorizedGroups.
/**
* List all groups authorised to access the location.
*
* @return list of all authorised groups.
*/
@ApiOperation(value = "List all groups authorized to access the location", notes = "Only user with ADMIN role can list authorized groups to the location.")
@RequestMapping(value = "/groups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<List<GroupDTO>> getAuthorizedGroups(@PathVariable String orchestratorId, @PathVariable String locationId) {
Location location = locationService.getLocation(orchestratorId, locationId);
List<GroupDTO> groups = GroupDTO.convert(resourcePermissionService.getAuthorizedGroups(location));
return RestResponseBuilder.<List<GroupDTO>>builder().data(groups).build();
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationSecurityController method updateAuthorizedEnvironmentsAndEnvTypesPerApplication.
/**
* Update applications,environments and environment types authorized to access the location.
*/
@ApiOperation(value = "Update applications,environments and environment types authorized to access the location", notes = "Only user with ADMIN role can update authorized applications,environments and environment types for the location.")
@RequestMapping(value = "/environmentsPerApplication", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public synchronized RestResponse<Void> updateAuthorizedEnvironmentsAndEnvTypesPerApplication(@PathVariable String orchestratorId, @PathVariable String locationId, @RequestBody ApplicationEnvironmentAuthorizationUpdateRequest request) {
Location location = locationService.getLocation(orchestratorId, locationId);
resourcePermissionService.revokeAuthorizedEnvironmentsAndEnvironmentTypesPerApplication(location, request.getApplicationsToDelete(), request.getEnvironmentsToDelete(), request.getEnvironmentTypesToDelete());
resourcePermissionService.grantAuthorizedEnvironmentsAndEnvTypesPerApplication(location, request.getApplicationsToAdd(), request.getEnvironmentsToAdd(), request.getEnvironmentTypesToAdd());
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationController method getAll.
@ApiOperation(value = "Get all locations for a given orchestrator.")
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<List<LocationDTO>> getAll(@ApiParam(value = "Id of the orchestrator for which to get all locations.") @PathVariable String orchestratorId) {
List<Location> locations = locationService.getAll(orchestratorId);
List<LocationDTO> locationDTOs = Lists.newArrayList();
for (Location location : locations) {
locationDTOs.add(buildLocationDTO(location));
}
return RestResponseBuilder.<List<LocationDTO>>builder().data(locationDTOs).build();
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationController method setSecretConfiguration.
@ApiOperation(value = "Set the secret configuration for the given location.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}/secret-conf", method = RequestMethod.POST)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public RestResponse<Void> setSecretConfiguration(@ApiParam(value = "Id of the orchestrator for which the location is defined.") @PathVariable String orchestratorId, @ApiParam(value = "Id of the location to update", required = true) @PathVariable String id, @RequestBody SecretProviderConfiguration secretProviderConfiguration) {
Location location = locationService.getOrFail(id);
secretProviderService.validateConfiguration(secretProviderConfiguration.getPluginName(), secretProviderConfiguration.getConfiguration());
location.setSecretProviderConfiguration(secretProviderConfiguration);
locationService.save(location);
return RestResponseBuilder.<Void>builder().build();
}
Aggregations