Merge "trivial: Remove vendored 'is_safe_url' function"
This commit is contained in:
commit
3abaeda160
|
@ -99,21 +99,6 @@ def is_token_valid(token, margin=None):
|
|||
return expiration > timezone.now()
|
||||
|
||||
|
||||
# From django.contrib.auth.views
|
||||
# Added in Django 1.4.3, 1.5b2
|
||||
# Vendored here for compatibility with old Django versions.
|
||||
def is_safe_url(url, host=None):
|
||||
"""Return ``True`` if the url is a safe redirection.
|
||||
|
||||
The safe redirection means that it doesn't point to a different host.
|
||||
Always returns ``False`` on an empty url.
|
||||
"""
|
||||
if not url:
|
||||
return False
|
||||
netloc = urlparse.urlparse(url)[1]
|
||||
return not netloc or netloc == host
|
||||
|
||||
|
||||
# Helper for figuring out keystone version
|
||||
# Implementation will change when API version discovery is available
|
||||
def get_keystone_version():
|
||||
|
|
|
@ -41,11 +41,6 @@ from openstack_auth.forms import Login # noqa:F401
|
|||
from openstack_auth import user as auth_user
|
||||
from openstack_auth import utils
|
||||
|
||||
try:
|
||||
is_safe_url = http.is_safe_url
|
||||
except AttributeError:
|
||||
is_safe_url = utils.is_safe_url
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -241,7 +236,8 @@ def switch(request, tenant_id, redirect_field_name=auth.REDIRECT_FIELD_NAME):
|
|||
# Ensure the user-originating redirection url is safe.
|
||||
# Taken from django.contrib.auth.views.login()
|
||||
redirect_to = request.GET.get(redirect_field_name, '')
|
||||
if not is_safe_url(url=redirect_to, allowed_hosts=[request.get_host()]):
|
||||
if not http.is_safe_url(url=redirect_to,
|
||||
allowed_hosts=[request.get_host()]):
|
||||
redirect_to = settings.LOGIN_REDIRECT_URL
|
||||
|
||||
if auth_ref:
|
||||
|
@ -275,7 +271,8 @@ def switch_region(request, region_name,
|
|||
region_name, request.user.username)
|
||||
|
||||
redirect_to = request.GET.get(redirect_field_name, '')
|
||||
if not is_safe_url(url=redirect_to, allowed_hosts=[request.get_host()]):
|
||||
if not http.is_safe_url(url=redirect_to,
|
||||
allowed_hosts=[request.get_host()]):
|
||||
redirect_to = settings.LOGIN_REDIRECT_URL
|
||||
|
||||
response = shortcuts.redirect(redirect_to)
|
||||
|
@ -305,7 +302,8 @@ def switch_keystone_provider(request, keystone_provider=None,
|
|||
raise exceptions.KeystoneAuthException(msg)
|
||||
|
||||
redirect_to = request.GET.get(redirect_field_name, '')
|
||||
if not is_safe_url(url=redirect_to, allowed_hosts=[request.get_host()]):
|
||||
if not http.is_safe_url(url=redirect_to,
|
||||
allowed_hosts=[request.get_host()]):
|
||||
redirect_to = settings.LOGIN_REDIRECT_URL
|
||||
|
||||
unscoped_auth_ref = None
|
||||
|
|
Loading…
Reference in New Issue