diff options
| author | Dolph Mathews <dolph.mathews@gmail.com> | 2013-04-30 17:34:14 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-04-30 17:34:14 +0000 |
| commit | 28dc9b38a735a7c7d1c59ff82e39ec8e67965e1d (patch) | |
| tree | e579c419bbd8163627dfc2db74124598e82dbd01 /keystoneclient/v2_0/client.py | |
| parent | 22228f526d6ea08b7006be1287afe959b93c23db (diff) | |
| download | python-keystoneclient-28dc9b38a735a7c7d1c59ff82e39ec8e67965e1d.tar.gz | |
Revert "Use TokenManager to get token"
This reverts commit 22228f526d6ea08b7006be1287afe959b93c23db which appears to be breaking the keystone gating
Diffstat (limited to 'keystoneclient/v2_0/client.py')
| -rw-r--r-- | keystoneclient/v2_0/client.py | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/keystoneclient/v2_0/client.py b/keystoneclient/v2_0/client.py index 1d21f54..03cb8f2 100644 --- a/keystoneclient/v2_0/client.py +++ b/keystoneclient/v2_0/client.py @@ -154,7 +154,7 @@ class Client(client.HTTPClient): self.user_id = self.auth_ref.user_id self._extract_service_catalog(self.auth_url, self.auth_ref) - def get_raw_token_from_identity_service(self, username=None, + def get_raw_token_from_identity_service(self, auth_url, username=None, password=None, tenant_name=None, tenant_id=None, token=None): """ Authenticate against the Keystone API. @@ -166,12 +166,12 @@ class Client(client.HTTPClient): """ try: - return self.tokens.authenticate(username=username, - tenant_id=tenant_id, - tenant_name=tenant_name, - password=password, - token=token, - return_raw=True) + return self._base_authN(auth_url, + username=username, + tenant_id=tenant_id, + tenant_name=tenant_name, + password=password, + token=token) except (exceptions.AuthorizationFailure, exceptions.Unauthorized): _logger.debug("Authorization Failed.") raise @@ -179,6 +179,29 @@ class Client(client.HTTPClient): raise exceptions.AuthorizationFailure("Authorization Failed: " "%s" % e) + def _base_authN(self, auth_url, username=None, password=None, + tenant_name=None, tenant_id=None, token=None): + """ Takes a username, password, and optionally a tenant_id or + tenant_name to get an authentication token from keystone. + May also take a token and a tenant_id to re-scope a token + to a tenant.""" + headers = {} + url = auth_url + "/tokens" + if token: + headers['X-Auth-Token'] = token + params = {"auth": {"token": {"id": token}}} + elif username and password: + params = {"auth": {"passwordCredentials": {"username": username, + "password": password}}} + else: + raise ValueError('A username and password or token is required.') + if tenant_id: + params['auth']['tenantId'] = tenant_id + elif tenant_name: + params['auth']['tenantName'] = tenant_name + resp, body = self.request(url, 'POST', body=params, headers=headers) + return body['access'] + # TODO(heckj): remove entirely in favor of access.AccessInfo and # associated methods def _extract_service_catalog(self, url, body): |
