feat: Implement a comprehensive audit log system with a dedicated dashboard page and backend API.

This commit is contained in:
Galindo97
2026-02-10 14:07:20 -06:00
parent 6b88429cc6
commit f90e20469a
14 changed files with 1163 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
from starlette.responses import Response
from core.security import verify_token
from core.context import set_user_context
class UserContextMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next) -> Response:
auth_header = request.headers.get("Authorization")
if auth_header and auth_header.startswith("Bearer "):
token = auth_header.split(" ")[1]
try:
# verify_token might raise exception if invalid, we catch it to not block request
# but we won't have user context
user_info = verify_token(token)
set_user_context(user_info)
except Exception:
# Log error or ignore
pass
response = await call_next(request)
return response