diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py index d43e0ba..194b0b7 100644 --- a/openstack_auth/backend.py +++ b/openstack_auth/backend.py @@ -217,12 +217,24 @@ class KeystoneBackend(object): # Check expiry for our new scoped token. self.check_auth_expiry(scoped_auth_ref) + # We want to try to use the same region we just logged into + # which may or may not be the default depending upon the order + # keystone uses + region_name = None + id_endpoints = scoped_auth_ref.service_catalog.\ + get_endpoints(service_type='identity') + for id_endpoint in [cat for cat in id_endpoints['identity']]: + if auth_url in id_endpoint.values(): + region_name = id_endpoint['region'] + break + 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)) + interface=interface, + region_name=region_name)) # If we made it here we succeeded. Create our User! unscoped_token = unscoped_auth_ref.auth_token @@ -230,7 +242,8 @@ class KeystoneBackend(object): user = auth_user.create_user_from_token( request, auth_user.Token(scoped_auth_ref, unscoped_token=unscoped_token), - endpoint) + endpoint, + services_region=region_name) if request is not None: request.session['unscoped_token'] = unscoped_token