amazon-transcreation/backend/app/auth/middleware.py
DJP 98fa16bfc3 feat: complete Phase 1-2 scaffold — backend, frontend, pipeline skeleton
Full-stack Amazon AI Transcreation Platform with:
- FastAPI backend (async, PostgreSQL, Redis, Celery) with 11 DB tables
- JWT auth (SSO-ready abstract provider pattern)
- 6-agent pipeline orchestrator with deterministic modules
- Next.js 14 frontend with Amazon branding (Ember fonts, orange/dark theme)
- Job wizard, monitoring HUD, output review, admin screens
- 154 TM/reference files imported, 12 locales configured
- Docker Compose for all services

Agents 2-5 (TM retrieval, ranker, transcreator, compliance) are stubs
pending Phase 3 LLM integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 12:31:43 -04:00

33 lines
1,014 B
Python

from uuid import UUID
from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from app.auth.service import AuthService
security = HTTPBearer()
auth_service = AuthService()
async def decode_jwt(
credentials: HTTPAuthorizationCredentials = Depends(security),
) -> dict:
"""Decode JWT from Authorization header and return user claims."""
token = credentials.credentials
claims = auth_service.validate_token(token)
if claims is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid or expired token",
)
if claims.get("type") != "access":
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid token type",
)
return {
"user_id": UUID(claims["sub"]),
"email": claims.get("email", ""),
"role": claims.get("role", ""),
"name": claims.get("name", ""),
}