Opened 9 months ago
Closed 2 months ago
#35303 closed New feature (fixed)
Add async implementations to contrib.auth backends
Reported by: | Jon Janzen | Owned by: | Jon Janzen |
---|---|---|---|
Component: | contrib.auth | Version: | 5.0 |
Severity: | Normal | Keywords: | async auth |
Cc: | Carlton Gibson | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In previous tickets (TODO) we've added an async interface to contrib.auth and then added async implementations to relevant dependencies in other parts of Django.
The time has come to tie all that work together and provide context-switch-free async implementations of auth backends (to the extent possible within the current limitations of async django, namely that async ORM backends do not exist in main yet)
More reading here: https://forum.djangoproject.com/t/asyncifying-django-contrib-auth-and-signals-and-maybe-sessions/18770
Quoting from myself in that doc:
Once the prereqs are done ([see tickets above]), we could asyncify the internals of the auth app. This would allow for async-compatible backends and then take advantage of them to make the internals of the auth app fully async (if called from an async API entrypoint, like the alogin function that would be implemented in [above initial ticket]).
Note that I said async-COMPATIBLE. I envision that subclasses of auth.backends.BaseBackend would have several new functions added to support async-mode while still supporting sync-mode in the same classes. Default implementations of async-mode would be added automatically via sync_to_async, and implementers are free to choose to add async support or leave the default, slightly inefficient implementation in place.
You can see a prototype of the implementation on my fork: https://github.com/bigfootjon/django/compare/main...bigfootjon:django:async-contrib-auth
Change History (7)
comment:1 by , 9 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 9 months ago
Cc: | added |
---|
comment:3 by , 9 months ago
comment:4 by , 9 months ago
Has patch: | set |
---|
comment:5 by , 5 months ago
Patch needs improvement: | set |
---|
comment:6 by , 2 months ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
PR