Skip to content

A complete user authentication system built using Spring Boot, Spring Security, JWT (JSON Web Token), and MySQL. This project demonstrates a stateless REST API where users can register, log in, and securely access protected resources using JWT-based authentication.

Notifications You must be signed in to change notification settings

RustamPoonia/AuthX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 AuthX – Secure JWT Authentication API

A secure and professional-grade backend authentication system built using Spring Boot, Spring Security, and JWT (JSON Web Token). Designed to demonstrate best practices in stateless REST API development with token-based authentication and email verification.

🎯 Features

✅ User registration and login with validation
✅ JWT-based stateless authentication
✅ Secure profile access using token
✅ Email verification with OTP
✅ Reset password via OTP
✅ Modular and clean project structure
✅ MySQL integration
✅ CORS enabled for frontend access

#🛠️ Tech Stack

  • Java 17
  • Spring Boot 3
  • Spring Security
  • JWT (jjwt)
  • MySQL
  • Maven
  • Postman (for testing)

📦 Project Structure

src/
├── configurations/            # Security and JWT filter configs
├── controller/                # REST Controllers (Auth, Profile)
├── entity/                    # User entity
├── repository/                # Spring Data JPA repositories
├── services/                  # Business logic
├── userdto/                   # DTOs: Login, Register, AuthResponse, etc.
├── jwt/                       # JWT token utility classes
└── resources/                 # application.properties

🔗 API Endpoints

🔸 Authentication

▶️ Register User

POST /api/v1.0/auth/register

▶️ Login User

POST /login

✅ Check Authentication

GET /is-authenticated

Returns true if user is authenticated using JWT.


👤 Profile

🔎 Get Profile (Protected)

GET /api/v1.0/profile

Headers

Key Value
Authorization Bearer JWT_TOKEN_HERE

🔐 Email Verification & Password Reset

📤 Send Email Verification OTP

POST /send-otp

Headers

Key Value
Authorization Bearer JWT_TOKEN_HERE

✅ Verify Email with OTP

POST /verify-email

Headers

Key Value
Authorization Bearer JWT_TOKEN_HERE

Body

{
  "otp": "123456"
}

🔁 Send Reset Password OTP

POST /send-reset-otp?email=user@example.com

🔒 Reset Password Using OTP

POST /reset-password

Body

{
  "email": "user@example.com",
  "otp": "123456",
  "newPassword": "newSecurePassword"
}

📁 Configuration (application.properties)

spring.datasource.url=jdbc:mysql://localhost:3306/authx_db
spring.datasource.username=root
spring.datasource.password=yourpassword

jwt.secret=your_jwt_secret
jwt.expiration=86400000

🧪 Postman Workflow

  1. Register → /auth/register
  2. Login → /login → copy token
  3. Access /profile with header:
    Authorization: Bearer <JWT_TOKEN>
  4. Email Verification → /send-otp, /verify-email
  5. Forgot Password → /send-reset-otp, /reset-password

📸 Screenshots


📌 TODO / Future Enhancements

  • 🔄 Refresh token endpoint
  • 🔓 Logout endpoint (client-side JWT destroy)
  • 👮 Admin-specific role-based routes

🙋 Author

Rustam – Final Year B.Tech Student
🔗 GitHub: @RustamPoonia


📄 License

This project is released under the MIT License. Feel free to use and contribute.


🟦🟩🟨🟧🟥🟪 Thanks for checking out AuthX!

About

A complete user authentication system built using Spring Boot, Spring Security, JWT (JSON Web Token), and MySQL. This project demonstrates a stateless REST API where users can register, log in, and securely access protected resources using JWT-based authentication.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages