Dockerized Flask Starter App with Two-Factor Auth
This repository is the result of my long search for a simple but versatile route from Python code to a presentable HTTPS web app that lives on a custom domain.
The web app has a private section for authenticated users. I work in biotech and healthcare sectors, where two-factor authentication is a common requirement. Here you have what’s in my view is the least annoying flavor of 2FA: TOTP tokens. To register, you scan a QR code with a free app like Google Authenticator. The app generates tokens that expire every 30 seconds.
Here are the main features:
Note: At the time of writing (September 2020), standard Docker Desktop did not have the docker ecs
feature and Docker Desktop Edge (2.3.3.0) was required. You can use regular edition now: https://docs.docker.com/engine/context/ecs-integration/
git clone https://github.com/liquidcarbon/dockerflask2fa.git && cd dockerflask2fa
docker-compose up
http://localhost:5000
in your address bar to connect to the application. Unless you crash the app, the changes you will make to the application will automagically appear in your browser (hot reloading).Update Oct 21, 2020: these instructions will no longer work because Docker disabled docker ecs
feature in favor of docker context
: https://docs.docker.com/engine/context/ecs-integration/
Costs: about $1 / day (ELB + ECS)
Follow the steps below or the instructions in docker-ecs repo.
docker ecs setup
and set context to aws
docker context use aws
(to revert to local, say docker context use default
)docker ecs compose up
(takes a few minutes)docker ecs compose ps
- looks like this Dockerflask2faLoadBalancer-67be8e87ec9268e4.elb.us-east-1.amazonaws.com:5000