russellromney / dash-auth-flow

Batteries-included authentication flow with Dash.
https://dash-auth-flow.fly.dev
MIT License
78 stars 14 forks source link

dash-auth-flow

Batteries-included authentication flow in Dash with Dash Pages.

This has landing pages and functions to run the entire authentication flow:

This uses flask-login on the backend, taking some inspiration from the very useful dash-flask-login. Data is held in users.db.

The .env File

The provided .env.example is just an example. Copy that file to a .env file and fill in the details. It's set up this way so you don't accidentally expose your credentials in git. The app won't run correctly if .env doesn't have the required values filled out.

Run Locally

# with plain virtualenv
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python create_tables.py
python app.py

# with pipenv
pip install pipenv
pipenv install --ignore-pipfile
pipenv python create_tables.py
pipenv run python app.py

# with poetry
pip install poetry
poetry run python create_tables.py
poetry run python app.py

# either: deactivate virtual environment
deactivate

Notes:

Deploying to fly.io or Heroku

I've provided a Procfile for Heroku, there are many resources for Heroku deployment.

My preferred host is Fly.io. I've included a Dockerfile, .dockerignore, and fly.toml for an example.

# first time
fly launch

# after any change, deploy an updated version with
fly deploy