diff options
author | Jamie Lennox <jamielennox@redhat.com> | 2015-06-23 11:32:11 +0800 |
---|---|---|
committer | Jamie Lennox <jamielennox@redhat.com> | 2015-07-15 22:01:14 +0000 |
commit | a4584c4ba7fa62c923d7da883e1cf8080e1275ad (patch) | |
tree | 17882464cf6703cd1cb8becb81d41bebc0f626c2 /keystoneclient/v2_0 | |
parent | f1d0b15bae728ce88627292b02911a0112e0ed20 (diff) | |
download | python-keystoneclient-a4584c4ba7fa62c923d7da883e1cf8080e1275ad.tar.gz |
Add get_token_data to token CRUD
We already have the validate method that returns an AccessInfo object.
For auth_token middleware it would be simpler if the client returned
simply the token data so it presented the same way as other sources of
token data.
It would also help with the keystoneauth transition in auth_token as we
could bypass the keystoneclient.AccessInfo objects.
Closes-Bug: #1475041
Change-Id: Ifbe7a7004937d910739c325cc04ae7264a4498e0
Diffstat (limited to 'keystoneclient/v2_0')
-rw-r--r-- | keystoneclient/v2_0/tokens.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/keystoneclient/v2_0/tokens.py b/keystoneclient/v2_0/tokens.py index 670d65b..1874b48 100644 --- a/keystoneclient/v2_0/tokens.py +++ b/keystoneclient/v2_0/tokens.py @@ -84,6 +84,17 @@ class TokenManager(base.Manager): """ return self._get('/tokens/%s' % base.getid(token), 'access') + def get_token_data(self, token): + """Fetch the data about a token from the identity server. + + :param str token: The token id. + + :rtype: dict + """ + url = '/tokens/%s' % token + resp, body = self.client.get(url) + return body + def validate_access_info(self, token): """Validate a token. @@ -100,10 +111,9 @@ class TokenManager(base.Manager): return token.auth_token return base.getid(token) - url = '/tokens/%s' % calc_id(token) - resp, body = self.client.get(url) - access_info = access.AccessInfo.factory(resp=resp, body=body) - return access_info + token_id = calc_id(token) + body = self.get_token_data(token_id) + return access.AccessInfo.factory(auth_token=token_id, body=body) def get_revoked(self): """Returns the revoked tokens response. |