A MERN Stack authentication application implementing JWT-based authentication with Access Tokens and Refresh Tokens.
- User Registration
- User Login
- Password Hashing using bcrypt
- JWT Authentication
- Short-lived Access Token
- Long-lived Refresh Token
- Protected Dashboard Route
- Refresh Token stored as HttpOnly Cookie
- MongoDB Database
- React Frontend
- Express Backend
- React
- React Router
- Tailwind CSS
- Fetch API
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT
- bcrypt
Frontend
src/ ├── pages/ │ ├── auth.jsx │ ├── dashboard.jsx │ └── home.jsx
Backend
src/ ├── config/ ├── controllers/ ├── middleware/ ├── models/ ├── routes/ └── services/
- User registers.
- Password is hashed using bcrypt.
- User logs in.
- Server returns:
- Access Token
- Refresh Token (HttpOnly Cookie)
- Dashboard requests include Access Token.
- If Access Token expires, Refresh Token generates a new Access Token.
npm install
npm run devnpm install
npm run devBackend
MONGO_URI=
JWT_SECRET=
Frontend
VITE_API_URL=http://localhost:5000
POST /register
POST /login
GET /dashboard
GET /logout
- Password hashing with bcrypt
- JWT Authentication
- HttpOnly Refresh Token
- Protected Routes
- Email Verification
- Password Reset
- Refresh Token Rotation
- Role-based Authentication
- Docker Deployment
- Unit Testing