diff options
author | Brant Knudson <bknudson@us.ibm.com> | 2015-02-12 20:18:07 -0600 |
---|---|---|
committer | Brant Knudson <bknudson@us.ibm.com> | 2015-02-12 20:20:48 -0600 |
commit | ae784225627f1652638edc0bf273a41519a438d5 (patch) | |
tree | c720aaa0138c0be40b5ce21ae476d3fad21b8f9a | |
parent | 32c18a83e2ffe80f559ca871eeddb2ef8848ff17 (diff) | |
download | python-keystoneclient-ae784225627f1652638edc0bf273a41519a438d5.tar.gz |
Ignore all failures removing catalog when logging token
Operations could fail if the response was logged and had a 'token'
field that's not a dict. The fix is to ignore all errors when
trying to remove the service catalog from the response.
Also, enhanced the service catalog removal code to support V2
tokens.
Closes-Bug: 1420080
Change-Id: I35b971415744825e8e5f00f30dcf193d04ee699a
-rw-r--r-- | keystoneclient/session.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/keystoneclient/session.py b/keystoneclient/session.py index 69d0701..668a37a 100644 --- a/keystoneclient/session.py +++ b/keystoneclient/session.py @@ -57,16 +57,21 @@ def request(url, method='GET', **kwargs): def remove_service_catalog(body): try: data = jsonutils.loads(body) - except ValueError: - return body - try: - if 'catalog' in data['token']: + + # V3 token + if 'token' in data and 'catalog' in data['token']: data['token']['catalog'] = '<removed>' return jsonutils.dumps(data) - else: - return body - except KeyError: - return body + + # V2 token + if 'serviceCatalog' in data['access']: + data['access']['serviceCatalog'] = '<removed>' + return jsonutils.dumps(data) + + except Exception: + # Don't fail trying to clean up the request body. + pass + return body class Session(object): |