""" 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