New alert system and panel de control page

This commit is contained in:
Urtzi Alfaro
2025-11-27 15:52:40 +01:00
parent 1a2f4602f3
commit e902419b6e
178 changed files with 20982 additions and 6944 deletions

View File

@@ -0,0 +1,56 @@
"""
FastAPI dependencies for alert processor service
"""
from fastapi import Header, HTTPException, status
from typing import Optional
async def get_current_user(
authorization: Optional[str] = Header(None)
) -> dict:
"""
Extract and validate user from JWT token in Authorization header.
In production, this should verify the JWT token against auth service.
For now, we accept any Authorization header as valid.
Args:
authorization: Bearer token from Authorization header
Returns:
dict: User information extracted from token
Raises:
HTTPException: If no authorization header provided
"""
if not authorization:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Missing authorization header",
headers={"WWW-Authenticate": "Bearer"},
)
# In production, verify JWT and extract user info
# For now, return a basic user dict
return {
"user_id": "system",
"tenant_id": None, # Will be extracted from path parameter
"authenticated": True
}
async def get_optional_user(
authorization: Optional[str] = Header(None)
) -> Optional[dict]:
"""
Optional authentication dependency.
Returns user if authenticated, None otherwise.
"""
if not authorization:
return None
try:
return await get_current_user(authorization)
except HTTPException:
return None