Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

React Spring JWT MySQL


🔐 The Problem This Solves

Type your password into most "strength checker" websites and it gets sent straight to a server. You have no idea what happens to it after that.

This project treats that as a bug, not a norm. Every byte of password analysis and generation happens in your browser. The Spring Boot backend never sees, receives, or logs the passwords you're checking or generating — it only exists for account login, and even then it stores a BCrypt hash, never the password itself.

 What the backend NEVER sees          What the backend DOES handle
 ─────────────────────────────        ─────────────────────────────
 ✗ Passwords you're analyzing         ✓ Account email + hashed password
 ✗ Passwords being generated          ✓ JWT issuance for sessions
 ✗ Any personalization input          ✓ Security education content
                                       ✓ User profile metadata

🧭 What's Inside

🔍 Password Analyzer Real-time strength scoring — length, character variety, common patterns, sequential runs — with a live meter and specific feedback, computed entirely in passwordStrength.ts.

🎲 Password Generator Random mode (configurable length + character sets) and passphrase mode, both built on crypto.getRandomValues() — not Math.random(), which isn't cryptographically safe for this use case.

📚 Security Education DB-backed topic cards (passwords, 2FA, phishing) — content lives in MySQL via a SecurityTopic entity, not hardcoded into the frontend, so it can grow without a redeploy.

👤 Dashboard Profile summary pulled from the JWT-authenticated /api/users/me endpoint, plus quick links into the other three tools.


🏗️ How Auth Actually Works Here

  Browser                          Spring Boot                     MySQL
     │                                  │                             │
     │  POST /api/auth/register         │                             │
     ├─────────────────────────────────▶│  BCrypt.hash(password)      │
     │                                  ├────────────────────────────▶│
     │  ◀── { token, email } ───────────┤                             │
     │                                  │                             │
     │  GET /api/users/me               │                             │
     │  Authorization: Bearer <token>   │                             │
     ├─────────────────────────────────▶│  JwtAuthFilter validates,   │
     │                                  │  sets SecurityContext        │
     │  ◀── { email, memberSince } ─────┤                             │

Stateless JWT auth (SessionCreationPolicy.STATELESS) means the server holds no session state — every request carries its own proof of identity, verified by JwtAuthFilter before it ever reaches a controller.


🛠️ Stack Rationale

Choice Why
JWT over sessions Stateless — no server-side session store to manage or scale
BCrypt Adaptive hashing; deliberately slow to resist brute-force
crypto.getRandomValues Cryptographically secure RNG, unlike Math.random()
Client-side password logic Removes the backend as a point of exposure entirely
DTOs at every boundary Entities never serialize directly to the client
DB-backed education content Content can change without a frontend redeploy

⚙️ Running It Locally

Backend (Java 17, MySQL)

cd backend
CREATE DATABASE password_analyzer_db;
# src/main/resources/application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/password_analyzer_db
spring.datasource.username=your_mysql_username
spring.datasource.password=your_mysql_password
spring.jpa.hibernate.ddl-auto=update

jwt.secret=your-long-random-secret-key-at-least-32-characters
jwt.expiration-ms=86400000
./mvnw spring-boot:run

Runs on localhost:8080 · Swagger at /swagger-ui/index.html · DataSeeder auto-populates security topics on first boot.

Frontend (Node + npm)

cd frontend
npm install
npm run dev

Runs on localhost:5173. If Vite picks a different port, update setAllowedOrigins in SecurityConfig.java to match — CORS is locked to a single origin on purpose.


🔌 API Reference

Method Endpoint Auth Description
POST /api/auth/register ❌ Create account, receive JWT
POST /api/auth/login ❌ Authenticate, receive JWT
GET /api/users/me ✅ Current user's profile
GET /api/topics ✅ All security education topics
GET /api/topics/{id} ✅ Single topic

Every response follows one shape, success or failure:

{ "success": true, "data": { "...": "..." }, "message": "Login successful" }

📁 Project Layout

password-security-analyzer/
├── backend/  com.shruti.passwordanalyzer/
│   ├── config/       JwtUtil · JwtAuthFilter · SecurityConfig · DataSeeder
│   ├── controller/   Auth · User · SecurityTopic
│   ├── service/      Business logic, kept out of controllers
│   ├── dto/          Request/response contracts
│   ├── entity/       User · SecurityTopic
│   ├── repository/   Spring Data JPA interfaces
│   └── exception/    Custom exceptions + @RestControllerAdvice
└── frontend/  src/
    ├── api/          Typed fetch wrappers per resource
    ├── components/   Dashboard · Analyzer · Generator · Education · AuthForm
    └── utils/        passwordStrength.ts · passwordGenerator.ts (all client-side)

🗺️ Build Progress

  • Architecture & project setup
  • Backend foundation — DTOs, global exception handling, Swagger
  • JWT authentication end to end
  • React + TypeScript frontend foundation
  • Client-side password analysis engine
  • Client-side password generator (random + passphrase)
  • DB-backed security education module
  • User dashboard
  • Personalized generator mode (with dictionary-attack warnings)
  • Automated test coverage
  • Full responsive UI polish

Shruti Pawar · CS Student, SNDT Women's University

GitHub LinkedIn

built on the idea that the safest place for your password is nowhere but your own browser

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages