Skip to content

Authentication System (Node.js + Express + MongoDB + JWT + OAuth + More)

License

Notifications You must be signed in to change notification settings

rahulranjandev/Authentication-System-Node.js

Repository files navigation

Authentication System (Node.js + Express + MongoDB + JWT + OAuth + More)

This is a basic README template for an Authentication System built with Node.js and Express. Customize it according to your project's specific details.

Table of Contents

Introduction

This Authentication System is a Node.js application that provides user authentication and registration functionality. It includes user registration, login, password reset, and JWT-based authentication. The system is built using modern JavaScript and uses popular libraries and frameworks such as Express, MongoDB, and more.

Features

  • User Registration: Allowing users to create new accounts.
  • User Login: Authenticating users and generating JWT tokens.
  • Password Reset: Resetting user passwords via email.
  • Rate Limiting: Protecting against brute-force attacks.
  • Secure: Implementing security best practices, including helmet and bcrypt.
  • Logging: Logging requests using Morgan.
  • Error Handling: Handling errors and exceptions gracefully.
  • Configuration: Using dotenv for environment variable management.
  • Testing: Includes sample test cases.
  • Ready for Deployment: Configured for easy deployment to platforms like Heroku or AWS.

Requirements

Make sure you have the following software installed:

  • Node.js (16 or higher)
  • MongoDB (or a MongoDB cloud service)
  • npm or yarn (package managers)
  • Git (optional)

Installation

  1. Clone this repository or download the source code.
git clone https://github.com/rahulranjan937/authentication-system.git
cd authentication-system
  1. Install dependencies.
npm install

Configuration

  1. Create a .env file in the project root directory based on the .env.example file provided.

  2. Update the .env file with your configuration settings, including database connection details, JWT secret, and other environment-specific variables.

Usage

To start the application, run:

npm start

This will start the Express server, and your authentication system will be accessible at http://localhost:3000 by default. You can customize the port and other settings in the .env file.

API Endpoints

  • POST /api/register: Register a new user.
  • POST /api/login: Log in and obtain a JWT token.
  • POST /api/forgotpassword: Send an email to reset the password.
  • POST /api/resetpassword/:token: Reset the user's password with a valid token.
  • POST /api/changepassword: Change the user's password.
  • GET /api/profile: Get the user's profile (protected route). (Coming Soon)

Testing (Coming Soon)

To run the sample test cases, use the following command:

npm test

You can add more test cases in the test directory as needed.

Deployment

This Authentication System is ready for deployment to various cloud platforms. You can use services like Heroku, AWS, or others to host your application. Be sure to configure the environment variables accordingly for production deployment.

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and test thoroughly.
  4. Submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Authentication System (Node.js + Express + MongoDB + JWT + OAuth + More)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published