👋This guides how to implement two-factor authentication in Django & DRF using Authenticator Apps
Complete guide Medium
- Django & DRF : for building the APIs
- Docker & Docker compose: Containerization
- PostgreSQL: Relational DB
- Understand how Two-Factor Authentication (2FA) works.
- Onboard a user on the system
- Generate a QR code for the user
- Enable users to make a login attempt using valid credentials, such as their email and password.
- Authenticate the user using an offline OTP generated by an Authenticator App.
Create a .env file by copying the .env.sample provided and run:
docker compose build && docker compose up
to start the container. As an alternative, run:
docker-compose -f docker-compose.dev.yml up --build
to build and run the container using the dev yaml file. Make sure to externalize the db instance to be used. It can be in another container.
Run descriptive tests in the container using:
docker compose exec <docker_container_name> pytest -rP -vv
Access the docs on:
http://localhost:8000/api/v1/doc