dash-auth-async 1.2.1__tar.gz → 1.3.0__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.2.1/dash_auth_async.egg-info → dash_auth_async-1.3.0}/PKG-INFO +97 -11
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/README.md +96 -10
- dash_auth_async-1.3.0/dash_auth_async/backends.py +869 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/basic_auth.py +6 -2
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/group_protection.py +6 -1
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/oidc_auth.py +56 -62
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/public_routes.py +13 -7
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/version.py +1 -1
- dash_auth_async-1.3.0/dash_auth_async/websocket_auth.py +271 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0/dash_auth_async.egg-info}/PKG-INFO +97 -11
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/pyproject.toml +20 -2
- dash_auth_async-1.2.1/dash_auth_async/backends.py +0 -238
- dash_auth_async-1.2.1/dash_auth_async/websocket_auth.py +0 -138
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/LICENSE +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/MANIFEST.in +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/__init__.py +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/_optional.py +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/auth.py +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async/quart_client.py +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async.egg-info/SOURCES.txt +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async.egg-info/dependency_links.txt +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async.egg-info/requires.txt +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/dash_auth_async.egg-info/top_level.txt +0 -0
- {dash_auth_async-1.2.1 → dash_auth_async-1.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dash-auth-async
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Dash Authorization Package.
|
|
5
5
|
Author-email: Jonas Schrage <119843859+joschrag@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -66,17 +66,20 @@ How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-
|
|
|
66
66
|
| --- | :---: | :---: |
|
|
67
67
|
| Flask backend | ✅ | ✅ |
|
|
68
68
|
| Quart backend | ❌ | ✅ |
|
|
69
|
-
| FastAPI backend | ❌ |
|
|
70
|
-
| Custom backends | ❌ | ✅ <sup>
|
|
69
|
+
| FastAPI backend | ❌ | ✅ |
|
|
70
|
+
| Custom backends | ❌ | ✅ <sup>1</sup> |
|
|
71
71
|
| Protected / public callbacks | ✅ | ✅ |
|
|
72
|
-
| Async callbacks | ❌ | ✅ <sup>
|
|
72
|
+
| Async callbacks | ❌ | ✅ <sup>2</sup> |
|
|
73
73
|
| Authenticated WebSocket callbacks | ❌ | ✅ <sup>3</sup> |
|
|
74
74
|
|
|
75
|
-
✅ supported ·
|
|
75
|
+
✅ supported · ❌ not supported
|
|
76
|
+
|
|
77
|
+
<sup>1</sup> `detect_backend` resolves Flask/Quart/FastAPI automatically; any other server is supported by supplying your own `Backend` instance.
|
|
78
|
+
|
|
79
|
+
<sup>2</sup> Provided by the Quart and FastAPI backends.
|
|
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.
|
|
76
82
|
|
|
77
|
-
<sup>1</sup> A `dash-auth-async[fastapi]` extra is declared and a native FastAPI backend is on the roadmap. In the meantime you can support it by implementing the `Backend` ABC and passing `Auth(..., backend=MyBackend())`.
|
|
78
|
-
<sup>2</sup> `detect_backend` resolves Flask/Quart automatically; any other server is supported by supplying your own `Backend` instance.
|
|
79
|
-
<sup>3</sup> Provided by the Quart backend. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
80
83
|
|
|
81
84
|
For local testing, install [uv](https://docs.astral.sh/uv/getting-started/installation/), then install the dev dependencies and run individual tests:
|
|
82
85
|
|
|
@@ -321,7 +324,22 @@ if __name__ == "__main__":
|
|
|
321
324
|
app.run(debug=True)
|
|
322
325
|
```
|
|
323
326
|
|
|
324
|
-
###
|
|
327
|
+
### Async backends
|
|
328
|
+
|
|
329
|
+
#### Known Limitations
|
|
330
|
+
|
|
331
|
+
> **⚠️ WebSocket callbacks & auth:**
|
|
332
|
+
> Do **not** enable `websocket_callbacks=True`
|
|
333
|
+
> globally on an authenticated `use_pages` app. The global flag routes *every*
|
|
334
|
+
> callback — including Dash's built-in page-routing callback — over the WebSocket,
|
|
335
|
+
> which bypasses the HTTP `before_request` auth guard where the login challenge is
|
|
336
|
+
> issued. Navigating to a protected page then hangs (the socket closes with `4401`
|
|
337
|
+
> and reconnect-loops) instead of prompting for login — the prompt appears only after
|
|
338
|
+
> a full page reload. Opt **individual** streaming callbacks into `websocket=True`
|
|
339
|
+
> instead, so routing and login stay on HTTP.
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
#### Quart (async) Backend
|
|
325
343
|
|
|
326
344
|
`dash-auth-async` supports [Dash's Quart backend](https://dash.plotly.com/) for fully async request handling.
|
|
327
345
|
Install the `quart` extra to pull in the required dependencies:
|
|
@@ -333,7 +351,7 @@ pip install dash-auth-async[quart]
|
|
|
333
351
|
Then pass `backend="quart"` when creating your Dash app. The auth setup is identical
|
|
334
352
|
to the Flask examples above — no code changes required beyond the backend flag.
|
|
335
353
|
|
|
336
|
-
|
|
354
|
+
##### BasicAuth with Quart
|
|
337
355
|
|
|
338
356
|
```python
|
|
339
357
|
from dash import Dash
|
|
@@ -347,7 +365,7 @@ if __name__ == "__main__":
|
|
|
347
365
|
app.run(host="127.0.0.1", port=8050, debug=True)
|
|
348
366
|
```
|
|
349
367
|
|
|
350
|
-
|
|
368
|
+
##### OIDCAuth with Quart
|
|
351
369
|
|
|
352
370
|
```python
|
|
353
371
|
import os
|
|
@@ -377,6 +395,74 @@ if __name__ == "__main__":
|
|
|
377
395
|
|
|
378
396
|
> **Note:** The Quart backend requires Dash >= 4.2.0 and Python >= 3.10.
|
|
379
397
|
|
|
398
|
+
#### FastAPI (async) Backend
|
|
399
|
+
|
|
400
|
+
`dash-auth-async` supports [Dash's FastAPI backend](https://dash.plotly.com/) too.
|
|
401
|
+
Install the `fastapi` extra to pull in the required dependencies:
|
|
402
|
+
|
|
403
|
+
```
|
|
404
|
+
pip install dash-auth-async[fastapi]
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Then pass `backend="fastapi"` when creating your Dash app. `BasicAuth` and
|
|
408
|
+
`OIDCAuth` work exactly as on Flask/Quart — no code changes beyond the backend flag.
|
|
409
|
+
|
|
410
|
+
##### BasicAuth with FastAPI
|
|
411
|
+
|
|
412
|
+
```python
|
|
413
|
+
from dash import Dash
|
|
414
|
+
from dash_auth_async import BasicAuth
|
|
415
|
+
|
|
416
|
+
app = Dash(__name__, backend="fastapi")
|
|
417
|
+
|
|
418
|
+
BasicAuth(
|
|
419
|
+
app,
|
|
420
|
+
{"admin": "admin", "viewer": "viewer123"},
|
|
421
|
+
secret_key="aStaticSecretKey!", # enables sessions (SessionMiddleware)
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
if __name__ == "__main__":
|
|
425
|
+
app.run(host="127.0.0.1", port=8050, debug=True)
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
##### OIDCAuth with FastAPI
|
|
429
|
+
|
|
430
|
+
```python
|
|
431
|
+
import os
|
|
432
|
+
from dash import Dash, html
|
|
433
|
+
from dash_auth_async import OIDCAuth
|
|
434
|
+
|
|
435
|
+
app = Dash(__name__, backend="fastapi")
|
|
436
|
+
|
|
437
|
+
app.layout = html.Div([
|
|
438
|
+
html.H2("OIDCAuth + FastAPI"),
|
|
439
|
+
html.A("Logout", href="/oidc/logout"),
|
|
440
|
+
])
|
|
441
|
+
|
|
442
|
+
auth = OIDCAuth(app, secret_key="aStaticSecretKey!")
|
|
443
|
+
auth.register_provider(
|
|
444
|
+
"myidp",
|
|
445
|
+
client_id=os.environ["OIDC_CLIENT_ID"],
|
|
446
|
+
client_secret=os.environ["OIDC_CLIENT_SECRET"],
|
|
447
|
+
server_metadata_url=os.environ["OIDC_METADATA_URL"],
|
|
448
|
+
token_endpoint_auth_method="client_secret_post",
|
|
449
|
+
client_kwargs={"scope": "openid email profile"},
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
if __name__ == "__main__":
|
|
453
|
+
app.run(host="127.0.0.1", port=8050, debug=True)
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Notes:
|
|
457
|
+
|
|
458
|
+
- A `secret_key` installs Starlette's `SessionMiddleware` automatically. If you
|
|
459
|
+
add your own `SessionMiddleware`, `dash-auth-async` defers to it.
|
|
460
|
+
- `Auth`/`OIDCAuth` must be constructed before the server starts serving
|
|
461
|
+
(Starlette forbids adding middleware after startup) — the normal usage pattern.
|
|
462
|
+
- OIDC uses authlib's official `starlette_client`; no extra client module required.
|
|
463
|
+
|
|
464
|
+
> The FastAPI backend requires Dash >= 4.2.0 and Python >= 3.10.
|
|
465
|
+
|
|
380
466
|
### User-group-based permissions
|
|
381
467
|
|
|
382
468
|
`dash_auth_async` provides a convenient way to secure parts of your app based on user groups.
|
|
@@ -21,17 +21,20 @@ How this fork compares to upstream [`dash-auth`](https://github.com/plotly/dash-
|
|
|
21
21
|
| --- | :---: | :---: |
|
|
22
22
|
| Flask backend | ✅ | ✅ |
|
|
23
23
|
| Quart backend | ❌ | ✅ |
|
|
24
|
-
| FastAPI backend | ❌ |
|
|
25
|
-
| Custom backends | ❌ | ✅ <sup>
|
|
24
|
+
| FastAPI backend | ❌ | ✅ |
|
|
25
|
+
| Custom backends | ❌ | ✅ <sup>1</sup> |
|
|
26
26
|
| Protected / public callbacks | ✅ | ✅ |
|
|
27
|
-
| Async callbacks | ❌ | ✅ <sup>
|
|
27
|
+
| Async callbacks | ❌ | ✅ <sup>2</sup> |
|
|
28
28
|
| Authenticated WebSocket callbacks | ❌ | ✅ <sup>3</sup> |
|
|
29
29
|
|
|
30
|
-
✅ supported ·
|
|
30
|
+
✅ supported · ❌ not supported
|
|
31
|
+
|
|
32
|
+
<sup>1</sup> `detect_backend` resolves Flask/Quart/FastAPI automatically; any other server is supported by supplying your own `Backend` instance.
|
|
33
|
+
|
|
34
|
+
<sup>2</sup> Provided by the Quart and FastAPI backends.
|
|
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.
|
|
31
37
|
|
|
32
|
-
<sup>1</sup> A `dash-auth-async[fastapi]` extra is declared and a native FastAPI backend is on the roadmap. In the meantime you can support it by implementing the `Backend` ABC and passing `Auth(..., backend=MyBackend())`.
|
|
33
|
-
<sup>2</sup> `detect_backend` resolves Flask/Quart automatically; any other server is supported by supplying your own `Backend` instance.
|
|
34
|
-
<sup>3</sup> Provided by the Quart backend. WebSocket auth is a no-op on Flask, which has no WebSocket callback transport.
|
|
35
38
|
|
|
36
39
|
For local testing, install [uv](https://docs.astral.sh/uv/getting-started/installation/), then install the dev dependencies and run individual tests:
|
|
37
40
|
|
|
@@ -276,7 +279,22 @@ if __name__ == "__main__":
|
|
|
276
279
|
app.run(debug=True)
|
|
277
280
|
```
|
|
278
281
|
|
|
279
|
-
###
|
|
282
|
+
### Async backends
|
|
283
|
+
|
|
284
|
+
#### Known Limitations
|
|
285
|
+
|
|
286
|
+
> **⚠️ WebSocket callbacks & auth:**
|
|
287
|
+
> Do **not** enable `websocket_callbacks=True`
|
|
288
|
+
> globally on an authenticated `use_pages` app. The global flag routes *every*
|
|
289
|
+
> callback — including Dash's built-in page-routing callback — over the WebSocket,
|
|
290
|
+
> which bypasses the HTTP `before_request` auth guard where the login challenge is
|
|
291
|
+
> issued. Navigating to a protected page then hangs (the socket closes with `4401`
|
|
292
|
+
> and reconnect-loops) instead of prompting for login — the prompt appears only after
|
|
293
|
+
> a full page reload. Opt **individual** streaming callbacks into `websocket=True`
|
|
294
|
+
> instead, so routing and login stay on HTTP.
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
#### Quart (async) Backend
|
|
280
298
|
|
|
281
299
|
`dash-auth-async` supports [Dash's Quart backend](https://dash.plotly.com/) for fully async request handling.
|
|
282
300
|
Install the `quart` extra to pull in the required dependencies:
|
|
@@ -288,7 +306,7 @@ pip install dash-auth-async[quart]
|
|
|
288
306
|
Then pass `backend="quart"` when creating your Dash app. The auth setup is identical
|
|
289
307
|
to the Flask examples above — no code changes required beyond the backend flag.
|
|
290
308
|
|
|
291
|
-
|
|
309
|
+
##### BasicAuth with Quart
|
|
292
310
|
|
|
293
311
|
```python
|
|
294
312
|
from dash import Dash
|
|
@@ -302,7 +320,7 @@ if __name__ == "__main__":
|
|
|
302
320
|
app.run(host="127.0.0.1", port=8050, debug=True)
|
|
303
321
|
```
|
|
304
322
|
|
|
305
|
-
|
|
323
|
+
##### OIDCAuth with Quart
|
|
306
324
|
|
|
307
325
|
```python
|
|
308
326
|
import os
|
|
@@ -332,6 +350,74 @@ if __name__ == "__main__":
|
|
|
332
350
|
|
|
333
351
|
> **Note:** The Quart backend requires Dash >= 4.2.0 and Python >= 3.10.
|
|
334
352
|
|
|
353
|
+
#### FastAPI (async) Backend
|
|
354
|
+
|
|
355
|
+
`dash-auth-async` supports [Dash's FastAPI backend](https://dash.plotly.com/) too.
|
|
356
|
+
Install the `fastapi` extra to pull in the required dependencies:
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
pip install dash-auth-async[fastapi]
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Then pass `backend="fastapi"` when creating your Dash app. `BasicAuth` and
|
|
363
|
+
`OIDCAuth` work exactly as on Flask/Quart — no code changes beyond the backend flag.
|
|
364
|
+
|
|
365
|
+
##### BasicAuth with FastAPI
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
from dash import Dash
|
|
369
|
+
from dash_auth_async import BasicAuth
|
|
370
|
+
|
|
371
|
+
app = Dash(__name__, backend="fastapi")
|
|
372
|
+
|
|
373
|
+
BasicAuth(
|
|
374
|
+
app,
|
|
375
|
+
{"admin": "admin", "viewer": "viewer123"},
|
|
376
|
+
secret_key="aStaticSecretKey!", # enables sessions (SessionMiddleware)
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
if __name__ == "__main__":
|
|
380
|
+
app.run(host="127.0.0.1", port=8050, debug=True)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
##### OIDCAuth with FastAPI
|
|
384
|
+
|
|
385
|
+
```python
|
|
386
|
+
import os
|
|
387
|
+
from dash import Dash, html
|
|
388
|
+
from dash_auth_async import OIDCAuth
|
|
389
|
+
|
|
390
|
+
app = Dash(__name__, backend="fastapi")
|
|
391
|
+
|
|
392
|
+
app.layout = html.Div([
|
|
393
|
+
html.H2("OIDCAuth + FastAPI"),
|
|
394
|
+
html.A("Logout", href="/oidc/logout"),
|
|
395
|
+
])
|
|
396
|
+
|
|
397
|
+
auth = OIDCAuth(app, secret_key="aStaticSecretKey!")
|
|
398
|
+
auth.register_provider(
|
|
399
|
+
"myidp",
|
|
400
|
+
client_id=os.environ["OIDC_CLIENT_ID"],
|
|
401
|
+
client_secret=os.environ["OIDC_CLIENT_SECRET"],
|
|
402
|
+
server_metadata_url=os.environ["OIDC_METADATA_URL"],
|
|
403
|
+
token_endpoint_auth_method="client_secret_post",
|
|
404
|
+
client_kwargs={"scope": "openid email profile"},
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
if __name__ == "__main__":
|
|
408
|
+
app.run(host="127.0.0.1", port=8050, debug=True)
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Notes:
|
|
412
|
+
|
|
413
|
+
- A `secret_key` installs Starlette's `SessionMiddleware` automatically. If you
|
|
414
|
+
add your own `SessionMiddleware`, `dash-auth-async` defers to it.
|
|
415
|
+
- `Auth`/`OIDCAuth` must be constructed before the server starts serving
|
|
416
|
+
(Starlette forbids adding middleware after startup) — the normal usage pattern.
|
|
417
|
+
- OIDC uses authlib's official `starlette_client`; no extra client module required.
|
|
418
|
+
|
|
419
|
+
> The FastAPI backend requires Dash >= 4.2.0 and Python >= 3.10.
|
|
420
|
+
|
|
335
421
|
### User-group-based permissions
|
|
336
422
|
|
|
337
423
|
`dash_auth_async` provides a convenient way to secure parts of your app based on user groups.
|