Show and Tell: full authentication flow example, dash-auth-flow

Major update - Dash Pages and granular layout authentication

@all, I’ve launched a major upgrade and update to dash-auth-flow. Most of the changes are updates which bring dash-auth-flow into the Dash 2.0+ era - Dash Pages, consolidated imports, etc. It also adds a guide for running locally and deploying to Fly.io, a proper .env file structure, and smooth transitions between login and logout.

Each layout function can be explicitly unprotected by adding the @unprotected decorator to the layout function. All layout functions are protected by default.

from utils.auth import protect_layouts

app = Dash(__name__,...)
protect_layouts(default=True) # require authentication on all pages layouts by default

...
import dash
from utils.auth import unprotected

dash.register_page(__name__, path="/unprotected")

@unprotected
def layout():
    """This layout function will be accessible to unauthenticated users."""
    return html.Div("Page Content")

I think this update will make dash-auth-flow much more useful and accessible for all Dash users, as Dash pages is a significant improvement over previous routing designs.

The example is deployed and moved from Heroku to Fly.io; check it out at https://dash-auth-flow.fly.dev

See the updated code at GitHub - russellromney/dash-auth-flow: Batteries-included authentication flow with Dash.

In a future update, I’m going to add MFA via TOTP authenticator apps (Google Authenticator, Authy) and SMS (with an SMS provider), and add a system for arbitrary email/sms providers. Let me know if these updates will be of interest to you and if you’d like to sponsor that development.

6 Likes