Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deploy/docker/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ def jwt_required(credentials: HTTPAuthorizationCredentials = Depends(security))


class TokenRequest(BaseModel):
email: EmailStr
email: EmailStr
api_token: Optional[str] = None
1 change: 1 addition & 0 deletions deploy/docker/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rate_limiting:
security:
enabled: false
jwt_enabled: false
api_token: "" # When set, /token endpoint requires this secret to issue JWTs
https_redirect: false
trusted_hosts: ["*"]
headers:
Expand Down
3 changes: 3 additions & 0 deletions deploy/docker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ def _safe_eval_config(expr: str) -> dict:
# ──────────────────────── Endpoints ──────────────────────────
@app.post("/token")
async def get_token(req: TokenRequest):
expected_token = config.get("security", {}).get("api_token", "")
if expected_token and req.api_token != expected_token:
raise HTTPException(401, "Invalid or missing api_token")
if not verify_email_domain(req.email):
raise HTTPException(400, "Invalid email domain")
token = create_access_token({"sub": req.email})
Expand Down