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.1.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.1.0
File Size Uploaded Provenance Actions
dash_auth_async-2.1.0.tar.gz 53.2 kB With provenance Details for dash_auth_async-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 107.9 kB

Release files / dash_auth_async-2.1.0.tar.gz

Download URL dash_auth_async-2.1.0.tar.gz
Size 53.2 kB
Tags Source
SHA-256 checksum
How to use checksums
aefa3150eb592575ef299a87b49266a32c14f99d0720dccc2819851a2def9d2b
BLAKE2b-256 checksum
How to use checksums
6977a45b001233327022255143d3d37c83eee2db5e78c49a0e00812fabe87e7a
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 28, 2026.

Transparency log

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

Download URL dash_auth_async-2.1.0-py3-none-any.whl
Size 54.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b74291afc927638fbe31f2f920341a9b805b9ba18f23476c5e79c5f5bed68743
BLAKE2b-256 checksum
How to use checksums
32e0fe41de1ec32c289d4d4aacd38e37bd09f1f0f1062864aaba254bce6776dd
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 28, 2026.

Transparency log

Security for dash-auth-async 2.1.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.1.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 28, 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