11 lines
340 B
Python
11 lines
340 B
Python
"""认证校验:CLI / Agent 请求必须携带与 GATEWAY_AUTH 一致的密码。"""
|
||
from fastapi import HTTPException
|
||
|
||
from app.config import settings
|
||
|
||
|
||
def require_auth(auth: str) -> None:
|
||
"""auth 不匹配时抛出 401。"""
|
||
if auth != settings.gateway_auth:
|
||
raise HTTPException(status_code=401, detail="invalid auth")
|