The Users Service is responsible for handling authentication, authorization, and user profile management for the application. It is a key component of the DevQuestIO project, ensuring secure and flexible user authentication.
- Node.js
- Express.js
- Keycloak
- Two-Factor Authentication (2FA):
- Provides enhanced security by requiring an additional verification step during login.
- Single Sign-On (SSO):
- Simplified authentication process using external identity providers like Google.
- Flexible Authentication Options:
- Supports both username/password login and external identity providers.
- Customizable Realms:
- Configured realms in Keycloak to manage authentication rules and policies for the application.
- Integrated Keycloak to enable robust login flows.
- Ensures secure token-based authentication for all API calls.
Below are the APIs exposed by the Users Service:
- Login
- Endpoint:
POST /auth/login - Description: Handles user login with username/password or via SSO.
- Endpoint:
- Logout
- Endpoint:
POST /auth/logout - Description: Ends the user session and invalidates the token.
- Endpoint:
- Refresh Token
- Endpoint:
POST /auth/refresh - Description: Refreshes the user's access token.
- Endpoint:
- Create User
- Endpoint:
POST /users - Description: Registers a new user in the system.
- Endpoint:
- Get User Profile
- Endpoint:
GET /users/:id - Description: Retrieves the profile information of a specific user.
- Endpoint:
- Update User Profile
- Endpoint:
PUT /users/:id - Description: Updates user profile details.
- Endpoint:
- Delete User
- Endpoint:
DELETE /users/:id - Description: Deletes a user from the system.
- Endpoint:
- Assign Role to User
- Endpoint:
POST /roles/assign - Description: Assigns a specific role to a user.
- Endpoint:
- Get User Roles
- Endpoint:
GET /roles/:userId - Description: Retrieves all roles assigned to a user.
- Endpoint:
- Realm Configuration:
- Set up a realm in Keycloak with specific authentication flows and policies.
- Client Configuration:
- Register a client for the frontend application to enable secure communication.
- Environment Variables:
- Configure Keycloak environment variables (e.g., realm name, client ID, secret).
- Node.js installed.
- Keycloak running locally or accessible via a server.
- Clone the repository:
git clone https://github.com/DevQuestIO/Users.git cd Users - Install dependencies:
npm install
- Configure environment variables:
- Create a
.envfile with the following:KEYCLOAK_REALM=devquest KEYCLOAK_CLIENT_ID=your-client-id KEYCLOAK_CLIENT_SECRET=your-client-secret KEYCLOAK_URL=http://localhost:8080 PORT=5000
- Create a
- Start the server:
npm start