Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1.05 KB

File metadata and controls

51 lines (40 loc) · 1.05 KB

Spring Boot JWT Authentication

A production-ready authentication system built using Spring Boot, Spring Security, JWT, and MySQL.

Features

  • User Registration & Login
  • JWT-based Authentication
  • Stateless Security
  • Role-based Authorization (USER / ADMIN)
  • BCrypt Password Encryption
  • MySQL Database Integration
  • Protected APIs using JWT filter

Tech Stack

  • Java 17
  • Spring Boot
  • Spring Security
  • JWT (JSON Web Token)
  • Spring Data JPA (Hibernate)
  • MySQL
  • Maven

API Endpoints

Authentication

  • POST /api/auth/register
  • POST /api/auth/login

Protected

  • GET /api/users
  • GET /api/admin (ADMIN role only)

Security Flow

  1. User logs in with email & password
  2. Server validates credentials
  3. JWT token is generated
  4. Token must be sent in Authorization header: Authorization: Bearer <JWT_TOKEN>
  5. JWT filter validates token on every request

Database Tables

  • users
  • roles
  • user_roles

Purpose

Built to demonstrate real-world Spring Security + JWT authentication and prepare for backend interviews.


Author: Shivam Yogi