diff options
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r-- | glanceclient/common/utils.py | 12 |
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 |