Opened 9 years ago

Closed 9 years ago

Last modified 9 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 by Paulo Gabriel Poiati, 9 years ago

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

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Paulo Gabriel Poiati, 9 years ago

Has patch: set

comment:5 by Carl Meyer, 9 years ago

Needs documentation: set

in reply to:  5 comment:6 by Paulo Gabriel Poiati, 9 years ago

Replying to carljm:

The documentation was updated .

comment:7 by Tim Graham, 9 years ago

Needs documentation: unset

comment:8 by Tim Graham, 9 years ago

Patch needs improvement: set

comment:9 by Paulo Gabriel Poiati, 9 years ago

Patch needs improvement: unset

I applied the corrections in the PR.

comment:10 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In b643386:

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

Added an optional backend argument to login().

comment:11 by Tim Graham <timograham@…>, 9 years ago

In 6ea7b67:

Refs #24855 -- fixed typo in 1.10 release notes

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