Merge "Add API version to identity endpoint URLs"
This commit is contained in:
commit
4fe52d8303
|
@ -219,13 +219,18 @@ class KeystoneBackend(object):
|
|||
|
||||
interface = getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'public')
|
||||
|
||||
endpoint = utils.fix_auth_url_version(
|
||||
scoped_auth_ref.service_catalog.url_for(
|
||||
service_type='identity',
|
||||
interface=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(service_type='identity',
|
||||
interface=interface))
|
||||
endpoint)
|
||||
|
||||
if request is not None:
|
||||
request.session['unscoped_token'] = unscoped_token
|
||||
|
|
|
@ -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 "
|
||||
|
|
Loading…
Reference in New Issue