Prepend WEBROOT to redirect URL for WebSSO
Change-Id: Ib5c99e3b7b16bfb64b651d2129643d6f53fe7722 Closes-Bug: 1444244
This commit is contained in:
parent
0e1f7b7827
commit
85b2aaea48
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user