X-Serivce-Token should be hashed in the log

Currently, logs display the hash values of X-Auth-Token,
Authorization, and X-Subject-Token, but not the value of
the X-Service-Token.  This patch set adds the X-Service-Token
to the list of header fields to be hashed for logging purposes.

Change-Id: I4d996a2631f61a2c9bbbc7f959e97c7279be023d
Closes-Bug: #1654847
This commit is contained in:
Tin Lam 2017-01-09 01:07:06 -06:00 committed by Steve Martinelli
parent f387043138
commit 9d3ae3ef94
3 changed files with 8 additions and 2 deletions

View File

@ -287,7 +287,7 @@ class Session(object):
def _process_header(header):
"""Redact the secure headers to be logged."""
secure_headers = ('authorization', 'x-auth-token',
'x-subject-token',)
'x-subject-token', 'x-service-token')
if header[0].lower() in secure_headers:
token_hasher = hashlib.sha1()
token_hasher.update(header[1].encode('utf-8'))

View File

@ -192,7 +192,8 @@ class SessionTests(utils.TestCase):
'Content-Type': 'application/text'}
security_headers = {'Authorization': uuid.uuid4().hex,
'X-Auth-Token': uuid.uuid4().hex,
'X-Subject-Token': uuid.uuid4().hex, }
'X-Subject-Token': uuid.uuid4().hex,
'X-Service-Token': uuid.uuid4().hex}
body = 'BODYRESPONSE'
data = 'BODYDATA'
all_headers = dict(

View File

@ -0,0 +1,5 @@
---
fixes:
- |
The ``X-Service-Token`` header value is now properly masked, and is
displayed as a hash value, in the log.