A production-ready Authentication & Authorization REST API built using Java, Spring Boot, Spring Security, JWT, MySQL, Docker, and Swagger/OpenAPI.
SecureAuth is a backend authentication and authorization system built with Spring Boot and Spring Security.
The project demonstrates how a modern authentication system can be designed with JWT-based stateless authentication, refresh tokens, email verification, password reset, role-based authorization, secure password hashing, and Dockerized deployment.
The application follows a layered architecture with RESTful APIs, DTOs, service/repository separation, validation, and centralized exception handling.
- β User Registration
- β Secure Login
- β BCrypt Password Hashing
- β JWT Access Token Authentication
- β Refresh Token Support
- β Logout with Refresh Token Revocation
- β Protected User Profile API
- β Verification Token Generation
- β Verification Email
- β Token Expiration
- β Account Activation after Email Verification
- β Verification Token Cleanup
- β Forgot Password
- β Password Reset Token Generation
- β Password Reset Email
- β 15-Minute Token Expiration
- β Secure Password Update using BCrypt
- β Reset Token Invalidation after Password Change
- β Previous Reset Token Replacement
- β Role-Based Access Control (USER / ADMIN)
- β Protected Admin APIs
- β Admin User Management
- β Role Update Support
- β Spring Security 6
- β Stateless Authentication
- β JWT Authentication Filter
- β Input Validation
- β Global Exception Handling
- β RESTful API Design
- β JPA / Hibernate
- β MySQL Database
- β Docker & Docker Compose
- β Swagger / OpenAPI Documentation
| Category | Technology |
|---|---|
| Language | Java 17 |
| Framework | Spring Boot 3.5 |
| Security | Spring Security 6 |
| Authentication | JWT |
| Password Hashing | BCrypt |
| Database | MySQL 8 |
| ORM | Spring Data JPA / Hibernate |
| API Documentation | Swagger / OpenAPI |
| Build Tool | Maven |
| Containerization | Docker & Docker Compose |
βββββββββββββββββββββββ
β Client β
β Swagger / Frontend β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β REST Controllers β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Service Layer β
β Auth / Admin / Emailβ
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Repository Layer β
β Spring Data JPA β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β MySQL β
βββββββββββββββββββββββ
---
secure-auth
β
βββ src
β βββ controller
β βββ service
β β βββ impl
β βββ repository
β βββ security
β βββ entity
β βββ dto
β β βββ request
β β βββ response
β βββ exception
β βββ config
β
βββ docs
β βββ screenshots
β
βββ Dockerfile
βββ docker-compose.yml
βββ pom.xml
βββ README.md
The application is fully containerized using Docker Compose.
Containers:
- secure-auth-app
- secure-auth-mysql
Database tables:
- users
- refresh_tokens
# π Authentication Flow
User Registration
β
Verification Email Sent
β
Email Verification
β
Account Activated
β
Login
β
Access Token + Refresh Token
β
Access Protected APIs
β
Access Token Expires
β
Refresh Token
β
New Access Token
β
Continue Access
β
Logout
β
Refresh Token Revoked
---
git clone https://github.com/anik-ug/secure-auth.git
cd secure-authdocker compose up --buildApplication
http://localhost:8080
Swagger
http://localhost:8080/swagger-ui/index.html
- BCrypt password hashing
- JWT-based authentication
- Stateless authentication
- Refresh token management
- Refresh token revocation on logout
- Role-Based Access Control
- JWT authentication filter
- Email verification
- Expiring verification tokens
- Expiring password reset tokens
- One-time password reset token usage
- Input validation
- Global exception handling
- OAuth2 Login (Google/GitHub)
- Redis Token Blacklisting
- CI/CD using GitHub Actions
- Kubernetes Deployment
Anik Kumar
B.Tech (ECE) β’ IIIT Ranchi
GitHub: https://github.com/anik-ug
LinkedIn: https://www.linkedin.com/in/anik-kumar-6a8397287/
β If you found this project useful, consider giving it a star.







