dash-auth-async 1.3.1__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.
Files changed (22) hide show
  1. {dash_auth_async-1.3.1/dash_auth_async.egg-info → dash_auth_async-1.3.2}/PKG-INFO +7 -7
  2. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/README.md +5 -5
  3. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/auth.py +1 -1
  4. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/basic_auth.py +7 -3
  5. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/public_routes.py +14 -10
  6. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/version.py +1 -1
  7. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2/dash_auth_async.egg-info}/PKG-INFO +7 -7
  8. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/requires.txt +1 -1
  9. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/pyproject.toml +2 -9
  10. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/LICENSE +0 -0
  11. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/MANIFEST.in +0 -0
  12. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/__init__.py +0 -0
  13. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/_optional.py +0 -0
  14. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/backends.py +0 -0
  15. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/group_protection.py +0 -0
  16. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/oidc_auth.py +0 -0
  17. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/quart_client.py +0 -0
  18. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async/websocket_auth.py +0 -0
  19. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/SOURCES.txt +0 -0
  20. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/dependency_links.txt +0 -0
  21. {dash_auth_async-1.3.1 → dash_auth_async-1.3.2}/dash_auth_async.egg-info/top_level.txt +0 -0
  22. {dash_auth_async-1.3.1 → 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.1
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]>=4.2.0; extra == "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 backend and everything that rides on it (async callbacks, authenticated WebSocket callbacks) plus a pluggable backend abstraction.
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> Provided by the Quart and FastAPI backends.
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 Flask server
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={"user1": ["group1", "group2"], "user2": ["group2"]},
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 backend and everything that rides on it (async callbacks, authenticated WebSocket callbacks) plus a pluggable backend abstraction.
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> Provided by the Quart and FastAPI backends.
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 Flask server
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={"user1": ["group1", "group2"], "user2": ["group2"]},
452
+ user_groups={"username": ["group1", "group2"], "user2": ["group2"]},
453
453
  secret_key="Test!",
454
454
  )
455
455
 
@@ -113,7 +113,7 @@ class Auth(ABC):
113
113
  pathname = next(
114
114
  (
115
115
  inp.get("value")
116
- for inp in body["inputs"]
116
+ for inp in body.get("inputs", [])
117
117
  if isinstance(inp, dict) and inp.get("property") == "pathname"
118
118
  ),
119
119
  None,
@@ -119,9 +119,13 @@ class BasicAuth(Auth):
119
119
  return False
120
120
  else:
121
121
  stored_password = self._users.get(username)
122
- if stored_password is None:
123
- return authorized
124
- authorized = hmac.compare_digest(stored_password, password)
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
- # GLOBAL_CALLBACK_MAP is a Dash internal with no public API equivalent.
9
- from dash._callback import GLOBAL_CALLBACK_MAP # noqa: PLC2701
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
- callback_id = next(
103
- (
104
- k
105
- for k, v in GLOBAL_CALLBACK_MAP.items()
106
- if inspect.getsource(v["callback"]) == inspect.getsource(func)
107
- ),
108
- None,
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,3 +1,3 @@
1
1
  """Single source of truth for the package version."""
2
2
 
3
- __version__ = "1.3.1"
3
+ __version__ = "1.3.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dash-auth-async
3
- Version: 1.3.1
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]>=4.2.0; extra == "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 backend and everything that rides on it (async callbacks, authenticated WebSocket callbacks) plus a pluggable backend abstraction.
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> Provided by the Quart and FastAPI backends.
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 Flask server
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={"user1": ["group1", "group2"], "user2": ["group2"]},
497
+ user_groups={"username": ["group1", "group2"], "user2": ["group2"]},
498
498
  secret_key="Test!",
499
499
  )
500
500
 
@@ -4,7 +4,7 @@ werkzeug>=3.1.8
4
4
  dash>=2
5
5
 
6
6
  [async]
7
- dash[async]>=4.2.0
7
+ dash[async]>=3.1.0
8
8
 
9
9
  [fastapi]
10
10
  dash[fastapi]>=4.2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dash-auth-async"
7
- version = "1.3.1"
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]>=4.2.0"]
48
+ async = ["dash[async]>=3.1.0"]
49
49
 
50
50
  [project.urls]
51
51
  Homepage = "https://github.com/joschrag/dash-auth-async"
@@ -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