Mask passwords in debug log on user password operations
When a user is created, they change their password, or admin changes their password and debug logging is enabled, the value of the user's password was logged. The value should be masked. Change-Id: I07b7441378fb630f01204d6b656b218f6b94dd5a Closes-Bug: #1465922
This commit is contained in:
parent
c2c3a0ff86
commit
fbdb100e65
|
@ -17,6 +17,7 @@ import uuid
|
|||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
from keystone.common import authorization
|
||||
|
@ -52,9 +53,12 @@ def v2_deprecated(f):
|
|||
|
||||
|
||||
def _build_policy_check_credentials(self, action, context, kwargs):
|
||||
kwargs_str = ', '.join(['%s=%s' % (k, kwargs[k]) for k in kwargs])
|
||||
kwargs_str = strutils.mask_password(kwargs_str)
|
||||
|
||||
LOG.debug('RBAC: Authorizing %(action)s(%(kwargs)s)', {
|
||||
'action': action,
|
||||
'kwargs': ', '.join(['%s=%s' % (k, kwargs[k]) for k in kwargs])})
|
||||
'kwargs': kwargs_str})
|
||||
|
||||
# see if auth context has already been created. If so use it.
|
||||
if ('environment' in context and
|
||||
|
|
|
@ -439,8 +439,6 @@ class IdentityTestCase(test_v3.RestfulTestCase):
|
|||
def test_create_user_password_not_logged(self):
|
||||
# When a user is created, the password isn't logged at any level.
|
||||
|
||||
# FIXME(blk-u): This doesn't work as expected, see bug 1465922
|
||||
|
||||
log_fix = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
|
||||
|
||||
ref = self.new_user_ref(domain_id=self.domain_id)
|
||||
|
@ -448,15 +446,12 @@ class IdentityTestCase(test_v3.RestfulTestCase):
|
|||
'/users',
|
||||
body={'user': ref})
|
||||
|
||||
# This should be assert*Not*In, see bug 1465922
|
||||
self.assertIn(ref['password'], log_fix.output)
|
||||
self.assertNotIn(ref['password'], log_fix.output)
|
||||
|
||||
def test_update_password_not_logged(self):
|
||||
# When admin modifies user password, the password isn't logged at any
|
||||
# level.
|
||||
|
||||
# FIXME(blk-u): This doesn't work as expected, see bug 1465922
|
||||
|
||||
log_fix = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
|
||||
|
||||
# bootstrap a user as admin
|
||||
|
@ -471,9 +466,7 @@ class IdentityTestCase(test_v3.RestfulTestCase):
|
|||
expected_status=200)
|
||||
|
||||
self.assertNotIn(password, log_fix.output)
|
||||
|
||||
# This should be assert*Not*In, see bug 1465922
|
||||
self.assertIn(new_password, log_fix.output)
|
||||
self.assertNotIn(new_password, log_fix.output)
|
||||
|
||||
|
||||
class IdentityV3toV2MethodsTestCase(tests.TestCase):
|
||||
|
@ -628,8 +621,6 @@ class UserSelfServiceChangingPasswordsTestCase(test_v3.RestfulTestCase):
|
|||
# When a user changes their password, the password isn't logged at any
|
||||
# level.
|
||||
|
||||
# FIXME(blk-u): This doesn't work as expected, see bug 1465922
|
||||
|
||||
log_fix = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
|
||||
|
||||
# change password
|
||||
|
@ -638,6 +629,5 @@ class UserSelfServiceChangingPasswordsTestCase(test_v3.RestfulTestCase):
|
|||
original_password=self.user_ref['password'],
|
||||
expected_status=204)
|
||||
|
||||
# These should be assert*Not*In, see bug 1465922
|
||||
self.assertIn(self.user_ref['password'], log_fix.output)
|
||||
self.assertIn(new_password, log_fix.output)
|
||||
self.assertNotIn(self.user_ref['password'], log_fix.output)
|
||||
self.assertNotIn(new_password, log_fix.output)
|
||||
|
|
Loading…
Reference in New Issue