Giter Club home page Giter Club logo

2fa_with_authenticator's Introduction

2Fa with Authenticator Apps like Google Authenticator

This project provides a RESTful API for user authentication and management, utilizing MongoDB as the database and OTPAuth for generating and validating One-Time Passwords (OTP). The API is built using Express.js and is designed to handle user registration, login, OTP generation, verification, validation, and disabling.

Table of Contents

Documentation

Deployed Endpoint

Endpoints

  1. POST /register: Register a new user by providing the user's name, email, and password. If successful, the user is added to the database.

  2. POST /login: Log in a user by providing their email and password. If the login is successful, user details are returned, including OTP status.

  3. POST /otp/generate: Generate an OTP for a user. The generated OTP is associated with the user, and a QR code is generated for adding the OTP to an authenticator app.

  4. POST /otp/verify: Verify an OTP provided by the user. If the OTP is valid, the user's OTP status is updated.

  5. POST /otp/validate: Validate an OTP provided by the user. The validation window is extended to allow for minor time discrepancies.

  6. POST /otp/disable: Disable OTP for a user.

Getting Started

  1. Clone this repository to your local machine.
  2. Install the required dependencies using npm install.
  3. Set up your MongoDB database and provide the database URL in the project's environment.
  4. Start the backend server using npm start.

Usage

  1. Start the backend server.
  2. Use tools like Postman to send requests to the defined API endpoints.
  3. Follow the flow for user registration, login, OTP generation, verification, validation, and disabling.

Note: This collection requires the use of an authenticator app that supports the TOTP algorithm to handle OTP generation and verification.

Dependencies

  • Express.js: Web framework for building the API endpoints.
  • OTPAuth: Library for generating and validating OTPs using TOTP algorithm.
  • MongoDB: Database used for storing user information and OTP-related data.

Contributing

Contributions are welcome! If you find any issues or improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

2fa_with_authenticator's People

Contributors

splashray avatar

Stargazers

Oluwatobi Aruna avatar Favour Okafor avatar  avatar Timilehin Okunola avatar Wonder Akwei avatar Olawale Afuye  avatar  avatar Joshua Lehman avatar Aliyu Olamide avatar

Watchers

Owolabi Bassit avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.