The user service component provides user data and authentication functions for registration and login as REST-Service. Additionally, it provides a service via gRPC to validate authorisation tokens for other services.
- Description: Processes user login requests. Users need to provide login credentials.
- Usage: Submit authentication details (username, password) in request body. Returns a jwt token on success.
- Description: Handles new user registrations.
- Usage: Submit registration details (username, password, email, etc.). Returns confirmation upon successful account creation.
- Description: Retrieves users based on their role.
- Usage: Include user role as URL parameter. Returns a list of users matching the specified role.
- Access control: Only merchants are unrestricted for users. An admin can fetch users by every role.
- Description: Fetches details of a specific user by their unique ID.
- Usage: Provide user ID as URL parameter. Returns details of the corresponding user.
- Access control: Only the user or an admin can do this.
- Description: Allows updating a user's information.
- Usage: Include user ID as URL parameter and updated information in the request body. Updates user details in the database.
- Access control: Only the user or an admin can do this.
- Description: Deletes a user from the system.
- Usage: Require user ID as a URL parameter. Removes the user with the given ID from the database.
- Access control: Only the user or an admin can do this.
- Server Method:
UserServiceServer.ValidateUserToken
- Request Type:
ValidateUserTokenRequest
- Response Type:
ValidateUserTokenResponse
This endpoint validates a user's authentication token. It checks the validity of the provided token and, if valid, retrieves the user's details based on the token's claims. If the verification fails due to an invalid token, it returns a status error.
This endpoint is primarily used for internal authentication and authorization purposes of other services, ensuring that the client's requests are accompanied by a valid, authenticated user token. It's essential in scenarios where user identity and permissions need to be validated before granting access to specific resources or operations.
You can configure this service with environmental variables or an environment file (.env) relative to the main application file.
RQLITE_HOST="database"
RQLITE_PORT=4001
RQLITE_USER="db-user"
RQLITE_PASSWORD="db-pw-changeMe!"
HTTP_SERVER_PORT=3001
GRPC_SERVER_PORT=50051
JWT_PRIVATE_KEY="<path [e.g. privateKey.pem] or inline-key>"
To generate a ecdsa private key in pem format you can use the following command:
ssh-keygen -t ecdsa -f privateKey.pem -m pem
When no or an invalid key is provided, container will use a random but secure generated key on each start. Note: Users will be logged-out when the service restarts.
You can operate the service either as a standalone application or within a containerized environment. The database is required. It is designed to automatically generate the necessary tables should they not already exist.
Also: See the main README.md to get information for a complete containerized setup.