Auth alert creation settings (#820)
* fix(auth): enforce security dependencies for alert creation settings routes Co-authored-by: Copilot <copilot@github.com> * precommit-fixes --------- Co-authored-by: Copilot <copilot@github.com>
taylor_socfortress committed
Apr 24, 2026 at 16:31 UTC
e876d735480cbc0b1bdc9ee0faefa45140821797
1 file changed
+8
backend/app/integrations/alert_creation_settings/routes/alert_creation_settings.py
+8
@@ -3,11 +3,13 @@ from typing import List
3
from fastapi import APIRouter
4
from fastapi import Depends
5
from fastapi import HTTPException
6
+from fastapi import Security
7
from loguru import logger
8
from sqlalchemy.ext.asyncio import AsyncSession
9
from sqlalchemy.future import select
10
from sqlalchemy.orm import joinedload
11
12
+from app.auth.routes.auth import AuthHandler
13
from app.db.db_session import get_db
14
from app.integrations.alert_creation_settings.models.alert_creation_settings import (
15
AlertCreationEventConfig,
@@ -42,6 +44,7 @@ alert_creation_settings_router = APIRouter()
44
"/{customer_code}/event_configs",
45
response_model=List[List[AlertCreationEventConfigResponse]],
46
description="Get all alert event configs for a customer.",
47
+ dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))],
48
)
49
async def get_customer_event_configs(
50
customer_code: str,
@@ -75,6 +78,7 @@ async def get_customer_event_configs(
78
"/create",
79
response_model=AlertCreationSettings,
80
description="Create a new alert creation setting.",
81
+ dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))],
82
)
83
async def create_alert_creation_settings(
84
alert_creation_settings: AlertCreationSettingsCreate,
@@ -137,6 +141,7 @@ async def create_alert_creation_settings(
141
"/{customer_name}",
142
response_model=AlertCreationSettingsResponse,
143
description="Retrieve alert creation settings by customer name.",
144
+ dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))],
145
)
146
async def get_alert_creation_settings(
147
customer_name: str,
@@ -178,6 +183,7 @@ async def get_alert_creation_settings(
183
"/{customer_name}/event",
184
response_model=EventOrderResponse,
185
description="Add a new event to a customer's alert creation settings.",
186
+ dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))],
187
)
188
async def add_event_order(
189
customer_name: str,
@@ -240,6 +246,7 @@ async def add_event_order(
246
"/{customer_name}",
247
response_model=AlertCreationSettingsResponse,
248
description="Update a customer's event orders.",
249
+ dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))],
250
)
251
async def update_event_orders(
252
customer_name: str,
@@ -306,6 +313,7 @@ async def update_event_orders(
313
@alert_creation_settings_router.delete(
314
"/{customer_name}/event/{order_label}",
315
description="Delete an event order by order_label.",
316
+ dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))],
317
)
318
async def delete_event_order(
319
customer_name: str,