Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#26956 closed New feature (fixed)

Allow additional safe hosts for "next" parameter during login

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

Use case:

  • Django application using auth for authentication
  • Django application is one part of a loosely coupled network of applications written in multiple languages/frameworks
  • These other applications are hosted on different domains
  • Goal, upon successful login, Django should be able to redirect to these other applications

To solve this use case I propose the following changes:

  • Change is_safe_url() so the host argument can also accept a list of hosts.
  • Change LoginView to add a new class member allowed_hosts. This member is a list of allowed hosts to pass to is_safe_url() in LoginView.get_success_url(). I think self.request.get_host() will always be implicitly added to this list.

Change History (7)

comment:1 by Simon Charette, 8 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Simon Charette, 8 years ago

As allowed_hosts would only be used by the get_success_url() method I suggest giving the class member or method a more explicit name (get_success_url_allowed_hosts()?)

comment:3 by Jon Dufresne, 8 years ago

Has patch: set

comment:4 by Tim Graham, 8 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Jon Dufresne <jon.dufresne@…>, 8 years ago

In f227b8d:

Refs #26956 -- Allowed is_safe_url() to validate against multiple hosts

comment:6 by Jon Dufresne <jon.dufresne@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 66e1ebbf:

Fixed #26956 -- Added success_url_allowed_hosts to LoginView and LogoutView.

Allows specifying additional hosts to redirect after login and log out.

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

In 96107e2:

Refs #26956 -- Removed the host parameter of django.utils.http.is_safe_url().

Per deprecation timeline.

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