use of alien4cloud.audit.annotation.Audit 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();
}
use of alien4cloud.audit.annotation.Audit in project alien4cloud by alien4cloud.
the class LocationController method deleteSecretConfiguration.
@ApiOperation(value = "Delete the secret configuration for the given location.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}/secret-conf", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public RestResponse<Void> deleteSecretConfiguration(@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) {
Location location = locationService.getOrFail(id);
location.setSecretProviderConfiguration(null);
locationService.save(location);
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.audit.annotation.Audit in project alien4cloud by alien4cloud.
the class LocationController method update.
@ApiOperation(value = "Update the name of an existing location.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public RestResponse<Void> update(@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, @ApiParam(value = "Location update request, representing the fields to updates and their new values.", required = true) @Valid @NotEmpty @RequestBody UpdateLocationRequest updateRequest) {
Location location = locationService.getOrFail(id);
String currentName = location.getName();
ReflectionUtil.mergeObject(updateRequest, location);
locationService.ensureNameUnicityAndSave(location, currentName);
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.audit.annotation.Audit in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesSecurityController method grantAccessToUsers.
/**
*****************************************************************************************************************************
*
* SECURITY ON USERS
*
******************************************************************************************************************************
*/
/**
* Grant access to the location resoure to the user (deploy on the location)
*
* @param locationId The location's id.
* @param resourceId The location resource's id.
* @param userNames The authorized users.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Grant access to the location's resource 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, @PathVariable String resourceId, @RequestBody String[] userNames) {
Location location = locationService.getLocation(orchestratorId, locationId);
locationSecurityService.grantAuthorizationOnLocationIfNecessary(location, Subject.USER, userNames);
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
// prefer using locationResourceService.saveResource so that the location update date is update.
// This will then trigger a deployment topology update
resourcePermissionService.grantPermission(resourceTemplate, (resource -> locationResourceService.saveResource(location, (AbstractLocationResourceTemplate) resource)), Subject.USER, userNames);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(resourceTemplate));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.audit.annotation.Audit in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesSecurityController method grantAccessToGroups.
/**
*****************************************************************************************************************************
*
* SECURITY ON GROUPS
*
******************************************************************************************************************************
*/
/**
* Grant access to the location resource to the groups
*
* @param locationId The location's id.
* @param groupIds The authorized groups.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Grant access to the location to the groups", notes = "Only user with ADMIN role can grant access to a group.")
@RequestMapping(value = "/groups", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public synchronized RestResponse<List<GroupDTO>> grantAccessToGroups(@PathVariable String orchestratorId, @PathVariable String locationId, @PathVariable String resourceId, @RequestBody String[] groupIds) {
Location location = locationService.getLocation(orchestratorId, locationId);
locationSecurityService.grantAuthorizationOnLocationIfNecessary(location, Subject.GROUP, groupIds);
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
resourcePermissionService.grantPermission(resourceTemplate, (resource -> locationResourceService.saveResource(location, (AbstractLocationResourceTemplate) resource)), Subject.GROUP, groupIds);
List<GroupDTO> groups = GroupDTO.convert(resourcePermissionService.getAuthorizedGroups(resourceTemplate));
return RestResponseBuilder.<List<GroupDTO>>builder().data(groups).build();
}
Aggregations