Hide extended health check information behind superuser permission or a session property

Also adds an endpoint that (when specified with the proper secret), sets the session property
This commit is contained in:
Joseph Schorr 2017-05-24 18:26:22 -04:00
parent 4ad3682b9c
commit b7d6bb12fa
3 changed files with 37 additions and 6 deletions

View file

@ -1,5 +1,8 @@
import boto.rds2
import logging
from auth.permissions import SuperUserPermission
from flask import session
from health.services import check_all_services
logger = logging.getLogger(__name__)
@ -68,13 +71,18 @@ class HealthCheck(object):
data = {
'services': service_statuses_bools,
'services_expanded': service_status_expanded,
'notes': notes,
'is_testing': self.app.config['TESTING'],
'config_provider': self.config_provider.provider_id,
'local_service_key_id': self.instance_keys.local_key_id,
}
add_debug_information = SuperUserPermission().can() or session.get('health_debug', False)
if add_debug_information:
data.update({
'services_expanded': service_status_expanded,
'notes': notes,
'is_testing': self.app.config['TESTING'],
'config_provider': self.config_provider.provider_id,
'local_service_key_id': self.instance_keys.local_key_id,
})
return (data, 200 if is_healthy else 503)
@classmethod