#34391 closed New feature (fixed)

Add async interface to contrib.auth

Reported by: Jon Janzen Owned by: Jon Janzen
Component: contrib.auth Version: dev
Severity: Normal Keywords: async
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

This module currently doesn't offer a way to work with it directly asynchronously. Per the work in #31920 the middleware supports it, but if you need to directly call any of the functions you need to manually wrap them with the help of sync_to_async.

There are several functions here that could use an async version:

  • authenticate
  • login
  • logout
  • get_user
  • update_session_auth_hash

I'd like to propose implementing them by just wrapping the synchronous versions (for now). Later on we can asyncify the internals down to the ORM. I've discussed doing this as part of a larger proposal at length here: https://forum.djangoproject.com/t/asyncifying-django-contrib-auth-and-signals-and-maybe-sessions/18770

Change History (8)

comment:1 by Mariusz Felisiak, 21 months ago

Cc: Carlton Gibson added
Triage Stage: UnreviewedAccepted

comment:2 by Jon Janzen, 21 months ago

Owner: changed from nobody to Jon Janzen
Status: newassigned

comment:3 by Jon Janzen, 21 months ago

Has patch: set

comment:4 by Carlton Gibson, 21 months ago

Needs documentation: set
Needs tests: set

comment:5 by Jon Janzen, 20 months ago

Needs documentation: unset
Needs tests: unset

comment:6 by GitHub <noreply@…>, 17 months ago

In 650ce967:

Refs #34391 -- Updated asgiref dependency for 5.0 release series.

comment:7 by Mariusz Felisiak, 17 months ago

Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 17 months ago

Resolution: fixed
Status: assignedclosed

In 5e98959:

Fixed #34391 -- Added async-compatible interface to auth functions and related methods test clients.

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