summaryrefslogtreecommitdiff
path: root/keystoneclient/v3
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-11-29 23:02:41 +0000
committerGerrit Code Review <review@openstack.org>2016-11-29 23:02:41 +0000
commit70934194e18ed9823baa0d344e2543b982f1af73 (patch)
treea931bded0963d60d738b26dbb73c68c69a1e9ef7 /keystoneclient/v3
parent660e02f25972ee4baa974e6efa2c5f6bc9cf68be (diff)
parent9f5493747a404adc92960785848016a85c5a4acb (diff)
downloadpython-keystoneclient-70934194e18ed9823baa0d344e2543b982f1af73.tar.gz
Merge "Pass allow_expired to token validate"
Diffstat (limited to 'keystoneclient/v3')
-rw-r--r--keystoneclient/v3/tokens.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/keystoneclient/v3/tokens.py b/keystoneclient/v3/tokens.py
index 380ab8f..77f6045 100644
--- a/keystoneclient/v3/tokens.py
+++ b/keystoneclient/v3/tokens.py
@@ -61,37 +61,51 @@ class TokenManager(object):
return body
@positional.method(1)
- def get_token_data(self, token, include_catalog=True):
+ def get_token_data(self, token, include_catalog=True, allow_expired=False):
"""Fetch the data about a token from the identity server.
:param str token: The ID of the token to be fetched.
:param bool include_catalog: Whether the service catalog should be
included in the response.
+ :param allow_expired: If True the token will be validated and returned
+ if it has already expired.
:rtype: dict
"""
headers = {'X-Subject-Token': token}
+ flags = []
url = '/auth/tokens'
+
if not include_catalog:
- url += '?nocatalog'
+ flags.append('nocatalog')
+ if allow_expired:
+ flags.append('allow_expired=1')
+
+ if flags:
+ url = '%s?%s' % (url, '&'.join(flags))
resp, body = self._client.get(url, headers=headers)
return body
@positional.method(1)
- def validate(self, token, include_catalog=True):
+ def validate(self, token, include_catalog=True, allow_expired=False):
"""Validate a token.
:param token: The token to be validated.
:type token: str or :class:`keystoneclient.access.AccessInfo`
:param include_catalog: If False, the response is requested to not
include the catalog.
+ :param allow_expired: If True the token will be validated and returned
+ if it has already expired.
+ :type allow_expired: bool
:rtype: :class:`keystoneclient.access.AccessInfoV3`
"""
token_id = _calc_id(token)
- body = self.get_token_data(token_id, include_catalog=include_catalog)
+ body = self.get_token_data(token_id,
+ include_catalog=include_catalog,
+ allow_expired=allow_expired)
return access.AccessInfo.factory(auth_token=token_id, body=body)