fix(openapi): declare the admin session cookie on every guarded operation #71

Merged
sirius merged 1 commit from fix/openapi-admin-security into master 2026-11-27 05:30:00 +00:00

2026-11-27

Sirius DevOps
fix(openapi): declare the admin session cookie on every guarded operation
/openapi.json is served to the internet and declared no securitySchemes at
all, so every one of the 22 mutating operations read as unauthenticated while
the middleware answers 401 on them. The enforcement lives in
AdminAuthMiddleware, not in a route dependency, so FastAPI had nothing to
infer a scheme from.

The spec is now stamped from auth.is_public() — the same allowlist the
middleware enforces — instead of a hand-maintained per-route list:
- components.securitySchemes.adminSession: apiKey in cookie, name
  osint_session (the cookie the middleware actually reads), with the 401/403
  behaviour documented.
- protected operations: security: [{"adminSession": []}] — 19 of the 22
  mutating operations plus GET /api/keys, GET /api/settings, /api/news/models.
- public operations: security: [] (explicit "no auth"; not omitted).
  POST /api/search, POST /api/auth/login and POST /api/auth/logout stay
  public, and the read-only HUD surface is untouched.

Tests pin the pair per documented operation: the real app must answer 401 on
every operation that declares security, and the middleware must admit every
operation that declares []. Verified red on the untouched base (9 failures)
and green after the change.
2026-11-27 00:27:50 -05:00