What You'll Build
Architecture Overview
1. Project Setup & Dependencies
Terminal
2. User Entity & Database Schema
src/users/user.entity.ts
Security Note: Refresh Token Hashing
3. Auth Module & JWT Configuration
src/auth/auth.module.ts
4. Passport Strategies
4a. Local Strategy (Credential Validation)
src/auth/strategies/local.strategy.ts
4b. JWT Access Strategy (Protected Route Guard)
src/auth/strategies/jwt-access.strategy.ts
4c. JWT Refresh Strategy (Token Rotation)
src/auth/strategies/jwt-refresh.strategy.ts
5. Auth Service � Core Business Logic
src/auth/auth.service.ts
6. Auth Controller & Guards
src/auth/auth.controller.ts
7. Environment Variables
.env
Frequently Asked Questions
Why store the refresh token hashed in the database?
Why use HttpOnly cookies for refresh tokens instead of localStorage?
What is refresh token rotation and why does it matter?
How do I protect routes globally instead of per-controller?