A Spring Boot microservice that handles user identity for a small e-commerce platform: sign up, login, logout, password/session validation, and role management. It also acts as an OAuth2/OIDC authorization server (via Spring Authorization Server) so other services can validate JWT-based sessions issued by this service.
This service is part of a small e-commerce microservices suite together with
paymentservice and
productservice_proxy.
- User sign up and login (
AuthController) - Logout and session/token validation
- Role management for users (
RoleController,UserController) - Password hashing via
BCryptPasswordEncoder - JWT issuance/validation using
io.jsonwebtoken(JJWT) - OAuth2/OIDC Authorization Server support (Spring Authorization Server), including JPA-backed client, authorization, and consent repositories
- Database schema migrations via Flyway
| Method | Path | Description |
|---|---|---|
| POST | /auth/signup |
Create a new user account |
| POST | /auth/login |
Authenticate a user and issue a session |
| POST | /auth/logout |
Invalidate an existing session |
| POST | /auth/validate |
Validate a session token |
| GET | /users/{id} |
Fetch a user's details |
| POST | /users/{id}/roles |
Assign roles to a user |
- Java 17, Spring Boot 3.1.4
- Spring Data JPA / Spring Data JDBC
- Spring Security + Spring Authorization Server (OAuth2/OIDC)
- MySQL (via
mysql-connector-j) - Flyway for database migrations
- JJWT for JWT handling
- Lombok
- Java 17
- Maven (or use the bundled
./mvnw) - A MySQL instance
Database connection and OAuth2 client settings are configured in
src/main/resources/application.properties. Update the datasource URL,
username, and password for your local MySQL instance before running the
service. Do not commit real credentials — use environment variables or a
local override for anything sensitive.
./mvnw spring-boot:runThe service starts on the default Spring Boot port (8080) unless
overridden.
./mvnw testReleased under the MIT License.