A production-ready authentication service built with the MERN stack that supports multiple authentication providers, secure session management, and modern authentication best practices.
- User Registration
- User Login
- Secure Logout
- JWT Authentication
- HTTP-only Cookie Authentication
- Protected Routes
- Google Sign-In
- GitHub Sign-In
- Automatic Account Linking
- Single Account Across Multiple Providers
- Forgot Password
- Reset Password
- Secure Email-Based Password Reset
- Password Hashing with bcryptjs
- JWT Authentication
- HTTP-only Cookies
- Secure Password Reset Tokens
- Input Validation
- Environment Variables
- OAuth 2.0 & OpenID Connect
- React 19
- TypeScript
- Vite
- Axios
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT
- bcryptjs
- Google Identity Services
- GitHub OAuth
- Nodemailer
- Mailtrap
- ESLint
- Prettier
.
โโโ client/
โโโ server/
โโโ assets/
โโโ README.md
โโโ .gitignore
git clone https://github.com/Beast18akash/mern-auth-system.git
cd mern-auth-systemFrontend
cd client
npm installBackend
cd server
npm installCreate the following files.
VITE_API_URL=http://localhost:5000
VITE_GOOGLE_CLIENT_ID=your_google_client_idPORT=5000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
CLIENT_URL=http://localhost:5173
EMAIL_HOST=
EMAIL_PORT=
EMAIL_USER=
EMAIL_PASS=
GOOGLE_CLIENT_ID=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=http://localhost:5000/api/auth/github/callbackStart the backend
cd server
npm run devStart the frontend
cd client
npm run devUser
โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
Local Login Google Login GitHub Login
โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โผ
Authentication Service
โ
โผ
Account Linking Layer
โ
โผ
JWT Authentication
โ
โผ
HTTP-only Cookie Session
โ
โผ
Protected Application
| Version | Description |
|---|---|
| v1.0.0 | Initial stable authentication service |
| v1.1.0 | GitHub OAuth & Multi-provider authentication |
- Email Verification
- Refresh Tokens
- Session Management
- User Profile
- Two-Factor Authentication (2FA)
- Role-Based Access Control (RBAC)
Contributions, suggestions, and improvements are welcome.
Feel free to fork the repository and submit a pull request.
This project is licensed under the MIT License.





