feat(users): add GET /users endpoint for listing users #2432
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements a new
GET /usersendpoint in the users controller that allows retrieving user information from the database.Motivation
ADMIN_GROUPSlikeadmin,ingestor) can retrieve all users in the databaseImplementation details
1. New CASL Actions (
src/casl/action.enum.ts)UserListAll- grants permission to list all users (admin only)UserListOwn- grants permission to list own user info (all authenticated users)2. CASL Ability Factory (
src/casl/casl-ability.factory.ts)ADMIN_GROUPS) are grantedUserListAllpermissionUserListOwnpermissionUserListAll3. Users Service (
src/users/users.service.ts)findAll()method that retrieves all users from the database4. Users Controller (
src/users/users.controller.ts)GET /usersendpoint with proper guards and policy checksChanges
Unit Tests Added
Controller Tests (
src/users/users.controller.spec.ts)userEndpointAccessfindAllservice is not called for non-admin usersService Tests (
src/users/users.service.spec.ts)findByIdreturns user or null appropriatelyAPI Documentation
The endpoint is documented with Swagger decorators:
@ApiOperationwith summary and description@ApiResponsewith status 200 andReturnedUserDto[]typeAuthorization Matrix
ADMIN_GROUPS)Tests included
Documentation
Official documentation info
N/A - No official documentation changes required for this PR.