summaryrefslogtreecommitdiff
path: root/openstack_auth
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2019-08-26 17:14:42 +0100
committerAkihiro Motoki <amotoki@gmail.com>2019-09-11 03:33:41 +0000
commit1de8e806e07c4b954df14d1cd2f173a86aa096ea (patch)
treee4655450cbaaf2951998c2a691d19fae5b690a01 /openstack_auth
parentcfb907f803082bef519b82850081ed6c7193582a (diff)
downloadhorizon-1de8e806e07c4b954df14d1cd2f173a86aa096ea.tar.gz
trivial: Remove vendored 'is_safe_url' function
This has been present since at least Django 1.6 [1], though the comment on the removed function suggests it might have been earlier (pre-Git days, perhaps?). [1] https://github.com/django/django/commit/a2f2a399566 Change-Id: Ib6978ffa8d3962383fbc0a1c3cfd9da9e162f7dd Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'openstack_auth')
-rw-r--r--openstack_auth/utils.py15
-rw-r--r--openstack_auth/views.py14
2 files changed, 6 insertions, 23 deletions
diff --git a/openstack_auth/utils.py b/openstack_auth/utils.py
index 6ec1af693..ad4c7ab19 100644
--- a/openstack_auth/utils.py
+++ b/openstack_auth/utils.py
@@ -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():
diff --git a/openstack_auth/views.py b/openstack_auth/views.py
index 6ad2b2f46..4d490640e 100644
--- a/openstack_auth/views.py
+++ b/openstack_auth/views.py
@@ -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__)
@@ -237,7 +232,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:
@@ -270,7 +266,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)
@@ -299,7 +296,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