dash-auth-async 1.3.4__tar.gz → 1.3.6__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.4/dash_auth_async.egg-info → dash_auth_async-1.3.6}/PKG-INFO +2 -2
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/auth.py +52 -25
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/backends.py +21 -6
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/basic_auth.py +4 -3
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/oidc_auth.py +11 -4
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/version.py +1 -1
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/websocket_auth.py +83 -23
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6/dash_auth_async.egg-info}/PKG-INFO +2 -2
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async.egg-info/requires.txt +1 -1
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/pyproject.toml +6 -4
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/LICENSE +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/MANIFEST.in +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/README.md +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/__init__.py +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/_optional.py +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/group_protection.py +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/public_routes.py +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async/quart_client.py +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async.egg-info/SOURCES.txt +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async.egg-info/dependency_links.txt +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/dash_auth_async.egg-info/top_level.txt +0 -0
- {dash_auth_async-1.3.4 → dash_auth_async-1.3.6}/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.6
|
|
4
4
|
Summary: Dash Authorization Package.
|
|
5
5
|
Author-email: Jonas Schrage <119843859+joschrag@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -30,7 +30,7 @@ Classifier: Topic :: Software Development :: Widget Sets
|
|
|
30
30
|
Requires-Python: >=3.10
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
License-File: LICENSE
|
|
33
|
-
Requires-Dist: authlib>=1.
|
|
33
|
+
Requires-Dist: authlib>=1.9.1
|
|
34
34
|
Requires-Dist: flask>=3.1.3
|
|
35
35
|
Requires-Dist: werkzeug>=3.1.8
|
|
36
36
|
Requires-Dist: dash>=2
|
|
@@ -4,6 +4,9 @@ from abc import ABC, abstractmethod
|
|
|
4
4
|
|
|
5
5
|
from dash import Dash
|
|
6
6
|
|
|
7
|
+
# Dash's pre-setup callback registry; no public API equivalent exists.
|
|
8
|
+
from dash._callback import GLOBAL_CALLBACK_MAP # noqa: PLC2701
|
|
9
|
+
|
|
7
10
|
from .backends import Backend, detect_backend, set_active_backend
|
|
8
11
|
from .public_routes import (
|
|
9
12
|
add_public_routes,
|
|
@@ -98,27 +101,19 @@ class Auth(ABC):
|
|
|
98
101
|
public_routes = get_public_routes(self.app)
|
|
99
102
|
public_callbacks = get_public_callbacks(self.app)
|
|
100
103
|
if path == self._callback_path():
|
|
101
|
-
# Treat a missing or
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
+
# Treat a missing, unparseable or non-object body (valid JSON
|
|
105
|
+
# that is a list/string/number) as unauthorised rather than
|
|
106
|
+
# crashing with AttributeError/KeyError → 500.
|
|
107
|
+
if not body or not isinstance(body, dict):
|
|
104
108
|
return self.login_request()
|
|
105
109
|
|
|
106
110
|
# Check whether the callback is marked as public
|
|
107
111
|
if body.get("output") in public_callbacks:
|
|
108
112
|
return None
|
|
109
113
|
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
pathname = next(
|
|
114
|
-
(
|
|
115
|
-
inp.get("value")
|
|
116
|
-
for inp in body.get("inputs", [])
|
|
117
|
-
if isinstance(inp, dict) and inp.get("property") == "pathname"
|
|
118
|
-
),
|
|
119
|
-
None,
|
|
120
|
-
)
|
|
121
|
-
if pathname and public_routes.test(pathname):
|
|
114
|
+
# A routing callback (one registered with a pathname input) is
|
|
115
|
+
# public when that pathname hits a public route
|
|
116
|
+
if self._is_public_routing_callback(body):
|
|
122
117
|
return None
|
|
123
118
|
|
|
124
119
|
# If the route is not a callback route, check whether the path
|
|
@@ -149,20 +144,52 @@ class Auth(ABC):
|
|
|
149
144
|
if payload.get("output") in public_callbacks:
|
|
150
145
|
return True
|
|
151
146
|
|
|
152
|
-
|
|
153
|
-
pathname = next(
|
|
154
|
-
(
|
|
155
|
-
inp.get("value")
|
|
156
|
-
for inp in payload.get("inputs", [])
|
|
157
|
-
if isinstance(inp, dict) and inp.get("property") == "pathname"
|
|
158
|
-
),
|
|
159
|
-
None,
|
|
160
|
-
)
|
|
161
|
-
if pathname and public_routes.test(pathname):
|
|
147
|
+
if self._is_public_routing_callback(payload):
|
|
162
148
|
return True
|
|
163
149
|
|
|
164
150
|
return user is not None
|
|
165
151
|
|
|
152
|
+
def _is_public_routing_callback(self, body: dict) -> bool:
|
|
153
|
+
"""Whether ``body`` invokes a routing callback on a public pathname.
|
|
154
|
+
|
|
155
|
+
Which arguments are pathnames is read from the *registered* callback,
|
|
156
|
+
never from the request: the body's own ``property`` labels are
|
|
157
|
+
client-controlled, and Dash only validates the argument count. Trusting
|
|
158
|
+
them let any callback be invoked unauthenticated by relabelling one
|
|
159
|
+
input as ``pathname`` with a public-route value.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
True if the callback declares pathname inputs and every value the
|
|
163
|
+
request supplies for them matches a public route.
|
|
164
|
+
"""
|
|
165
|
+
output = body.get("output")
|
|
166
|
+
if not isinstance(output, str):
|
|
167
|
+
return False
|
|
168
|
+
# Callbacks sit in Dash's global map until its first-request setup
|
|
169
|
+
# migrates them onto the app, which may not have run yet.
|
|
170
|
+
spec = self.app.callback_map.get(output) or GLOBAL_CALLBACK_MAP.get(output)
|
|
171
|
+
if not spec:
|
|
172
|
+
return False
|
|
173
|
+
|
|
174
|
+
# Dash builds the callback arguments positionally from inputs + state,
|
|
175
|
+
# so index the same flat list to see exactly what the callback receives.
|
|
176
|
+
inputs, state = body.get("inputs"), body.get("state")
|
|
177
|
+
args = [
|
|
178
|
+
*(inputs if isinstance(inputs, list) else []),
|
|
179
|
+
*(state if isinstance(state, list) else []),
|
|
180
|
+
]
|
|
181
|
+
pathnames = [
|
|
182
|
+
args[i].get("value")
|
|
183
|
+
if i < len(args) and isinstance(args[i], dict)
|
|
184
|
+
else None
|
|
185
|
+
for i, dep in enumerate(spec["inputs"])
|
|
186
|
+
if dep.get("property") == "pathname"
|
|
187
|
+
]
|
|
188
|
+
public_routes = get_public_routes(self.app)
|
|
189
|
+
return bool(pathnames) and all(
|
|
190
|
+
isinstance(p, str) and p and public_routes.test(p) for p in pathnames
|
|
191
|
+
)
|
|
192
|
+
|
|
166
193
|
@abstractmethod
|
|
167
194
|
def is_authorized(self):
|
|
168
195
|
"""Return whether the current request is authenticated."""
|
|
@@ -632,12 +632,19 @@ class FastAPIBackend(Backend):
|
|
|
632
632
|
return PlainTextResponse(str(result))
|
|
633
633
|
|
|
634
634
|
@staticmethod
|
|
635
|
-
def
|
|
636
|
-
return
|
|
637
|
-
|
|
638
|
-
|
|
635
|
+
def _session_middleware(server) -> Any:
|
|
636
|
+
return next(
|
|
637
|
+
(
|
|
638
|
+
m
|
|
639
|
+
for m in getattr(server, "user_middleware", [])
|
|
640
|
+
if getattr(m, "cls", None) is SessionMiddleware
|
|
641
|
+
),
|
|
642
|
+
None,
|
|
639
643
|
)
|
|
640
644
|
|
|
645
|
+
def _has_session_middleware(self, server) -> bool:
|
|
646
|
+
return self._session_middleware(server) is not None
|
|
647
|
+
|
|
641
648
|
def setup_session(
|
|
642
649
|
self, server, secret_key: str | None, secure_session: bool = False
|
|
643
650
|
) -> None:
|
|
@@ -648,10 +655,18 @@ class FastAPIBackend(Backend):
|
|
|
648
655
|
silently dropped. Starlette always sets ``HttpOnly``. Defers to a
|
|
649
656
|
user-installed ``SessionMiddleware`` (opt-out/override) and is
|
|
650
657
|
idempotent — never adds a second instance.
|
|
658
|
+
|
|
659
|
+
Either way the session middleware ends up *outermost*: the auth
|
|
660
|
+
middleware reads ``request.session``, so one the user installed before
|
|
661
|
+
``Auth(...)`` (which would sit inside the auth middleware, leaving the
|
|
662
|
+
session unreadable there) is hoisted to the front of the stack.
|
|
651
663
|
"""
|
|
652
|
-
|
|
664
|
+
existing = self._session_middleware(server)
|
|
665
|
+
if existing is not None:
|
|
666
|
+
server.user_middleware.remove(existing)
|
|
667
|
+
server.user_middleware.insert(0, existing)
|
|
653
668
|
return
|
|
654
|
-
if
|
|
669
|
+
if secret_key is None:
|
|
655
670
|
return
|
|
656
671
|
server.add_middleware(
|
|
657
672
|
SessionMiddleware, secret_key=secret_key, https_only=secure_session
|
|
@@ -123,9 +123,10 @@ class BasicAuth(Auth):
|
|
|
123
123
|
# (compare `password` against itself, then discard the result) so
|
|
124
124
|
# response timing doesn't reveal which usernames exist.
|
|
125
125
|
reference = stored_password if stored_password is not None else password
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
# Compare bytes: compare_digest raises TypeError on non-ASCII str.
|
|
127
|
+
authorized = hmac.compare_digest(
|
|
128
|
+
reference.encode("utf-8"), password.encode("utf-8")
|
|
129
|
+
) and (stored_password is not None)
|
|
129
130
|
if authorized:
|
|
130
131
|
try:
|
|
131
132
|
self.session["user"] = {"email": username, "groups": []}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
import os
|
|
5
5
|
import re
|
|
6
|
+
from html import escape
|
|
6
7
|
from typing import TYPE_CHECKING
|
|
7
8
|
|
|
8
9
|
import dash
|
|
@@ -15,6 +16,7 @@ from dash_auth_async.auth import Auth
|
|
|
15
16
|
from dash_auth_async.public_routes import get_url_base
|
|
16
17
|
|
|
17
18
|
from .backends import detect_backend
|
|
19
|
+
from .websocket_auth import WS_CLIENT_COOKIE, close_authenticated_ws
|
|
18
20
|
|
|
19
21
|
if TYPE_CHECKING:
|
|
20
22
|
from authlib.integrations.flask_client.apps import (
|
|
@@ -323,6 +325,9 @@ class OIDCAuth(Auth):
|
|
|
323
325
|
Returns:
|
|
324
326
|
The logged-out page content.
|
|
325
327
|
"""
|
|
328
|
+
# The open socket's user is a handshake-time snapshot the cleared
|
|
329
|
+
# session can't reach: retire it so the logout applies there too.
|
|
330
|
+
close_authenticated_ws(self.request.cookies.get(WS_CLIENT_COOKIE))
|
|
326
331
|
self.session.clear()
|
|
327
332
|
base_url = get_url_base(self.app) or "/"
|
|
328
333
|
page = (
|
|
@@ -354,8 +359,10 @@ class OIDCAuth(Auth):
|
|
|
354
359
|
Returns:
|
|
355
360
|
The post-login redirect, or an error tuple on failure.
|
|
356
361
|
"""
|
|
362
|
+
# `idp` and the IdP error text are request-controlled and Flask/Quart
|
|
363
|
+
# render a returned str as text/html: escape them (reflected XSS).
|
|
357
364
|
if idp not in self.oauth._registry:
|
|
358
|
-
return f"'{idp}' is not a valid registered idp", 400
|
|
365
|
+
return f"'{escape(idp)}' is not a valid registered idp", 400
|
|
359
366
|
|
|
360
367
|
oauth_client = self.get_oauth_client(idp)
|
|
361
368
|
oauth_kwargs = self.get_oauth_kwargs(idp)
|
|
@@ -365,7 +372,7 @@ class OIDCAuth(Auth):
|
|
|
365
372
|
**oauth_kwargs.get("authorize_token_kwargs", {}),
|
|
366
373
|
)
|
|
367
374
|
except OAuthError as err:
|
|
368
|
-
return str(err), 401
|
|
375
|
+
return escape(str(err)), 401
|
|
369
376
|
|
|
370
377
|
user = token.get("userinfo")
|
|
371
378
|
return self.after_logged_in(user, idp, token)
|
|
@@ -381,7 +388,7 @@ class OIDCAuth(Auth):
|
|
|
381
388
|
"""
|
|
382
389
|
if idp not in self.oauth._registry:
|
|
383
390
|
return self.backend.coerce_response(
|
|
384
|
-
(f"'{idp}' is not a valid registered idp", 400)
|
|
391
|
+
(f"'{escape(idp)}' is not a valid registered idp", 400)
|
|
385
392
|
)
|
|
386
393
|
|
|
387
394
|
oauth_client = self.get_oauth_client(idp)
|
|
@@ -392,7 +399,7 @@ class OIDCAuth(Auth):
|
|
|
392
399
|
**oauth_kwargs.get("authorize_token_kwargs", {}),
|
|
393
400
|
)
|
|
394
401
|
except OAuthError as err:
|
|
395
|
-
return self.backend.coerce_response((str(err), 401))
|
|
402
|
+
return self.backend.coerce_response((escape(str(err)), 401))
|
|
396
403
|
|
|
397
404
|
user = token.get("userinfo")
|
|
398
405
|
return self.backend.coerce_response(self.after_logged_in(user, idp, token))
|
|
@@ -75,45 +75,105 @@ class _WSEntry:
|
|
|
75
75
|
# reconnect replaces the prior entry rather than stacking. Together these bound
|
|
76
76
|
# the map to (at most) one entry per distinct pre-login browser.
|
|
77
77
|
_WS_BY_CLIENT: dict[str, _WSEntry] = {}
|
|
78
|
+
# client-id cookie -> the browser's current *authenticated* socket, retired on
|
|
79
|
+
# logout. Kept apart from the anonymous map because every authorized HTTP
|
|
80
|
+
# request retires the anonymous entry, which must never hit a logged-in socket.
|
|
81
|
+
_AUTHED_WS_BY_CLIENT: dict[str, _WSEntry] = {}
|
|
78
82
|
_ws_registry_lock = threading.Lock()
|
|
79
83
|
|
|
84
|
+
# The key is a *client-supplied* cookie and Dash has no disconnect hook to
|
|
85
|
+
# deregister on, so an unauthenticated client handshaking with a fresh id each
|
|
86
|
+
# time would otherwise grow the map (and pin every socket) without bound.
|
|
87
|
+
# shortcut: oldest-first eviction, an evicted browser only loses the proactive
|
|
88
|
+
# reconnect and falls back to the reactive 4401-then-reconnect path; upgrade to
|
|
89
|
+
# deregistering on disconnect if Dash ever exposes a websocket_disconnect hook.
|
|
90
|
+
_MAX_TRACKED_WS = 10_000
|
|
91
|
+
# Minted ids are 22 characters; anything much longer was not minted here.
|
|
92
|
+
_MAX_CLIENT_ID_LEN = 64
|
|
93
|
+
|
|
80
94
|
|
|
81
95
|
def mint_ws_client_id() -> str:
|
|
82
96
|
"""Return a fresh, opaque browser-stable client id for the cookie."""
|
|
83
97
|
return secrets.token_urlsafe(16)
|
|
84
98
|
|
|
85
99
|
|
|
86
|
-
def
|
|
87
|
-
|
|
100
|
+
def _register_ws(
|
|
101
|
+
registry: dict[str, _WSEntry], client_id: str | None, ws: Any, loop: Any
|
|
102
|
+
) -> None:
|
|
103
|
+
"""Track ``ws`` under ``client_id`` in ``registry``, replacing any prior.
|
|
88
104
|
|
|
89
|
-
No-op without a client id
|
|
90
|
-
|
|
91
|
-
reactive 4401-then-reconnect path.
|
|
105
|
+
No-op without a (plausible) client id. The registry is capped at
|
|
106
|
+
``_MAX_TRACKED_WS`` entries, evicting the oldest first.
|
|
92
107
|
"""
|
|
93
|
-
if not client_id:
|
|
108
|
+
if not client_id or len(client_id) > _MAX_CLIENT_ID_LEN:
|
|
94
109
|
return
|
|
95
110
|
with _ws_registry_lock:
|
|
96
|
-
|
|
111
|
+
# Pop first so a reconnect re-enters as the newest entry.
|
|
112
|
+
registry.pop(client_id, None)
|
|
113
|
+
while len(registry) >= _MAX_TRACKED_WS:
|
|
114
|
+
del registry[next(iter(registry))]
|
|
115
|
+
registry[client_id] = _WSEntry(ws, loop)
|
|
97
116
|
|
|
98
117
|
|
|
99
|
-
def
|
|
100
|
-
"""Close
|
|
118
|
+
def _close_ws(registry: dict[str, _WSEntry], client_id: str | None) -> None:
|
|
119
|
+
"""Close and deregister the socket tracked for ``client_id``, if any.
|
|
101
120
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
cookie -- before the user's first click rather than after a sacrificed one.
|
|
106
|
-
Popping the entry also deregisters it, keeping the map from leaking.
|
|
121
|
+
The close code (``4408``) is outside the renderer's no-reconnect set
|
|
122
|
+
(``1000``/``4001``), so the SharedWorker dials a fresh handshake that
|
|
123
|
+
carries the browser's current session cookie.
|
|
107
124
|
"""
|
|
108
125
|
if not client_id:
|
|
109
126
|
return
|
|
110
127
|
with _ws_registry_lock:
|
|
111
|
-
entry =
|
|
128
|
+
entry = registry.pop(client_id, None)
|
|
112
129
|
if entry is None:
|
|
113
130
|
return
|
|
114
131
|
_schedule_ws_close(entry.loop, entry.ws)
|
|
115
132
|
|
|
116
133
|
|
|
134
|
+
def register_anonymous_ws(client_id: str | None, ws: Any, loop: Any) -> None:
|
|
135
|
+
"""Track a browser's current pre-login socket, replacing any stale prior.
|
|
136
|
+
|
|
137
|
+
No-op without a (plausible) client id (e.g. a backend that never minted the
|
|
138
|
+
cookie): such a socket can't be correlated to a later login and falls back
|
|
139
|
+
to the reactive 4401-then-reconnect path. The registry is capped at
|
|
140
|
+
``_MAX_TRACKED_WS`` entries, evicting the oldest first.
|
|
141
|
+
"""
|
|
142
|
+
if not client_id or len(client_id) > _MAX_CLIENT_ID_LEN:
|
|
143
|
+
return
|
|
144
|
+
with _ws_registry_lock:
|
|
145
|
+
# Pop first so a reconnect re-enters as the newest entry.
|
|
146
|
+
_WS_BY_CLIENT.pop(client_id, None)
|
|
147
|
+
while len(_WS_BY_CLIENT) >= _MAX_TRACKED_WS:
|
|
148
|
+
del _WS_BY_CLIENT[next(iter(_WS_BY_CLIENT))]
|
|
149
|
+
_WS_BY_CLIENT[client_id] = _WSEntry(ws, loop)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def close_anonymous_ws(client_id: str | None) -> None:
|
|
153
|
+
"""Close the browser's pre-login socket so the renderer reconnects authed.
|
|
154
|
+
|
|
155
|
+
Called when ``client_id`` authenticates over HTTP, so the reconnect happens
|
|
156
|
+
before the user's first click rather than after a sacrificed one. Popping
|
|
157
|
+
the entry also deregisters it, keeping the map from leaking.
|
|
158
|
+
"""
|
|
159
|
+
_close_ws(_WS_BY_CLIENT, client_id)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def close_authenticated_ws(client_id: str | None) -> None:
|
|
163
|
+
"""Close the browser's logged-in socket so a logout takes effect on it.
|
|
164
|
+
|
|
165
|
+
A socket's user is a snapshot taken at the handshake: clearing the session
|
|
166
|
+
over HTTP cannot reach it, so without this an already-open socket keeps
|
|
167
|
+
running protected callbacks after logout. The forced reconnect handshakes
|
|
168
|
+
with the cleared session and is anonymous from then on.
|
|
169
|
+
|
|
170
|
+
shortcut: the registry is per-process, so with several worker processes a
|
|
171
|
+
logout only retires a socket served by the same worker; upgrade to a shared
|
|
172
|
+
session store with server-side revocation if that matters.
|
|
173
|
+
"""
|
|
174
|
+
_close_ws(_AUTHED_WS_BY_CLIENT, client_id)
|
|
175
|
+
|
|
176
|
+
|
|
117
177
|
def _schedule_ws_close(loop: Any, ws: Any) -> None:
|
|
118
178
|
"""Schedule ``ws.close`` onto the socket's own event loop, thread-safely.
|
|
119
179
|
|
|
@@ -198,10 +258,10 @@ def _authorize_ws_message(ws: Any, message: dict) -> bool | tuple[int, str]:
|
|
|
198
258
|
def _ws_connect_hook(ws: Any):
|
|
199
259
|
"""Global Dash websocket_connect hook: register the socket by client id.
|
|
200
260
|
|
|
201
|
-
Runs at the handshake (before accept) for every socket. Tracks
|
|
202
|
-
|
|
203
|
-
so a later login can retire
|
|
204
|
-
|
|
261
|
+
Runs at the handshake (before accept) for every socket. Tracks each socket
|
|
262
|
+
keyed by browser (the ``dac_client`` cookie): one that handshakes
|
|
263
|
+
*anonymously* so a later login can retire it, an authenticated one so a
|
|
264
|
+
later logout can. Always allows the connection -- public pages
|
|
205
265
|
legitimately stream over an unauthenticated socket, so this hook must never
|
|
206
266
|
reject.
|
|
207
267
|
|
|
@@ -216,18 +276,18 @@ def _ws_connect_hook(ws: Any):
|
|
|
216
276
|
|
|
217
277
|
|
|
218
278
|
def _track_anonymous_ws(ws: Any) -> None:
|
|
219
|
-
"""Register ``ws``
|
|
279
|
+
"""Register ``ws`` by browser and auth state (see ``_ws_connect_hook``)."""
|
|
220
280
|
backend = get_active_backend()
|
|
221
281
|
_, user = backend.ws_identity(ws)
|
|
222
|
-
|
|
223
|
-
|
|
282
|
+
# Anonymous sockets are retired on login, authenticated ones on logout.
|
|
283
|
+
registry = _WS_BY_CLIENT if user is None else _AUTHED_WS_BY_CLIENT
|
|
224
284
|
client_id = getattr(ws, "cookies", {}).get(WS_CLIENT_COOKIE)
|
|
225
285
|
# Resolve the concrete socket: Quart hands us a context-local proxy that
|
|
226
286
|
# can't be closed from the later (different-task) login, so we must keep the
|
|
227
287
|
# underlying object. Starlette's WebSocket has no such proxy and is stored
|
|
228
288
|
# as-is.
|
|
229
289
|
real_ws = ws._get_current_object() if hasattr(ws, "_get_current_object") else ws
|
|
230
|
-
|
|
290
|
+
_register_ws(registry, client_id, real_ws, asyncio.get_running_loop())
|
|
231
291
|
|
|
232
292
|
|
|
233
293
|
def _ensure_hook_registered() -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dash-auth-async
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.6
|
|
4
4
|
Summary: Dash Authorization Package.
|
|
5
5
|
Author-email: Jonas Schrage <119843859+joschrag@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -30,7 +30,7 @@ Classifier: Topic :: Software Development :: Widget Sets
|
|
|
30
30
|
Requires-Python: >=3.10
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
License-File: LICENSE
|
|
33
|
-
Requires-Dist: authlib>=1.
|
|
33
|
+
Requires-Dist: authlib>=1.9.1
|
|
34
34
|
Requires-Dist: flask>=3.1.3
|
|
35
35
|
Requires-Dist: werkzeug>=3.1.8
|
|
36
36
|
Requires-Dist: dash>=2
|
|
@@ -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.6"
|
|
8
8
|
description = "Dash Authorization Package."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -36,7 +36,7 @@ classifiers = [
|
|
|
36
36
|
"Topic :: Software Development :: Widget Sets",
|
|
37
37
|
]
|
|
38
38
|
dependencies = [
|
|
39
|
-
"authlib>=1.
|
|
39
|
+
"authlib>=1.9.1",
|
|
40
40
|
"flask>=3.1.3",
|
|
41
41
|
"werkzeug>=3.1.8",
|
|
42
42
|
"dash>=2",
|
|
@@ -93,8 +93,10 @@ constraint-dependencies = [
|
|
|
93
93
|
# at and below 4.4.0. Pulled in transitively via hypercorn.
|
|
94
94
|
"h2>=4.4.1",
|
|
95
95
|
# GHSA-mpf4-983q-p7j4 and others: unbounded urlencoded/multipart
|
|
96
|
-
# parsing DoS at and below 6.5.7
|
|
97
|
-
#
|
|
96
|
+
# parsing DoS at and below 6.5.7, plus Dependabot alerts fixed in 6.6.
|
|
97
|
+
# tornado 6.6 needs Python 3.11+, so the 3.10 floor stays at 6.5.8.
|
|
98
|
+
# Pulled in transitively via jupyter-client.
|
|
99
|
+
"tornado>=6.6; python_version >= '3.11'",
|
|
98
100
|
"tornado>=6.5.8",
|
|
99
101
|
]
|
|
100
102
|
override-dependencies = [
|
|
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.4 → dash_auth_async-1.3.6}/dash_auth_async.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|