Limit deprecated token message to single warning
The current behavior of a deprecation warning on every single request is making the logs very difficult to scan for other problems. One deprecation warning per run should be enough to get the message across. This patch ensures only one warning per lifetime of the middleware object. Change-Id: I481a1b11305cc1c90edf7e26c686824c32fe781f Closes-Bug: #1652929
This commit is contained in:
parent
20fb1dbe5a
commit
dfd53e5551
@ -324,6 +324,7 @@ class BaseAuthProtocol(object):
|
||||
self._enforce_token_bind = enforce_token_bind
|
||||
self._service_token_roles = set(service_token_roles or [])
|
||||
self._service_token_roles_required = service_token_roles_required
|
||||
self._service_token_warning_emitted = False
|
||||
|
||||
@webob.dec.wsgify(RequestClass=_request._AuthTokenRequest)
|
||||
def __call__(self, req):
|
||||
@ -381,12 +382,15 @@ class BaseAuthProtocol(object):
|
||||
if self._service_token_roles_required:
|
||||
request.service_token_valid = role_check_passed
|
||||
else:
|
||||
self.log.warning(_LW('A valid token was submitted as a '
|
||||
'service token, but it was not a '
|
||||
'valid service token. This is '
|
||||
'incorrect but backwards compatible '
|
||||
'behaviour. This will be removed in '
|
||||
'future releases.'))
|
||||
if not self._service_token_warning_emitted:
|
||||
self.log.warning(_LW('A valid token was submitted as '
|
||||
'a service token, but it was not '
|
||||
'a valid service token. This is '
|
||||
'incorrect but backwards '
|
||||
'compatible behaviour. This will '
|
||||
'be removed in future releases.'))
|
||||
# prevent log spam on every single request
|
||||
self._service_token_warning_emitted = True
|
||||
|
||||
request.service_token_valid = True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user