summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2015-04-14 23:44:56 -0400
committerMatthias Runge <mrunge@redhat.com>2015-07-10 21:16:31 +0200
commit3f1eb3f3c6e3fbf8bff010d76362558f7e22b721 (patch)
tree4c4ff3db2f800eea69624700caf409dde32c6508
parent5267ef7890f5adeaf3095afa6ff411092db38900 (diff)
downloaddjango_openstack_auth-3f1eb3f3c6e3fbf8bff010d76362558f7e22b721.tar.gz
Prepend WEBROOT to redirect URL for WebSSO
Change-Id: Ib5c99e3b7b16bfb64b651d2129643d6f53fe7722 Closes-Bug: 1444244 (cherry picked from commit 85b2aaea489f2e89e36bc08b99216939d8076462)
-rw-r--r--openstack_auth/utils.py9
-rw-r--r--openstack_auth/views.py2
2 files changed, 10 insertions, 1 deletions
diff --git a/openstack_auth/utils.py b/openstack_auth/utils.py
index d861010..358f772 100644
--- a/openstack_auth/utils.py
+++ b/openstack_auth/utils.py
@@ -183,6 +183,15 @@ def is_websso_enabled():
return websso_enabled and keystonev3_plus
+def build_absolute_uri(request, relative_url):
+ """Ensure absolute_uri are relative to WEBROOT."""
+ webroot = getattr(settings, 'WEBROOT', '')
+ if webroot.endswith("/") and relative_url.startswith("/"):
+ webroot = webroot[:-1]
+
+ return request.build_absolute_uri(webroot + relative_url)
+
+
def has_in_url_path(url, sub):
"""Test if the `sub` string is in the `url` path."""
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
diff --git a/openstack_auth/views.py b/openstack_auth/views.py
index 8d5a0f5..68a1b08 100644
--- a/openstack_auth/views.py
+++ b/openstack_auth/views.py
@@ -60,7 +60,7 @@ def login(request, template_name=None, extra_context=None, **kwargs):
protocol = request.POST.get('auth_type', 'credentials')
if utils.is_websso_enabled() and protocol != 'credentials':
region = request.POST.get('region')
- origin = request.build_absolute_uri('/auth/websso/')
+ origin = utils.build_absolute_uri(request, '/auth/websso/')
url = ('%s/auth/OS-FEDERATION/websso/%s?origin=%s' %
(region, protocol, origin))
return shortcuts.redirect(url)