fix: add admin CORS + optional header
This commit is contained in:
@@ -24,8 +24,8 @@ router = APIRouter(prefix="/admin", tags=["admin"])
|
|||||||
ADMIN_API_KEY = "Platform-Admin-2024!" # in prod: from secret/env
|
ADMIN_API_KEY = "Platform-Admin-2024!" # in prod: from secret/env
|
||||||
|
|
||||||
|
|
||||||
def _require_admin(x_admin_key: str = Header(...)):
|
def _require_admin(x_admin_key: Optional[str] = Header(default=None)):
|
||||||
if x_admin_key != ADMIN_API_KEY:
|
if not x_admin_key or x_admin_key != ADMIN_API_KEY:
|
||||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Not authorized")
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Not authorized")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user