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.
Before you begin, you should have the following installed on your machine:
- Node.js (v14 or later)
- MongoDB
- Clone this repository to your local machine:
git clone https://github.com/Utkarsh-Technical/Authentication.git
- Install the project dependencies:
npm install
- Start the MongoDB server:
mongod
- Start the application:
npm start
- Open your web browser and navigate to http://localhost:5000/
- "/" - 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.
- 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