summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Grassler <j.grassler@syseleven.de>2015-10-21 17:43:35 +0200
committerJohannes Grassler <j.grassler@syseleven.de>2016-01-11 10:28:18 +0000
commitb8f342fb502b5e92ec4261fc558865b1edfc663e (patch)
tree578c46e8475e9589f508200ae768460eeb09c0a8
parent651a22ceaf3feb92ea2e1bab9420d9d97dd5b635 (diff)
downloaddjango_openstack_auth-b8f342fb502b5e92ec4261fc558865b1edfc663e.tar.gz
Add API version to identity endpoint URLs
This change adds the Keystone API version to the identity endpoint URL retrieved from Keystone's endpoint list. This is neccessary in Kilo and later, since identity endpoint URLs retrieved from Keystone no longer contain the API version path they used to contain until Juno. See https://bugs.launchpad.net/horizon/+bug/1508421 for a detailed analysis of the problem. Closes-Bug: 1508421 (cherry picked from commit 58ce9d7edeac81dbd7e7f77efde33c97e8d1e00c) Change-Id: I771555bc3133bc7e140822511ccd12aff8c35fca
-rw-r--r--openstack_auth/backend.py6
-rw-r--r--openstack_auth/utils.py16
2 files changed, 18 insertions, 4 deletions
diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py
index c630fb0..bc7c6ec 100644
--- a/openstack_auth/backend.py
+++ b/openstack_auth/backend.py
@@ -180,12 +180,16 @@ class KeystoneBackend(object):
interface = getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'public')
+ endpoint = utils.fix_auth_url_version(
+ scoped_auth_ref.service_catalog.url_for(endpoint_type=interface))
+
# If we made it here we succeeded. Create our User!
unscoped_token = unscoped_auth_ref.auth_token
+
user = auth_user.create_user_from_token(
request,
auth_user.Token(scoped_auth_ref, unscoped_token=unscoped_token),
- scoped_auth_ref.service_catalog.url_for(endpoint_type=interface))
+ endpoint)
if request is not None:
request.session['unscoped_token'] = unscoped_token
diff --git a/openstack_auth/utils.py b/openstack_auth/utils.py
index 1bc212e..7d0c515 100644
--- a/openstack_auth/utils.py
+++ b/openstack_auth/utils.py
@@ -282,12 +282,22 @@ def url_path_replace(url, old, new, count=None):
def fix_auth_url_version(auth_url):
- """Fix up the auth url if an invalid version prefix was given.
+ """Fix up the auth url if an invalid or no version prefix was given.
People still give a v2 auth_url even when they specify that they want v3
- authentication. Fix the URL to say v3. This should be smarter and take the
- base, unversioned URL and discovery.
+ authentication. Fix the URL to say v3 in this case and add version if it is
+ missing entirely. This should be smarter and use discovery.
"""
+
+ # Check for empty path component in endpoint URL and add keystone version
+ # to endpoint: as of Kilo, the identity URLs returned by Keystone might no
+ # longer contain API versions, leaving the version choice up to the user.
+ if urlparse.urlparse(auth_url)[3] == '':
+ if get_keystone_version() >= 3:
+ auth_url = urlparse.urljoin(auth_url, 'v3')
+ else:
+ auth_url = urlparse.urljoin(auth_url, 'v2.0')
+
if get_keystone_version() >= 3:
if has_in_url_path(auth_url, "/v2.0"):
LOG.warning("The settings.py file points to a v2.0 keystone "