Search in sources :

Example 1 with UserList

use of org.graylog2.rest.models.users.responses.UserList in project graylog2-server by Graylog2.

the class UsersResource method listUsers.

@GET
@Deprecated
@RequiresPermissions(RestPermissions.USERS_LIST)
@ApiOperation(value = "List all users", notes = "The permissions assigned to the users are always included.")
public UserList listUsers() {
    final List<User> users = userManagementService.loadAll();
    final AllUserSessions sessions = AllUserSessions.create(sessionService);
    final List<UserSummary> resultUsers = Lists.newArrayListWithCapacity(users.size() + 1);
    userManagementService.getRootUser().ifPresent(adminUser -> resultUsers.add(toUserResponse(adminUser, sessions)));
    for (User user : users) {
        resultUsers.add(toUserResponse(user, sessions));
    }
    return UserList.create(resultUsers);
}
Also used : User(org.graylog2.plugin.database.users.User) UserSummary(org.graylog2.rest.models.users.responses.UserSummary) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with UserList

use of org.graylog2.rest.models.users.responses.UserList in project graylog2-server by Graylog2.

the class AuthServiceBackendsResource method getUsers.

@GET
@Path("{backendId}/users")
@ApiOperation("Get paginated users for an authentication service backend")
@RequiresPermissions({ RestPermissions.AUTH_SERVICE_GLOBAL_CONFIG_READ, RestPermissions.USERS_READ })
public PaginatedResponse<UserOverviewDTO> getUsers(@ApiParam(name = "page") @QueryParam("page") @DefaultValue("1") int page, @ApiParam(name = "per_page") @QueryParam("per_page") @DefaultValue("50") int perPage, @ApiParam(name = "query") @QueryParam("query") @DefaultValue("") String query, @ApiParam(name = "sort", value = "The field to sort the result on", required = true, allowableValues = "username,full_name,email") @DefaultValue(UserOverviewDTO.FIELD_FULL_NAME) @QueryParam("sort") String sort, @ApiParam(name = "order", value = "The sort direction", allowableValues = "asc, desc") @DefaultValue("asc") @QueryParam("order") String order, @ApiParam(name = "backendId", required = true) @PathParam("backendId") @NotBlank String backendId) {
    final AuthServiceBackendDTO activeConfig = loadConfig(backendId);
    final PaginatedList<UserOverviewDTO> userList = userService.findPaginatedByAuthServiceBackend(parseSearchQuery(query), page, perPage, sort, order, activeConfig.id());
    return PaginatedResponse.create("users", userList, query, Collections.singletonMap("roles", createRoleContext(userList.delegate())));
}
Also used : UserOverviewDTO(org.graylog2.users.UserOverviewDTO) AuthServiceBackendDTO(org.graylog.security.authservice.AuthServiceBackendDTO) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 GET (javax.ws.rs.GET)2 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)2 Path (javax.ws.rs.Path)1 AuthServiceBackendDTO (org.graylog.security.authservice.AuthServiceBackendDTO)1 User (org.graylog2.plugin.database.users.User)1 UserSummary (org.graylog2.rest.models.users.responses.UserSummary)1 UserOverviewDTO (org.graylog2.users.UserOverviewDTO)1