feat(sandbox): add Python 3 code execution sandbox support
This commit is contained in:
15
sandbox/app/middleware/auth.py
Normal file
15
sandbox/app/middleware/auth.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""Authentication middleware"""
|
||||
from fastapi import Header, HTTPException, status
|
||||
|
||||
from app.config import get_config
|
||||
|
||||
|
||||
async def verify_api_key(x_api_key: str = Header(..., alias="X-Api-Key")):
|
||||
"""Verify API key from request header"""
|
||||
config = get_config()
|
||||
if x_api_key != config.app.key:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid API key"
|
||||
)
|
||||
return x_api_key
|
||||
Reference in New Issue
Block a user