Checking onboardin flow - fix 4

This commit is contained in:
Urtzi Alfaro
2025-07-27 16:29:53 +02:00
parent 0b14cf9eb2
commit e63a99b818
8 changed files with 497 additions and 8 deletions

View File

@@ -182,9 +182,11 @@ class AuthMiddleware(BaseHTTPMiddleware):
return False
# Validate token type
if payload.get("type") != "access":
token_type = payload.get("type")
if token_type not in ["access", "service"]:
logger.warning(f"Invalid token type: {payload.get('type')}")
return False
return True
@@ -193,12 +195,19 @@ class AuthMiddleware(BaseHTTPMiddleware):
Convert JWT payload to user context format
FIXED: Proper mapping between JWT structure and user context
"""
return {
base_context = {
"user_id": payload["user_id"],
"email": payload["email"],
"exp": payload["exp"],
"valid": True
}
if payload.get("service"):
base_context["service"] = payload["service"]
base_context["type"] = "service"
logger.debug(f"Service authentication: {payload['service']}")
return base_context
async def _verify_with_auth_service(self, token: str) -> Optional[Dict[str, Any]]:
"""