Set default auth_url from django settings when auth_url is None

This is useful when users(client web forms) just provide
username/password to authenticate with django_openstack_auth. In this
case, they can still login if keystone version == 2.0 since keystone
v2.0 only requires username/password and auth_url to authenticate. In
most cases, auth_url can get from django(horizon)'s settings.

Fix-bug: #1316490
Change-Id: I2ed24238adb79b6ef33e4bf20232b6a924ad0b1f
This commit is contained in:
Xiao Hanyu 2014-04-21 17:21:31 +08:00
parent c8d0b8a85b
commit e239fb78e0
1 changed files with 3 additions and 0 deletions

View File

@ -78,6 +78,9 @@ class KeystoneBackend(object):
endpoint_type = getattr(
settings, 'OPENSTACK_ENDPOINT_TYPE', 'publicURL')
if auth_url is None:
auth_url = settings.OPENSTACK_KEYSTONE_URL
# keystone client v3 does not support logging in on the v2 url any more
if get_keystone_version() >= 3:
auth_url = auth_url.replace('v2.0', 'v3')