Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#24855 closed New feature (fixed)

Allow the use of django.contrib.auth.login without credentials (authentication)

Reported by: Paulo Gabriel Poiati Owned by: Paulo Gabriel Poiati
Component: contrib.auth Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As it is we need to call authenticate before login because we need to set the authentication backend in the user model. We can use login without authenticate if we set the backend attr manually, but this need some implementation knowledge of how authentication works.

The proposal is to change the login function signature to:

login(request, user, backend=None)

The following rules will apply:

  1. Use the value of the backend argument, if provided.
  2. Use the value of the user.backend annotation, if present.
  3. Use the only configured backend, if there is only one.
  4. Raise ValueError("You have multiple authentication backends configured; you must provide the backend argument to login.") otherwise.

More information can be found in the mailing list topic:

https://groups.google.com/forum/#!topic/django-developers/_I0BW5L7Z58

Change History (11)

comment:1 Changed 8 years ago by Paulo Gabriel Poiati

Owner: changed from nobody to Paulo Gabriel Poiati
Status: newassigned

comment:2 Changed 8 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 7 years ago by Paulo Gabriel Poiati

Has patch: set

comment:5 Changed 7 years ago by Carl Meyer

Needs documentation: set

comment:6 in reply to:  5 Changed 7 years ago by Paulo Gabriel Poiati

Replying to carljm:

The documentation was updated .

comment:7 Changed 7 years ago by Tim Graham

Needs documentation: unset

comment:8 Changed 7 years ago by Tim Graham

Patch needs improvement: set

comment:9 Changed 7 years ago by Paulo Gabriel Poiati

Patch needs improvement: unset

I applied the corrections in the PR.

comment:10 Changed 7 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In b643386:

Fixed #24855 -- Allowed using contrib.auth.login() without credentials.

Added an optional backend argument to login().

comment:11 Changed 7 years ago by Tim Graham <timograham@…>

In 6ea7b67:

Refs #24855 -- fixed typo in 1.10 release notes

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