arcade-mcp/arcade/arcade/worker/fastapi/auth.py
Eric Gustin 890ee96ef4
Rename actor to worker (#174)
# PR Description
This PR renames `actor` to `worker` 

**Does not include deployment related things in
`.github/workflows/release-containers.yml`**
2025-01-03 14:28:04 -08:00

20 lines
641 B
Python

from fastapi import HTTPException
from fastapi.security import HTTPAuthorizationCredentials
from arcade.worker.core.auth import validate_engine_token
# Dependency function to validate JWT
async def validate_engine_request(
worker_secret: str,
credentials: HTTPAuthorizationCredentials,
) -> None:
jwt: str = credentials.credentials
validation_result = validate_engine_token(worker_secret, jwt)
if not validation_result.valid:
raise HTTPException(
status_code=401,
detail=f"Invalid token. Error: {validation_result.error}",
headers={"WWW-Authenticate": "Bearer"},
)