public_paths.py 1.6 KB

123456789101112131415161718192021222324252627
  1. """Shared allowlist of ``/api/*`` paths that bypass dashboard auth. Imported by BOTH gates —
  2. ``web_server.auth_middleware`` (loopback / ``--insecure``) and
  3. ``dashboard_auth.middleware.gated_auth_middleware`` (OAuth cookie) — so the lists cannot drift
  4. again (a drift once 401'd ``/api/status`` and broke the portal's cookie-less liveness probe).
  5. Keep minimal: every entry must be safe for external uptime probes, the pre-login SPA, and anyone
  6. who ``curl``s the hostname; otherwise gate it and bootstrap after login."""
  7. from __future__ import annotations
  8. PUBLIC_API_PATHS: frozenset[str] = frozenset({
  9. # Minimal process liveness probe for desktop/backend boot handshakes; avoids
  10. # gateway config, platform discovery, MCP setup and cold plugin imports.
  11. "/api/health",
  12. # Portal wildcard liveness probe (``docs/agent-dashboard-public-url-contract.md``,
  13. # NAS side): version, gateway state, session count, auth-gate shape. No secrets.
  14. "/api/status",
  15. # Read-only config-defaults / schema feeds for the SPA's Config page.
  16. "/api/config/defaults",
  17. "/api/config/schema",
  18. # Read-only model metadata — same shape as public provider catalogs.
  19. "/api/model/info",
  20. # Read-only theme + plugin manifests for the dashboard skin engine.
  21. "/api/dashboard/themes",
  22. "/api/dashboard/plugins",
  23. # Chronos managed-cron fire webhook (NAS -> agent). NOT cookie-gated: it
  24. # carries its own short-lived NAS-minted JWT (purpose=cron_fire), which the
  25. # handler verifies — the JWT, not this allowlist, is the security boundary.
  26. "/api/cron/fire"})