Opened 8 months ago

Closed 6 weeks 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 Mariusz Felisiak, 8 months ago

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

comment:2 by Carlton Gibson, 8 months ago

Cc: Carlton Gibson added

comment:3 by Jon Janzen, 8 months ago

comment:4 by Jon Janzen, 8 months ago

Has patch: set

comment:5 by Sarah Boyce, 4 months ago

Patch needs improvement: set

comment:6 by Sarah Boyce, 6 weeks ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:7 by Sarah Boyce <42296566+sarahboyce@…>, 6 weeks ago

Resolution: fixed
Status: assignedclosed

In 50f89ae:

Fixed #35303 -- Implemented async auth backends and utils.

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