[Django] #35303: Add async implementations to contrib.auth backends

20 views
Skip to first unread message

Django

unread,
Mar 14, 2024, 10:56:53 PM3/14/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
----------------------------------------+----------------------------
Reporter: Jon Janzen | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 5.0
Severity: Normal | Keywords: async auth
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+----------------------------
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
--
Ticket URL: <https://code.djangoproject.com/ticket/35303>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 15, 2024, 1:17:37 AM3/15/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
------------------------------+--------------------------------------
Reporter: Jon Janzen | Owner: Jon Janzen
Type: New feature | Status: assigned
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution:
Keywords: async auth | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Jon Janzen
* stage: Unreviewed => Accepted
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:1>

Django

unread,
Mar 15, 2024, 3:27:18 AM3/15/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
------------------------------+--------------------------------------
Reporter: Jon Janzen | Owner: Jon Janzen
Type: New feature | Status: assigned
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution:
Keywords: async auth | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* cc: Carlton Gibson (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:2>

Django

unread,
Mar 31, 2024, 3:50:15 PM3/31/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
------------------------------+--------------------------------------
Reporter: Jon Janzen | Owner: Jon Janzen
Type: New feature | Status: assigned
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution:
Keywords: async auth | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Comment (by Jon Janzen):

[https://github.com/django/django/pull/18036 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:3>

Django

unread,
Apr 6, 2024, 5:09:30 PM4/6/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
------------------------------+--------------------------------------
Reporter: Jon Janzen | Owner: Jon Janzen
Type: New feature | Status: assigned
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution:
Keywords: async auth | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Jon Janzen):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:4>

Django

unread,
Aug 1, 2024, 5:56:58 AM8/1/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
------------------------------+--------------------------------------
Reporter: Jon Janzen | Owner: Jon Janzen
Type: New feature | Status: assigned
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution:
Keywords: async auth | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:5>

Django

unread,
Oct 7, 2024, 6:04:17 AM10/7/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution:
Keywords: async auth | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:6>

Django

unread,
Oct 7, 2024, 8:19:50 AM10/7/24
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: closed
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution: fixed
Keywords: async auth | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"50f89ae850f6b4e35819fe725a08c7e579bfd099" 50f89ae]:
{{{#!CommitTicketReference repository=""
revision="50f89ae850f6b4e35819fe725a08c7e579bfd099"
Fixed #35303 -- Implemented async auth backends and utils.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:7>

Django

unread,
Aug 20, 2025, 4:29:19 AMAug 20
to django-...@googlegroups.com
#35303: Add async implementations to contrib.auth backends
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: closed
Component: contrib.auth | Version: 5.0
Severity: Normal | Resolution: fixed
Keywords: async auth | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by GitHub <noreply@…>):

In [changeset:"7063d31cc37028e0f945faa43030ce23dc1a5c23" 7063d31c]:
{{{#!CommitTicketReference repository=""
revision="7063d31cc37028e0f945faa43030ce23dc1a5c23"
Refs #35303 -- Made small optimizations in alogout() and aget_user().

In alogout(), there is no need to check the is_authenticated attribute
when user is None.

In aget_user(), there is no need to call get_session_auth_hash() twice.

Follow up to 50f89ae850f6b4e35819fe725a08c7e579bfd099.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35303#comment:8>
Reply all
Reply to author
Forward
0 new messages