use of alien4cloud.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class ServiceSecurityController method getAuthorizedUsers.
/**
* List all users authorised to access the location.
*
* @return list of all users.
*/
@ApiOperation(value = "List all users authorized to access the service 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 serviceId) {
ServiceResource service = serviceResourceService.getOrFail(serviceId);
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 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.rest.orchestrator.model.UserDTO 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.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class LocationSecurityController method revokeUserAccess.
/**
* Revoke the user's authorisation to access the location
*
* @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 the location, 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 username) {
Location location = locationService.getLocation(orchestratorId, locationId);
resourcePermissionService.revokePermission(location, Subject.USER, username);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(location));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.rest.orchestrator.model.UserDTO in project alien4cloud by alien4cloud.
the class LocationSecurityController method getAuthorizedUsers.
/**
* List all users authorised to access the location.
*
* @return list of all users.
*/
@ApiOperation(value = "List all users authorized to access the location", 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) {
Location location = locationService.getLocation(orchestratorId, locationId);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(location));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
Aggregations