Add audit event for suspending a service

This is particularly important for broadcast services, where a rogue
service or platform admin could launch a DoS attack by suspending a
service at a critical moment when it needs to send alerts.
This commit is contained in:
Ben Thorner
2021-07-08 15:20:24 +01:00
parent e72a260e13
commit bb4c86008a
4 changed files with 40 additions and 3 deletions

View File

@@ -67,6 +67,17 @@ def create_broadcast_account_type_change_event(
)
def create_suspend_service_event(
service_id,
suspended_by_id,
):
_send_event(
'suspend_service',
service_id=service_id,
suspended_by_id=suspended_by_id,
)
def _send_event(event_type, **kwargs):
event_data = _construct_event_data(request)
event_data.update(kwargs)

View File

@@ -28,7 +28,10 @@ from app import (
service_api_client,
user_api_client,
)
from app.event_handlers import create_broadcast_account_type_change_event
from app.event_handlers import (
create_broadcast_account_type_change_event,
create_suspend_service_event,
)
from app.extensions import zendesk_client
from app.formatters import email_safe
from app.main import main
@@ -443,6 +446,7 @@ def archive_service(service_id):
def suspend_service(service_id):
if request.method == 'POST':
service_api_client.suspend_service(service_id)
create_suspend_service_event(service_id, suspended_by_id=current_user.id)
return redirect(url_for('.service_settings', service_id=service_id))
else:
flash("This will suspend the service and revoke all api keys. Are you sure you want to suspend this service?",