Skip to main content

Dash Authorization and Login

Lint Typecheck codecov Ruff ty PyPI Python License

Maintained by joschrag. Forked from plotly/dash-auth with the goal to add support for the new 4.x dash backends.

License: MIT

Feature overview

How this fork compares to upstream dash-auth. The headline difference is async: upstream is Flask-only, while dash-auth-async adds async callback support, the Quart and FastAPI backends, authenticated WebSocket callbacks, and a pluggable backend abstraction.

Capability dash-auth (upstream) dash-auth-async
Flask backend ✅ ✅
Quart backend ❌ ✅
FastAPI backend ❌ ✅
Custom backends ❌ ✅ 1
Protected / public callbacks ✅ ✅
Async callbacks ❌ ✅ 2
Authenticated WebSocket callbacks ❌ ✅ 3
Group-protected background callbacks ❌ ✅ 4
Protected / public streaming callbacks ❌ ✅ 5

✅ supported · ❌ not supported

1 detect_backend resolves Flask/Quart/FastAPI automatically; any other server is supported by supplying your own Backend instance.

2 Supported on every backend, Flask included — you don't need Quart or FastAPI, just the async extra (bundled as dash-auth-async[async], which pulls in dash[async]).

3 Provided by the Quart and FastAPI backends only. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.

4 protected_callback(..., background=True) checks the user's groups when the request arrives — on the start request and every poll — so a denied user gets the fallback output without a job ever being started. The job itself runs in a separate process with no session, which is why the check can't live inside it (upstream checks there, so a background job always sees "no user" and is denied). Needs a background manager, e.g. dash[diskcache]. These callbacks are refused over the WebSocket; Dash only sends background callbacks over HTTP.

5 Dash 4.5+ streaming callbacks (async def callbacks that yield) work with protected_callback and public_callback. Dash consumes a stream outside the request, where no session is readable, so the caller is captured while Dash dispatches the callback and the group check runs with that user when the stream starts — over inline HTTP, the shared-storage downlink and the WebSocket alike. An allowed user receives every chunk; a denied user gets the fallback output as a stream frame. Public streams also reach anonymous visitors when the app uses shared storage. Sync generators are rejected by Dash itself. Logging out with OIDCAuth also stops the protected streams that session started, in every open tab: within about a second the stream sends its unauthenticated_output and ends (WebSocket streams end because logout closes the socket). Sessions ended any other way — expiry, or clearing the session yourself — do not stop running streams.

Installation

Python 3.11+ and Dash 3+ are required.

pip install dash-auth-async                 # Flask + BasicAuth
pip install "dash-auth-async[oidc]"         # + OpenID Connect
pip install "dash-auth-async[quart]"        # + Quart backend
pip install "dash-auth-async[fastapi]"      # + FastAPI backend
pip install "dash-auth-async[async]"        # + async callbacks on Flask

Extras combine, e.g. dash-auth-async[oidc,fastapi].

Quickstart

from dash import Dash
from dash_auth_async import BasicAuth

app = Dash(__name__)  # or backend="quart" / backend="fastapi"
BasicAuth(app, {"username": "password"})

Documentation

Guide Covers
Basic Authentication Username/password dicts and custom auth functions
Public routes add_public_routes, public_callback, multi-page apps
OIDC Authentication OpenID Connect, reverse proxies, multiple providers
Async backends Quart and FastAPI setup, WebSocket callback limitations
User-group-based permissions list_groups, check_groups, protected, protected_callback

Upgrading to 2.0

2.0 changes how the package installs. Code using BasicAuth, OIDCAuth and the group helpers is unchanged.

  1. OIDC users: add the oidc extra — pip install dash-auth-async[oidc] (plus quart/fastapi if you use those backends). Without it, OIDCAuth raises an ImportError naming the extra.
  2. Python 3.11+ and Dash 3+ are now required.
  3. dash_auth_async.version is gone. Read the version from dash_auth_async.__version__.
  4. OIDC refresh tokens are no longer stored in session["refresh_token"] (the cookie is readable by the client). If you need one, capture it in an after_logged_in override and store it server-side — see the CHANGELOG for an example.

See CHANGELOG.md for the full list.

Contributing

See CONTRIBUTING.md.

Metadata

Release files for dash-auth-async 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dash-auth-async 2.0.0
File Size Uploaded Provenance Actions
dash_auth_async-2.0.0.tar.gz 47.4 kB With provenance Details for dash_auth_async-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dash-auth-async 2.0.0
File Interpreter ABI Platform Actions
dash_auth_async-2.0.0-py3-none-any.whl Python 3 none any Details for dash_auth_async-2.0.0-py3-none-any.whl

Total release size: 96.0 kB

Release files / dash_auth_async-2.0.0.tar.gz

Download URL dash_auth_async-2.0.0.tar.gz
Size 47.4 kB
Tags Source
SHA-256 checksum
How to use checksums
642d697b4adf3ba88bd70947dbe0660ca0a6daab7df6da4a97fa337ea56acb2f
BLAKE2b-256 checksum
How to use checksums
d4a1c31bc47e6fe7bf6fe4863920930c5144dbf8b530b8447dfbcefe2ab66319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / dash_auth_async-2.0.0-py3-none-any.whl

Download URL dash_auth_async-2.0.0-py3-none-any.whl
Size 48.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b950e4f02bd1c6cb49a4ad18539974a7bf7f93a81c1f307af3eee7c0a0fef1a
BLAKE2b-256 checksum
How to use checksums
ca429dc318fb20777f23a244883cd063983d540f11072be4debbd8e779acd1b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for dash-auth-async 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dash_auth_async-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page