Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes compatibility with keystoneclient v0.2.

  • Loading branch information...
commit b95664d5baf54bfff7c13c8869db5507a377005d 1 parent f8b1be8
@gabrielhurley authored
View
2  openstack_auth/__init__.py
@@ -1,2 +1,2 @@
# following PEP 386
-__version__ = "1.0.5"
+__version__ = "1.0.6"
View
7 openstack_auth/backend.py
@@ -97,6 +97,9 @@ def authenticate(self, request=None, username=None, password=None,
while tenants:
tenant = tenants.pop()
try:
+ client = keystone_client.Client(tenant_id=tenant.id,
+ token=unscoped_token.id,
+ auth_url=auth_url)
token = client.tokens.authenticate(username=username,
token=unscoped_token.id,
tenant_id=tenant.id)
@@ -113,7 +116,9 @@ def authenticate(self, request=None, username=None, password=None,
self.check_auth_expiry(token)
# If we made it here we succeeded. Create our User!
- user = create_user_from_token(request, token, client.management_url)
+ user = create_user_from_token(request,
+ token,
+ client.service_catalog.url_for())
if request is not None:
if is_ans1_token(unscoped_token.id):
View
11 openstack_auth/tests/tests.py
@@ -41,6 +41,10 @@ def test_login(self):
username=user.name,
tenant_id=None).AndReturn(self.keystone_client)
self.keystone_client.tenants.list().AndReturn(tenants)
+ client.Client(auth_url=settings.OPENSTACK_KEYSTONE_URL,
+ tenant_id=self.data.tenant_two.id,
+ token=sc.get_token()['id']) \
+ .AndReturn(self.keystone_client)
self.keystone_client.tokens.authenticate(tenant_id=tenants[1].id,
token=sc.get_token()['id'],
username=user.name) \
@@ -172,7 +176,12 @@ def test_switch(self):
username=user.name) \
.AndReturn(scoped)
- client.Client(endpoint=settings.OPENSTACK_KEYSTONE_URL) \
+ client.Client(auth_url=settings.OPENSTACK_KEYSTONE_URL,
+ tenant_id=self.data.tenant_two.id,
+ token=sc.get_token()['id']) \
+ .AndReturn(self.keystone_client)
+
+ client.Client(endpoint=sc.url_for()) \
.AndReturn(self.keystone_client)
self.keystone_client.tokens.authenticate(tenant_id=tenant.id,
View
9 openstack_auth/user.py
@@ -1,4 +1,5 @@
import hashlib
+import logging
from django.contrib.auth.models import AnonymousUser
@@ -8,6 +9,9 @@
from .utils import check_token_expiration, is_ans1_token
+LOG = logging.getLogger(__name__)
+
+
def set_session_from_user(request, user):
if is_ans1_token(user.token.id):
hashed_token = hashlib.md5(user.token.id).hexdigest()
@@ -117,11 +121,10 @@ def authorized_tenants(self):
client = keystone_client.Client(username=self.username,
auth_url=endpoint,
token=token.id)
- authd = client.tenants.list()
+ self._authorized_tenants = client.tenants.list()
except (keystone_exceptions.ClientException,
keystone_exceptions.AuthorizationFailure):
- authd = []
- self._authorized_tenants = authd
+ LOG.exception('Unable to retrieve tenant list.')
return self._authorized_tenants or []
@authorized_tenants.setter
View
3  openstack_auth/views.py
@@ -55,8 +55,9 @@ def login(request):
# will erase it if we set it earlier.
if request.user.is_authenticated():
set_session_from_user(request, request.user)
+ regions = dict(Login.get_region_choices())
region = request.user.endpoint
- region_name = dict(Login.get_region_choices()).get(region)
+ region_name = regions.get(region)
request.session['region_endpoint'] = region
request.session['region_name'] = region_name
return res
View
2  setup.py
@@ -43,7 +43,7 @@ def find_version(*file_paths):
zip_safe=False,
install_requires=[
'django >= 1.4',
- 'python-keystoneclient'
+ 'python-keystoneclient >= 0.2'
],
tests_require=[
'mox',
Please sign in to comment.
Something went wrong with that request. Please try again.