Skip to content

Davheed2/Authentication-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Name

Authentication System with JWT, passport.js, and MongoDB

Description

This project is an authentication system built using JWT(JSON Web Tokens), Passport.js, and MongoDB as database . It provides secure user authentication and authorization functionalities for your web application.

Features

  • User registration with email and password
  • User login with JWT-based authntication
  • User profile management
  • Protected routes for authorized users
  • MongoDB for storing user data
  • Express.js for the backend server

    Installation

    1. Clone the repository:
    git clone https://github.com/Davheed2/Authentication-Sytem.git
    
    1. Install dependencies:
    cd authentication-sytem
    npm install
    
    1. Configure the environment variables:
  • Create a .env file in the root directory.
  • Add the following variables:
    PORT=5000 # Change as needed
    ACCESS_SECRET=your_access_secret
    REFRESH_SECRET=your_refresh_secret
    
    1. Start the server:
    npm start
    

    Usage

    1. Register a new user by making a POST request to /signup with a JSON body containing email and password. You will be given an access and refresh token which will be stored in the httpOnly secure cookie.
    2. Authenticate and log in a user by making a POST request to /login with valid credentials. You will be given an access and refresh token which will be stored in the httpOnly secure cookie.
    3. Access protected routes by including the JWT token in the Authorization header of your requests.
    4. Manage user profiles and data through the appropriate endpoints.

    API Endpoints

  • POST /signup: Register a new user.
  • POST /login: Authenticate and log in a user.
  • GET /logout: De-authenticate a logged in user.
  • GET /protected: View the protected route.
  • POST /refresh-token: Get a new access token from valid refresh token.
  • PUT /profile: Update the user's profile data (protected route).
  • DELETE /profile: Delete the user's profile data (protected route).

    Dependencies

  • Express.js: Web application framework.
  • Passport.js: Authentication middleware.
  • MongoDB: Database for user data storage.
  • JWT(jsonwebtoken): Library for JWT generation and verification.

    Contributing

    Contributions are welcome! Please follow the Contributing Guidelines to get started.

    License

    This project is licensed under the MIT Licence.

    Contact

  • Author: David Uchenna
  • Email: uchennadavid2404@gmail.com
  • Github: @Davheed2

    Feel free to reach out if you have any questions or issues related to this project.

  • About

    No description, website, or topics provided.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

     
     
     

    Contributors