summaryrefslogtreecommitdiff
path: root/keystoneclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-03-10 02:26:23 +0000
committerGerrit Code Review <review@openstack.org>2014-03-10 02:26:23 +0000
commitf4f0ce53b5784df5fccf6a3dca70b4ebdea2ec4a (patch)
tree5c307cf7f97baea36bc0db8c5fd2cb58470a8ab3 /keystoneclient
parent8d94c6540a3c8adf31c0bede59d11e0dbc979e2e (diff)
parent213616b13846960fb81add23142f8003a84d354a (diff)
downloadpython-keystoneclient-f4f0ce53b5784df5fccf6a3dca70b4ebdea2ec4a.tar.gz
Merge "Provide more data to AuthMethod plugins"
Diffstat (limited to 'keystoneclient')
-rw-r--r--keystoneclient/auth/identity/v3.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/keystoneclient/auth/identity/v3.py b/keystoneclient/auth/identity/v3.py
index 0553650..19085b6 100644
--- a/keystoneclient/auth/identity/v3.py
+++ b/keystoneclient/auth/identity/v3.py
@@ -58,16 +58,20 @@ class Auth(base.BaseIdentityPlugin):
self.project_domain_id = project_domain_id
self.project_domain_name = project_domain_name
+ @property
+ def token_url(self):
+ """The full URL where we will send authentication data."""
+ return '%s/auth/tokens' % self.auth_url.rstrip('/')
+
def get_auth_ref(self, session, **kwargs):
headers = {}
- url = self.auth_url + "/auth/tokens"
body = {'auth': {'identity': {}}}
ident = body['auth']['identity']
for method in self.auth_methods:
- method, auth_data = method.get_auth_data(headers)
- ident.setdefault('methods', []).append(method)
- ident[method] = auth_data
+ name, auth_data = method.get_auth_data(session, self, headers)
+ ident.setdefault('methods', []).append(name)
+ ident[name] = auth_data
if not ident:
raise exceptions.AuthorizationFailure('Authentication method '
@@ -98,7 +102,7 @@ class Auth(base.BaseIdentityPlugin):
scope = body['auth'].setdefault('scope', {})
scope['OS-TRUST:trust'] = {'id': self.trust_id}
- resp = session.post(url, json=body, headers=headers,
+ resp = session.post(self.token_url, json=body, headers=headers,
authenticated=False)
return access.AccessInfoV3(resp.headers['X-Subject-Token'],
**resp.json()['token'])
@@ -161,9 +165,11 @@ class AuthMethod(object):
for p in cls._method_parameters])
@abc.abstractmethod
- def get_auth_data(self, headers=None):
+ def get_auth_data(self, session, auth, headers, **kwargs):
"""Return the authentication section of an auth plugin.
+ :param Session session: The communication session.
+ :param Auth auth: The auth plugin calling the method.
:param dict headers: The headers that will be sent with the auth
request if a plugin needs to add to them.
:return tuple(string, dict): The identifier of this plugin and a dict
@@ -208,7 +214,7 @@ class PasswordMethod(AuthMethod):
"""
super(PasswordMethod, self).__init__(**kwargs)
- def get_auth_data(self, headers=None):
+ def get_auth_data(self, session, auth, headers, **kwargs):
user = {'password': self.password}
if self.user_id:
@@ -239,7 +245,7 @@ class TokenMethod(AuthMethod):
"""
super(TokenMethod, self).__init__(**kwargs)
- def get_auth_data(self, headers=None):
+ def get_auth_data(self, session, auth, headers, **kwargs):
headers['X-Auth-Token'] = self.token
return 'token', {'id': self.token}