Skip to content

This is a simple application that demonstrates how to implement Two-Factor Authentication (2FA) using Node.js, Express.js, and MongoDB. The application uses the Speakeasy library to generate TOTP (Time-based One-Time Password) tokens and QRCode to generate QR codes.

Notifications You must be signed in to change notification settings

Utkarsh-Technical/Two-Factor-Authentication

Repository files navigation

Two-Factor Authentication

This is a simple application that demonstrates how to implement Two-Factor Authentication (2FA) using Node.js, Express.js, and MongoDB. The application uses the Speakeasy library to generate TOTP (Time-based One-Time Password) tokens and QRCode to generate QR codes.

Prerequisites

Before you begin, you should have the following installed on your machine:

  • Node.js (v14 or later)
  • MongoDB

Getting Started

  1. Clone this repository to your local machine:
git clone https://github.com/Utkarsh-Technical/Authentication.git
  1. Install the project dependencies:
npm install
  1. Start the MongoDB server:
mongod
  1. Start the application:
npm start
  1. Open your web browser and navigate to http://localhost:5000/

UsageThe application has three routes:

  • "/" - This is the home page. You can click the "Generate Manual Code" button to generate a secret code that you can manually put with your 2FA app (such as Google Authenticator or Microsoft Authenticator).
  • "/verify" - This is the verification page. After input the secret code with your 2FA app, enter the 6-digit token and click the "Verify" button.

Tech Stack

  • Node.js - an open-source, cross-platform JavaScript runtime environment
  • Express.js - a fast, unopinionated, minimalist web framework for Node.js
  • MongoDB - a document-oriented NoSQL database program
  • Speakeasy - a library for generating Time-based One-Time Password (TOTP) tokens

About

This is a simple application that demonstrates how to implement Two-Factor Authentication (2FA) using Node.js, Express.js, and MongoDB. The application uses the Speakeasy library to generate TOTP (Time-based One-Time Password) tokens and QRCode to generate QR codes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published