Opened 7 weeks ago

Last modified 4 weeks ago

#35303 assigned New feature

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: Accepted
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 (4)

comment:1 by Mariusz Felisiak, 7 weeks ago

Owner: changed from nobody to Jon Janzen
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Carlton Gibson, 7 weeks ago

Cc: Carlton Gibson added

comment:3 by Jon Janzen, 5 weeks ago

comment:4 by Jon Janzen, 4 weeks ago

Has patch: set
Note: See TracTickets for help on using tickets.
Back to Top