Skip to content

Latest commit

ย 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 

Repository files navigation

React TypeScript Node.js MongoDB JWT License

๐Ÿ” MERN Authentication Service

A production-ready authentication service built with the MERN stack that supports multiple authentication providers, secure session management, and modern authentication best practices.


โœจ Features

Authentication

  • User Registration
  • User Login
  • Secure Logout
  • JWT Authentication
  • HTTP-only Cookie Authentication
  • Protected Routes

Social Authentication

  • Google Sign-In
  • GitHub Sign-In
  • Automatic Account Linking
  • Single Account Across Multiple Providers

Password Management

  • Forgot Password
  • Reset Password
  • Secure Email-Based Password Reset

Security

  • Password Hashing with bcryptjs
  • JWT Authentication
  • HTTP-only Cookies
  • Secure Password Reset Tokens
  • Input Validation
  • Environment Variables
  • OAuth 2.0 & OpenID Connect

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 19
  • TypeScript
  • Vite
  • Axios

Backend

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose

Authentication

  • JWT
  • bcryptjs
  • Google Identity Services
  • GitHub OAuth
  • Nodemailer
  • Mailtrap

Development

  • ESLint
  • Prettier

๐Ÿ“‚ Project Structure

.
โ”œโ”€โ”€ client/
โ”œโ”€โ”€ server/
โ”œโ”€โ”€ assets/
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ .gitignore

๐Ÿš€ Getting Started

Clone the repository

git clone https://github.com/Beast18akash/mern-auth-system.git
cd mern-auth-system

Install dependencies

Frontend

cd client
npm install

Backend

cd server
npm install

โš™๏ธ Environment Variables

Create the following files.

Client

VITE_API_URL=http://localhost:5000
VITE_GOOGLE_CLIENT_ID=your_google_client_id

Server

PORT=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/callback

โ–ถ๏ธ Running the Project

Start the backend

cd server
npm run dev

Start the frontend

cd client
npm run dev

๐Ÿ“ธ Screenshots

Sign Up

Sign Up

Sign In

Sign In

Forgot Password

Forgot Password

Sign In with Google

Sign In with Google button

Google Account Chooser

Sign In with GitHub

GitHub Authorization Page


๐Ÿ—๏ธ Authentication Flow

User
   โ”‚
   โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚                  โ”‚                  โ”‚
   โ–ผ                  โ–ผ                  โ–ผ
Local Login      Google Login      GitHub Login
   โ”‚                  โ”‚                  โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ผ
          Authentication Service
                      โ”‚
                      โ–ผ
           Account Linking Layer
                      โ”‚
                      โ–ผ
           JWT Authentication
                      โ”‚
                      โ–ผ
          HTTP-only Cookie Session
                      โ”‚
                      โ–ผ
          Protected Application

๐Ÿ“ฆ Releases

Version Description
v1.0.0 Initial stable authentication service
v1.1.0 GitHub OAuth & Multi-provider authentication

๐Ÿ”ฎ Roadmap

  • Email Verification
  • Refresh Tokens
  • Session Management
  • User Profile
  • Two-Factor Authentication (2FA)
  • Role-Based Access Control (RBAC)

๐Ÿค Contributing

Contributions, suggestions, and improvements are welcome.

Feel free to fork the repository and submit a pull request.


๐Ÿ“„ License

This project is licensed under the MIT License.

About

A scalable MERN Stack authentication system featuring JWT authentication, HTTP-only cookies, bcrypt password hashing, secure password reset, and extensible support for OAuth providers like Google and GitHub.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages