Harden LLM access: secrets only in server .env, no URL in repo.

Require LLM_BASE_URL and LLM_API_KEY for automatic generation, add per-user rate limits, stop publishing backend/LLM settings in docker-compose, and document secure deployment.
This commit is contained in:
Mireya Cueto Garrido
2026-06-04 13:24:40 +02:00
parent 182eae1e36
commit 4d2ced85a3
11 changed files with 487 additions and 169 deletions
+5
View File
@@ -51,9 +51,14 @@ def error_payload(code: str, message: str, details: object | None = None) -> dic
def register_exception_handlers(app: FastAPI) -> None:
@app.exception_handler(AppError)
async def app_error_handler(_: Request, exc: AppError) -> ORJSONResponse:
headers: dict[str, str] | None = None
retry_after = getattr(exc, "retry_after", None)
if retry_after is not None:
headers = {"Retry-After": str(retry_after)}
return ORJSONResponse(
status_code=exc.status_code,
content=error_payload(exc.code, exc.message),
headers=headers,
)
@app.exception_handler(StarletteHTTPException)