diff options
author | Juan Antonio Osorio Robles <jaosorior@redhat.com> | 2017-11-07 06:29:35 +0000 |
---|---|---|
committer | Juan Antonio Osorio Robles <jaosorior@redhat.com> | 2017-11-07 13:08:11 +0200 |
commit | a8d86df94099317f2918bd0cf1f147b822bfc599 (patch) | |
tree | 34296d2052d6577c8f4fe6e99988b8f704fa577f | |
parent | e75f4c5ad91962e272d65daa770e00f70f931ecb (diff) | |
download | oslo-context-2.19.3.tar.gz |
Ouput a placeholder instead of the auth_token2.19.3
As the name of the get_logging_values suggests, that function will
get entries from the context for logging purposes. For this, we
shouldn't need the auth_token since it might potentially leak
in the logs.
This filters out the auth_token by setting it as '***' by
default.
Change-Id: I2b245c1665c3587be3c476b803122788d186e5d5
-rw-r--r-- | oslo_context/context.py | 7 | ||||
-rw-r--r-- | oslo_context/tests/test_context.py | 1 | ||||
-rw-r--r-- | releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml | 7 |
3 files changed, 15 insertions, 0 deletions
diff --git a/oslo_context/context.py b/oslo_context/context.py index 24ded43..6475c2c 100644 --- a/oslo_context/context.py +++ b/oslo_context/context.py @@ -353,6 +353,13 @@ class RequestContext(object): 'user_domain_name': self.user_domain_name, 'project_domain_name': self.project_domain_name} values.update(self.to_dict()) + if self.auth_token: + # NOTE(jaosorior): Gotta obfuscate the token since this dict is + # meant for logging and we shouldn't leak it. + values['auth_token'] = '***' + else: + values['auth_token'] = None + return values @property diff --git a/oslo_context/tests/test_context.py b/oslo_context/tests/test_context.py index f81f4f0..7fb8d60 100644 --- a/oslo_context/tests/test_context.py +++ b/oslo_context/tests/test_context.py @@ -486,6 +486,7 @@ class ContextTest(test_base.BaseTestCase): d = ctx.get_logging_values() self.assertIn('auth_token', d) + self.assertEqual(d['auth_token'], '***') self.assertIn('user', d) self.assertIn('tenant', d) self.assertIn('domain', d) diff --git a/releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml b/releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml new file mode 100644 index 0000000..6ae3a04 --- /dev/null +++ b/releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml @@ -0,0 +1,7 @@ +--- +security: + - | + The ``get_logging_values`` function no longer outputs the auth_token, but + instead leaves it as ``***`` instead. As the name suggests, this function is + meant for logging, and letting the auth_token there might leak sensitive + data. |