use of alien4cloud.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesSecurityController method revokeUserAccess.
/**
* Revoke the user's authorisation to access a location resource
*
* @param locationId The id of the location.
* @param username The authorized user.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Revoke the user's authorisation to access a location resource, send back the new authorised users list", notes = "Only user with ADMIN role can revoke access to the location.")
@RequestMapping(value = "/users/{username}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public synchronized RestResponse<List<UserDTO>> revokeUserAccess(@PathVariable String orchestratorId, @PathVariable String locationId, @PathVariable String resourceId, @PathVariable String username) {
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
resourcePermissionService.revokePermission(resourceTemplate, (resource -> locationResourceService.saveResource((AbstractLocationResourceTemplate) resource)), Subject.USER, username);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(resourceTemplate));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesSecurityController method getAuthorizedUsers.
/**
* List all users authorised to access the location resource.
*
* @return list of all authorized users.
*/
@ApiOperation(value = "List all users authorized to access the location resource", notes = "Only user with ADMIN role can list authorized users to the location.")
@RequestMapping(value = "/users", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<List<UserDTO>> getAuthorizedUsers(@PathVariable String orchestratorId, @PathVariable String locationId, @PathVariable String resourceId) {
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(resourceTemplate));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class ServiceSecurityController method grantAccessToUsers.
/**
*****************************************************************************************************************************
*
* SECURITY ON USERS
*
******************************************************************************************************************************
*/
/**
* Grant access to the location to the user (deploy on the location)
*
* @param serviceId The location's id.
* @param userNames The authorized users.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Grant access to the service 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 serviceId, @RequestBody String[] userNames) {
ServiceResource service = serviceResourceService.getOrFail(serviceId);
resourcePermissionService.grantPermission(service, Subject.USER, userNames);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(service));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class ServiceSecurityController method revokeUserAccess.
/**
* Revoke the user's authorisation to access the location
*
* @param serviceId The id of the location.
* @param username The authorized user.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Revoke the user's authorisation to access the service resource, send back the new authorised users list", notes = "Only user with ADMIN role can revoke access to the location.")
@RequestMapping(value = "/users/{username}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public synchronized RestResponse<List<UserDTO>> revokeUserAccess(@PathVariable String serviceId, @PathVariable String username) {
ServiceResource service = serviceResourceService.getOrFail(serviceId);
resourcePermissionService.revokePermission(service, Subject.USER, username);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(service));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
Aggregations