Skip to content

vinodiOS/two-factor-auth-FastAPI

Repository files navigation

Two Factor Authentication using FastAPI

This repository uses FastAPI for creating webapp and PyOTP Python library is used for generating and verifying one-time passwords.

Installation

Local

git clone https://github.com/vinodiOS/two-factor-auth-FastAPI.git
cd two-factor-auth-FastAPI
virtualenv venv 
source env/bin/activate 
pip install -r requirements.txt
uvicorn main:app --reload

Container with docker

docker-compose up

Steps for setting up Two Factor Authentication

Follow next steps for setting up user account and generate TOTP using Authenticator app.

Signup

Enter the following path to create new user.

http://127.0.0.1:8000/signup/

signup

QR Code Generation

After entering appropriate details new user would be created and page will be navigated to QR Code.

qrcode_scan

Authenticator app setup

Use Google Authenticator or Microsoft Authenticator or any other Authenticator app to scan QR code and generate TOTP.

otp_screenshot

Login

Follow this path to login

http://127.0.0.1:8000/login/

Enter user credentials along with 6 digit TOTP generated by Authenticator app.

login

And, welcome to your website. You have securely logged into your account.

welcome

Please star ✨ repository if you like it. Thank you!