summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-25 18:52:42 +0000
committerGerrit Code Review <review@openstack.org>2016-01-25 18:52:42 +0000
commitdc981578062a6a8d2f026cd8a03b892fd1e779dd (patch)
tree3996140892967400a0ce45a077f9c31b841a0c3c
parent3295b154f3ca294252e10608a18fe5679ca81491 (diff)
parentb8f342fb502b5e92ec4261fc558865b1edfc663e (diff)
downloaddjango_openstack_auth-dc981578062a6a8d2f026cd8a03b892fd1e779dd.tar.gz
Merge "Add API version to identity endpoint URLs" into stable/liberty
-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 fefd85d..5abcbac 100644
--- a/openstack_auth/utils.py
+++ b/openstack_auth/utils.py
@@ -254,12 +254,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 "