dash-auth-async 1.3.0__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dash_auth_async-1.3.0/dash_auth_async.egg-info → dash_auth_async-1.3.2}/PKG-INFO +7 -7
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/README.md +5 -5
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/auth.py +1 -1
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/backends.py +49 -1
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/basic_auth.py +7 -3
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/public_routes.py +14 -10
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/version.py +1 -1
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2/dash_auth_async.egg-info}/PKG-INFO +7 -7
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/requires.txt +1 -1
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/pyproject.toml +4 -11
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/LICENSE +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/MANIFEST.in +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/__init__.py +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/_optional.py +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/group_protection.py +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/oidc_auth.py +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/quart_client.py +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async/websocket_auth.py +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/SOURCES.txt +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/dependency_links.txt +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/top_level.txt +0 -0
- {dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dash-auth-async
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Dash Authorization Package.
|
|
5
5
|
Author-email: Jonas Schrage <119843859+joschrag@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -40,7 +40,7 @@ Provides-Extra: quart
|
|
|
40
40
|
Requires-Dist: dash[quart]>=4.2.0; extra == "quart"
|
|
41
41
|
Requires-Dist: httpx>=0.23.0; extra == "quart"
|
|
42
42
|
Provides-Extra: async
|
|
43
|
-
Requires-Dist: dash[async]>=
|
|
43
|
+
Requires-Dist: dash[async]>=3.1.0; extra == "async"
|
|
44
44
|
Dynamic: license-file
|
|
45
45
|
|
|
46
46
|
## Dash Authorization and Login
|
|
@@ -60,7 +60,7 @@ License: MIT
|
|
|
60
60
|
|
|
61
61
|
## Feature overview
|
|
62
62
|
|
|
63
|
-
How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-auth). The headline difference is async: upstream is Flask-only, while `dash-auth-async` adds the Quart
|
|
63
|
+
How this fork compares to upstream [`dash-auth`](https://github.com/plotly/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.
|
|
64
64
|
|
|
65
65
|
| Capability | `dash-auth` (upstream) | `dash-auth-async` |
|
|
66
66
|
| --- | :---: | :---: |
|
|
@@ -76,9 +76,9 @@ How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-
|
|
|
76
76
|
|
|
77
77
|
<sup>1</sup> `detect_backend` resolves Flask/Quart/FastAPI automatically; any other server is supported by supplying your own `Backend` instance.
|
|
78
78
|
|
|
79
|
-
<sup>2</sup>
|
|
79
|
+
<sup>2</sup> 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]`).
|
|
80
80
|
|
|
81
|
-
<sup>3</sup> Provided by the Quart and FastAPI backends. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
81
|
+
<sup>3</sup> Provided by the Quart and FastAPI backends only. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
For local testing, install [uv](https://docs.astral.sh/uv/getting-started/installation/), then install the dev dependencies and run individual tests:
|
|
@@ -477,7 +477,7 @@ The following utilities are defined:
|
|
|
477
477
|
* `protected_callback`: A callback that only runs if the user is authenticated
|
|
478
478
|
and with the right group permissions.
|
|
479
479
|
|
|
480
|
-
NOTE: user info is stored in the session so make sure you define a secret_key on the
|
|
480
|
+
NOTE: user info is stored in the session so make sure you define a secret_key on the server
|
|
481
481
|
to use this feature.
|
|
482
482
|
|
|
483
483
|
If you wish to use this feature with BasicAuth, you will need to define the groups for individual
|
|
@@ -494,7 +494,7 @@ USER_PWD = {
|
|
|
494
494
|
BasicAuth(
|
|
495
495
|
app,
|
|
496
496
|
USER_PWD,
|
|
497
|
-
user_groups={"
|
|
497
|
+
user_groups={"username": ["group1", "group2"], "user2": ["group2"]},
|
|
498
498
|
secret_key="Test!",
|
|
499
499
|
)
|
|
500
500
|
|
|
@@ -15,7 +15,7 @@ License: MIT
|
|
|
15
15
|
|
|
16
16
|
## Feature overview
|
|
17
17
|
|
|
18
|
-
How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-auth). The headline difference is async: upstream is Flask-only, while `dash-auth-async` adds the Quart
|
|
18
|
+
How this fork compares to upstream [`dash-auth`](https://github.com/plotly/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.
|
|
19
19
|
|
|
20
20
|
| Capability | `dash-auth` (upstream) | `dash-auth-async` |
|
|
21
21
|
| --- | :---: | :---: |
|
|
@@ -31,9 +31,9 @@ How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-
|
|
|
31
31
|
|
|
32
32
|
<sup>1</sup> `detect_backend` resolves Flask/Quart/FastAPI automatically; any other server is supported by supplying your own `Backend` instance.
|
|
33
33
|
|
|
34
|
-
<sup>2</sup>
|
|
34
|
+
<sup>2</sup> 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]`).
|
|
35
35
|
|
|
36
|
-
<sup>3</sup> Provided by the Quart and FastAPI backends. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
36
|
+
<sup>3</sup> Provided by the Quart and FastAPI backends only. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
For local testing, install [uv](https://docs.astral.sh/uv/getting-started/installation/), then install the dev dependencies and run individual tests:
|
|
@@ -432,7 +432,7 @@ The following utilities are defined:
|
|
|
432
432
|
* `protected_callback`: A callback that only runs if the user is authenticated
|
|
433
433
|
and with the right group permissions.
|
|
434
434
|
|
|
435
|
-
NOTE: user info is stored in the session so make sure you define a secret_key on the
|
|
435
|
+
NOTE: user info is stored in the session so make sure you define a secret_key on the server
|
|
436
436
|
to use this feature.
|
|
437
437
|
|
|
438
438
|
If you wish to use this feature with BasicAuth, you will need to define the groups for individual
|
|
@@ -449,7 +449,7 @@ USER_PWD = {
|
|
|
449
449
|
BasicAuth(
|
|
450
450
|
app,
|
|
451
451
|
USER_PWD,
|
|
452
|
-
user_groups={"
|
|
452
|
+
user_groups={"username": ["group1", "group2"], "user2": ["group2"]},
|
|
453
453
|
secret_key="Test!",
|
|
454
454
|
)
|
|
455
455
|
|
|
@@ -43,6 +43,47 @@ except ImportError:
|
|
|
43
43
|
_current_request_var: ContextVar = ContextVar("dash_auth_request", default=None)
|
|
44
44
|
|
|
45
45
|
|
|
46
|
+
def _set_dash_request(request: Any) -> Any:
|
|
47
|
+
"""Populate Dash's FastAPI request ContextVar for the downstream call.
|
|
48
|
+
|
|
49
|
+
Dash 4.3.0's ``DashMiddleware`` added a "pass-through to avoid consuming
|
|
50
|
+
body stream" branch that returns *before* ``set_current_request`` for any
|
|
51
|
+
non-``_dash-`` page route. Its catch-all then serves those routes via
|
|
52
|
+
``index()`` -> ``get_current_request()``, which raises "No active request
|
|
53
|
+
in context" (a regression that breaks vanilla FastAPI page routes too).
|
|
54
|
+
|
|
55
|
+
Our ``_AuthMiddleware`` runs *outside* ``DashMiddleware`` and already holds
|
|
56
|
+
the request, so we set Dash's ContextVar ourselves and backfill the routes
|
|
57
|
+
Dash abandoned. For routes Dash still handles, its own set/reset nests
|
|
58
|
+
cleanly inside ours (ContextVar tokens are LIFO).
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
A reset token to pass to :func:`_reset_dash_request`, or ``None`` if
|
|
62
|
+
this Dash exposes no such helper (then it's a no-op).
|
|
63
|
+
"""
|
|
64
|
+
try:
|
|
65
|
+
from dash.backends._fastapi import ( # noqa: PLC0415, PLC2701 — lazy import of a Dash internal
|
|
66
|
+
set_current_request,
|
|
67
|
+
)
|
|
68
|
+
except ImportError:
|
|
69
|
+
return None
|
|
70
|
+
return set_current_request(request)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _reset_dash_request(token: Any) -> None:
|
|
74
|
+
"""Reset the Dash request ContextVar set by :func:`_set_dash_request`.
|
|
75
|
+
|
|
76
|
+
No-op when ``token`` is ``None`` (the helper was unavailable).
|
|
77
|
+
"""
|
|
78
|
+
if token is None:
|
|
79
|
+
return
|
|
80
|
+
from dash.backends._fastapi import ( # noqa: PLC0415, PLC2701 — lazy import of a Dash internal
|
|
81
|
+
reset_current_request,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
reset_current_request(token)
|
|
85
|
+
|
|
86
|
+
|
|
46
87
|
class Backend(ABC):
|
|
47
88
|
"""Framework adapter isolating everything Flask/Quart-specific.
|
|
48
89
|
|
|
@@ -815,7 +856,14 @@ class FastAPIBackend(Backend):
|
|
|
815
856
|
if logged_in:
|
|
816
857
|
close_anonymous_ws(client_id)
|
|
817
858
|
|
|
818
|
-
|
|
859
|
+
# Backfill Dash's request ContextVar so the catch-all's
|
|
860
|
+
# index() works on Dash 4.3.0, which skips it for page
|
|
861
|
+
# routes (see _set_dash_request).
|
|
862
|
+
dash_token = _set_dash_request(request)
|
|
863
|
+
try:
|
|
864
|
+
await self.app(scope, downstream_receive, send)
|
|
865
|
+
finally:
|
|
866
|
+
_reset_dash_request(dash_token)
|
|
819
867
|
finally:
|
|
820
868
|
_current_request_var.reset(token)
|
|
821
869
|
|
|
@@ -119,9 +119,13 @@ class BasicAuth(Auth):
|
|
|
119
119
|
return False
|
|
120
120
|
else:
|
|
121
121
|
stored_password = self._users.get(username)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
# Run a constant-time comparison even when the username is unknown
|
|
123
|
+
# (compare `password` against itself, then discard the result) so
|
|
124
|
+
# response timing doesn't reveal which usernames exist.
|
|
125
|
+
reference = stored_password if stored_password is not None else password
|
|
126
|
+
authorized = hmac.compare_digest(reference, password) and (
|
|
127
|
+
stored_password is not None
|
|
128
|
+
)
|
|
125
129
|
if authorized:
|
|
126
130
|
try:
|
|
127
131
|
self.session["user"] = {"email": username, "groups": []}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"""Public route and callback registration for unauthenticated access."""
|
|
2
2
|
|
|
3
|
-
import inspect
|
|
4
3
|
import os
|
|
5
4
|
|
|
6
5
|
from dash import Dash, callback, get_app
|
|
7
6
|
|
|
8
|
-
#
|
|
9
|
-
|
|
7
|
+
# create_callback_id is the same helper Dash uses internally to key its
|
|
8
|
+
# callback map; no public API equivalent exists.
|
|
9
|
+
from dash._utils import create_callback_id # noqa: PLC2701
|
|
10
|
+
from dash.dependencies import handle_callback_args
|
|
10
11
|
from werkzeug.routing import Map, MapAdapter, Rule
|
|
11
12
|
|
|
12
13
|
from .backends import detect_backend
|
|
@@ -99,14 +100,17 @@ def public_callback(*callback_args, **callback_kwargs):
|
|
|
99
100
|
|
|
100
101
|
def decorator(func):
|
|
101
102
|
wrapped_func = callback(*callback_args, **callback_kwargs)(func)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
# Derive the callback id straight from the output specs, exactly as
|
|
104
|
+
# Dash does internally (create_callback_id). This is deterministic and
|
|
105
|
+
# independent of GLOBAL_CALLBACK_MAP state -- unlike diffing the map,
|
|
106
|
+
# which yields no new key when the same output id was already
|
|
107
|
+
# registered (re-runs, or several apps sharing one process), and unlike
|
|
108
|
+
# source-text comparison, which mis-whitelists callbacks sharing a body
|
|
109
|
+
# and raises on lambdas/REPL-defined functions.
|
|
110
|
+
output, inputs, _state, _prevent = handle_callback_args(
|
|
111
|
+
callback_args, callback_kwargs
|
|
109
112
|
)
|
|
113
|
+
callback_id = create_callback_id(output, inputs, no_output=not output)
|
|
110
114
|
try:
|
|
111
115
|
app = get_app()
|
|
112
116
|
backend = detect_backend(app.server)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dash-auth-async
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Dash Authorization Package.
|
|
5
5
|
Author-email: Jonas Schrage <119843859+joschrag@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -40,7 +40,7 @@ Provides-Extra: quart
|
|
|
40
40
|
Requires-Dist: dash[quart]>=4.2.0; extra == "quart"
|
|
41
41
|
Requires-Dist: httpx>=0.23.0; extra == "quart"
|
|
42
42
|
Provides-Extra: async
|
|
43
|
-
Requires-Dist: dash[async]>=
|
|
43
|
+
Requires-Dist: dash[async]>=3.1.0; extra == "async"
|
|
44
44
|
Dynamic: license-file
|
|
45
45
|
|
|
46
46
|
## Dash Authorization and Login
|
|
@@ -60,7 +60,7 @@ License: MIT
|
|
|
60
60
|
|
|
61
61
|
## Feature overview
|
|
62
62
|
|
|
63
|
-
How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-auth). The headline difference is async: upstream is Flask-only, while `dash-auth-async` adds the Quart
|
|
63
|
+
How this fork compares to upstream [`dash-auth`](https://github.com/plotly/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.
|
|
64
64
|
|
|
65
65
|
| Capability | `dash-auth` (upstream) | `dash-auth-async` |
|
|
66
66
|
| --- | :---: | :---: |
|
|
@@ -76,9 +76,9 @@ How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-
|
|
|
76
76
|
|
|
77
77
|
<sup>1</sup> `detect_backend` resolves Flask/Quart/FastAPI automatically; any other server is supported by supplying your own `Backend` instance.
|
|
78
78
|
|
|
79
|
-
<sup>2</sup>
|
|
79
|
+
<sup>2</sup> 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]`).
|
|
80
80
|
|
|
81
|
-
<sup>3</sup> Provided by the Quart and FastAPI backends. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
81
|
+
<sup>3</sup> Provided by the Quart and FastAPI backends only. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
For local testing, install [uv](https://docs.astral.sh/uv/getting-started/installation/), then install the dev dependencies and run individual tests:
|
|
@@ -477,7 +477,7 @@ The following utilities are defined:
|
|
|
477
477
|
* `protected_callback`: A callback that only runs if the user is authenticated
|
|
478
478
|
and with the right group permissions.
|
|
479
479
|
|
|
480
|
-
NOTE: user info is stored in the session so make sure you define a secret_key on the
|
|
480
|
+
NOTE: user info is stored in the session so make sure you define a secret_key on the server
|
|
481
481
|
to use this feature.
|
|
482
482
|
|
|
483
483
|
If you wish to use this feature with BasicAuth, you will need to define the groups for individual
|
|
@@ -494,7 +494,7 @@ USER_PWD = {
|
|
|
494
494
|
BasicAuth(
|
|
495
495
|
app,
|
|
496
496
|
USER_PWD,
|
|
497
|
-
user_groups={"
|
|
497
|
+
user_groups={"username": ["group1", "group2"], "user2": ["group2"]},
|
|
498
498
|
secret_key="Test!",
|
|
499
499
|
)
|
|
500
500
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dash-auth-async"
|
|
7
|
-
version = "1.3.
|
|
7
|
+
version = "1.3.2"
|
|
8
8
|
description = "Dash Authorization Package."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -45,7 +45,7 @@ dependencies = [
|
|
|
45
45
|
[project.optional-dependencies]
|
|
46
46
|
fastapi = ["dash[fastapi]>=4.2.0"]
|
|
47
47
|
quart = ["dash[quart]>=4.2.0","httpx>=0.23.0"]
|
|
48
|
-
async = ["dash[async]>=
|
|
48
|
+
async = ["dash[async]>=3.1.0"]
|
|
49
49
|
|
|
50
50
|
[project.urls]
|
|
51
51
|
Homepage = "https://github.com/joschrag/dash-auth-async"
|
|
@@ -60,10 +60,10 @@ dev = [
|
|
|
60
60
|
"creosote>=5.2.0",
|
|
61
61
|
"dash[testing]>=4.2.0",
|
|
62
62
|
"setuptools>=79.0.1",
|
|
63
|
-
"ty
|
|
63
|
+
"ty==0.0.51",
|
|
64
64
|
"pre-commit>=3.5.0",
|
|
65
65
|
"pytest>=8.3.5",
|
|
66
|
-
"ruff
|
|
66
|
+
"ruff==0.15.18",
|
|
67
67
|
"pytest-cov>=7.1.0",
|
|
68
68
|
"websocket-client>=1.9.0",
|
|
69
69
|
"requests[security]>=2.34.2",
|
|
@@ -102,13 +102,6 @@ preview = true
|
|
|
102
102
|
select = ["FAST","I","D","DOC","PL","UP","PERF","RUF"]
|
|
103
103
|
|
|
104
104
|
[tool.ruff.lint.per-file-ignores]
|
|
105
|
-
# Examples are runnable demos, not shipped library code (setuptools only
|
|
106
|
-
# packages dash_auth_async*). Like tests, they read better without forced
|
|
107
|
-
# docstring coverage on every demo page/callback.
|
|
108
|
-
"examples/**" = [
|
|
109
|
-
"D", # demo scripts don't need module/function docstrings
|
|
110
|
-
"DOC", # ...nor docstring sections (Returns, etc.)
|
|
111
|
-
]
|
|
112
105
|
# Tests are self-describing and have different idioms than library code:
|
|
113
106
|
"tests/**" = [
|
|
114
107
|
"D", # don't require docstrings on every test/fixture/module
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dash_auth_async-1.3.0 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|