Skip to content

About

Production-ready Authentication & Authorization System built with Spring Boot, Spring Security, JWT, MySQL & Docker.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” SecureAuth

A production-ready Authentication & Authorization REST API built using Java, Spring Boot, Spring Security, JWT, MySQL, Docker, and Swagger/OpenAPI.

Java Spring Boot Spring Security JWT MySQL Docker License


πŸ“Œ Overview

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.


πŸš€ Features

πŸ” Authentication

  • βœ… User Registration
  • βœ… Secure Login
  • βœ… BCrypt Password Hashing
  • βœ… JWT Access Token Authentication
  • βœ… Refresh Token Support
  • βœ… Logout with Refresh Token Revocation
  • βœ… Protected User Profile API

πŸ“§ Email Verification

  • βœ… Verification Token Generation
  • βœ… Verification Email
  • βœ… Token Expiration
  • βœ… Account Activation after Email Verification
  • βœ… Verification Token Cleanup

πŸ”‘ Password Reset

  • βœ… 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

πŸ‘‘ Authorization

  • βœ… Role-Based Access Control (USER / ADMIN)
  • βœ… Protected Admin APIs
  • βœ… Admin User Management
  • βœ… Role Update Support

πŸ›‘οΈ Security & Backend

  • βœ… 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

πŸ›  Tech Stack

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

πŸ—οΈ Architecture

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚      Client         β”‚
                    β”‚ Swagger / Frontend  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚    REST Controllers β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     Service Layer   β”‚
                    β”‚ Auth / Admin / Emailβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Repository Layer  β”‚
                    β”‚    Spring Data JPA  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚       MySQL         β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

---

πŸ“‚ Project Structure

secure-auth
β”‚
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ controller
β”‚   β”œβ”€β”€ service
β”‚   β”‚   └── impl
β”‚   β”œβ”€β”€ repository
β”‚   β”œβ”€β”€ security
β”‚   β”œβ”€β”€ entity
β”‚   β”œβ”€β”€ dto
β”‚   β”‚   β”œβ”€β”€ request
β”‚   β”‚   └── response
β”‚   β”œβ”€β”€ exception
β”‚   └── config
β”‚
β”œβ”€β”€ docs
β”‚   └── screenshots
β”‚
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ pom.xml
└── README.md

πŸ“Έ API Screenshots

πŸ“– Swagger UI


πŸ‘€ User Registration


πŸ” User Login


πŸ™‹ Authenticated User Profile


πŸ‘‘ Admin Endpoint


🐳 Docker Deployment

The application is fully containerized using Docker Compose.

Containers:

  • secure-auth-app
  • secure-auth-mysql

πŸ—„ Database

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
---

πŸš€ Getting Started

Clone Repository

git clone https://github.com/anik-ug/secure-auth.git
cd secure-auth

Run with Docker

docker compose up --build

Application

http://localhost:8080

Swagger

http://localhost:8080/swagger-ui/index.html

πŸ”’ Security Features

  • 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

πŸ“ˆ Future Improvements

  • OAuth2 Login (Google/GitHub)
  • Redis Token Blacklisting
  • CI/CD using GitHub Actions
  • Kubernetes Deployment

πŸ‘¨β€πŸ’» Author

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.

About

Production-ready Authentication & Authorization System built with Spring Boot, Spring Security, JWT, MySQL & Docker.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages