summaryrefslogtreecommitdiff
path: root/glanceclient/common/utils.py
diff options
context:
space:
mode:
authorTravis Tripp <travis.tripp@hp.com>2014-09-15 16:17:18 -0600
committerTravis Tripp <travis.tripp@hp.com>2014-09-15 16:28:34 -0600
commitf980fc549247fa2deb87dfacebc6d8d13ccd45d1 (patch)
treea8bd380d148c998cc9666d6e13c34809dd4139b5 /glanceclient/common/utils.py
parent4a5903bce7cbe7e8384541b66020074b7fbe1702 (diff)
downloadpython-glanceclient-f980fc549247fa2deb87dfacebc6d8d13ccd45d1.tar.gz
Update how tokens are redacted
Using SHA-1 to match how Nova and Swift redact their tokens. Was discussed in the below thread: http://lists.openstack.org/pipermail/openstack-dev/2014-September/045802.html Here's what nova went with: https://review.openstack.org/#/c/99511/ swift seem to be following suit: https://review.openstack.org/#/c/99632/ Change-Id: I3045d6d9d2a13770f4022dbbd474b34eb1032f6e Closes-bug: 1329301
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r--glanceclient/common/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index d1a634e..d40a704 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -39,6 +39,8 @@ from glanceclient.openstack.common import strutils
_memoized_property_lock = threading.Lock()
+SENSITIVE_HEADERS = ('X-Auth-Token', )
+
# Decorator for cli-args
def arg(*args, **kwargs):
@@ -385,3 +387,13 @@ def memoized_property(fn):
setattr(self, attr_name, fn(self))
return getattr(self, attr_name)
return _memoized_property
+
+
+def safe_header(name, value):
+ if name in SENSITIVE_HEADERS:
+ v = value.encode('utf-8')
+ h = hashlib.sha1(v)
+ d = h.hexdigest()
+ return name, "{SHA1}%s" % d
+ else:
+ return name, value