diff --git a/Docker/compose.debug.yml b/Docker/compose.debug.yml index aa4f52b..7f32f5c 100644 --- a/Docker/compose.debug.yml +++ b/Docker/compose.debug.yml @@ -59,6 +59,7 @@ services: BANGUI_FAIL2BAN_SOCKET: "/var/run/fail2ban/fail2ban.sock" BANGUI_FAIL2BAN_CONFIG_DIR: "/config/fail2ban" BANGUI_LOG_LEVEL: "debug" + BANGUI_ENABLE_DOCS: "true" BANGUI_SESSION_SECRET: "${BANGUI_SESSION_SECRET:-dev-secret-do-not-use-in-production}" BANGUI_TIMEZONE: "${BANGUI_TIMEZONE:-UTC}" # Secure=false is intentional for local HTTP development. diff --git a/Docs/Backend-Development.md b/Docs/Backend-Development.md index 40c4a52..4dd98ed 100644 --- a/Docs/Backend-Development.md +++ b/Docs/Backend-Development.md @@ -834,6 +834,29 @@ BANGUI_FAIL2BAN_START_COMMAND='"/opt/my tools/fail2ban" start' # Quoted path **Common Pitfall:** Using `.split()` instead of `shlex.split()` would break commands with spaces in paths. Always use quoted strings for paths that contain whitespace. +### API Documentation Configuration + +The `enable_docs` setting controls whether FastAPI serves interactive API documentation at `/api/docs` (Swagger UI) and `/api/redoc` (ReDoc). + +**Default:** `false` — API documentation is disabled by default to prevent information disclosure in production. + +**When to Enable:** +- Set `BANGUI_ENABLE_DOCS=true` in development and debugging environments only. +- Never enable in production. Exposed API documentation reveals all endpoints, request/response schemas, and allows direct API invocation from the browser. + +**Environment Variables:** +```bash +BANGUI_ENABLE_DOCS="true" # Enable docs in development +BANGUI_ENABLE_DOCS="false" # Disable docs (default) +# Unset # Defaults to false (production) +``` + +**Debug Compose File:** +The `Docker/compose.debug.yml` sets `BANGUI_ENABLE_DOCS: "true"` for local development. Production compose files (`Docker/compose.prod.yml`) leave this unset, defaulting to `false`. + +**Middleware Allowlist:** +The `SetupRedirectMiddleware` in `main.py` includes `/api/docs`, `/api/redoc`, and `/api/openapi.json` in its `_ALWAYS_ALLOWED` paths so documentation can be accessed before setup completes (if enabled). + ### Log Path Validation & Allowlisting Authenticated users can instruct fail2ban to monitor additional log files through the API endpoint `POST /api/config/jails/{name}/logpath`. To prevent path-traversal attacks and unauthorized reads of sensitive system files, all requested log paths must resolve to locations within a configurable allowlist of safe directories. diff --git a/Docs/Tasks.md b/Docs/Tasks.md index b3f5244..b2bed74 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -1,77 +1,3 @@ -## TASK-024 — No CSRF protection on state-mutating endpoints - -**Severity:** High - -### Where found -All `POST`, `PUT`, `DELETE` routes in `backend/app/routers/`. Only `SameSite=Lax` on the session cookie provides any CSRF protection. - -### Why this is needed -`SameSite=Lax` blocks cross-site `