A production-minded authentication service built with Spring Boot, Spring Security, JWT, PostgreSQL, Flyway, Docker, and CI support.
This project is designed to showcase the backend skills recruiters usually look for in a strong Java project:
- secure JWT-based authentication with refresh-token flow
- role-based authorization for
USERandADMIN - PostgreSQL persistence with Flyway migrations
- request validation and structured error handling
- unit tests for auth and token logic
- Dockerized local setup
- Postman collection for quick API testing
- GitHub Actions CI for automated verification
- Java 21
- Spring Boot 3
- Spring Security
- Spring Data JPA
- PostgreSQL
- Flyway
- JJWT
- Swagger / OpenAPI
- JUnit 5 + Mockito
- Docker Compose
- User signup
- User login
- Refresh access token
- Logout with refresh-token revocation
- Protected authenticated endpoint
- Protected admin-only endpoint
- Seeded demo users for quick walkthrough
- Swagger UI at
/swagger-ui/index.html - Health endpoint at
/actuator/health
| Method | Endpoint | Description |
|---|---|---|
POST |
/auth/v1/signup |
Register a new user |
POST |
/auth/v1/login |
Authenticate and receive tokens |
POST |
/auth/v1/refresh-token |
Issue a new access token |
POST |
/auth/v1/logout |
Revoke a refresh token |
GET |
/api/v1/me |
Authenticated user endpoint |
GET |
/api/v1/admin |
Admin-only endpoint |
Use the sample file as a reference:
.env.exampleImportant variables:
POSTGRES_HOSTPOSTGRES_PORTPOSTGRES_DBPOSTGRES_USERNAMEPOSTGRES_PASSWORDJWT_SECRET
JWT_SECRET must be a Base64-encoded secret key.
You can use your own PostgreSQL instance or Docker Compose.
demo_user/Password1demo_admin/AdminPass1
./gradlew test
./gradlew :app:bootRunIf you want a zero-setup demo for README screenshots and recruiter walkthroughs, run:
./gradlew app:bootRun --args='--server.port=9900 --spring.profiles.active=demo'This profile uses an in-memory H2 database, applies the same Flyway migration, and seeds:
demo_user/Password1demo_admin/AdminPass1
http://localhost:9898/swagger-ui/index.html
Build the application JAR first, then run Docker Compose:
./gradlew build
docker compose up --buildRun:
./gradlew testCurrent automated coverage includes:
- JWT generation and validation logic
- refresh-token creation and revocation logic
- auth controller flow unit tests
You can test APIs using the Postman collection included in the repository.
Path:
postman/auth-service-collection.json
Recommended Postman variables:
baseUrlaccessTokenrefreshToken
- Architecture diagram:
docs/architecture-diagram.md - Auth flow diagram:
docs/auth-flow.md - Example request payloads:
docs/api-examples.md - Live demo responses:
docs/live-demo-output.md
Flyway migration scripts are stored in:
app/src/main/resources/db/migration
The initial migration creates:
usersrolesusers_rolesrefresh_tokens
It also seeds:
ROLE_USERROLE_ADMIN
The screenshot plan is tracked in docs/SCREENSHOT-CHECKLIST.md.
Full API documentation view for quick recruiter scanning.
Expanded auth endpoint showing request and response structure.
Schema definitions for request and response payloads.
Additional Swagger view for a stronger recruiter walkthrough.
Shows successful registration and token issuance.
Shows access-token and refresh-token generation.
Shows access token renewal using refresh token.
Shows authenticated access with a valid bearer token.
Shows role-based authorization working correctly for a non-admin user.
Shows refresh-token revocation in action.
Shows persisted users, roles, and refresh tokens.
Shows duplicate-user handling and structured error responses.
Shows what happens when a refresh token or invalid token is used against a protected endpoint.
- Add
docs/screenshots/ci-passing.pngafter your GitHub Actions workflow is green.
- Built a secure authentication service using Spring Boot, Spring Security, JWT, and PostgreSQL with login, signup, logout, refresh-token rotation-style revocation, and role-based authorization.
- Added Flyway migrations, automated tests, Docker-based local setup, Swagger documentation, and a Postman collection to make the service easy to validate and demo.
- capture README screenshots after running the app and Postman flows
- add integration tests with Testcontainers












