Remove the remaining Caddy references: Python is the edge

Caddy is gone from the platform and the standalone stacks; the backend is
its own edge (and Atrium's backend the platform's front door). Comments,
docstrings and current docs now describe that instead of naming Caddy;
leftover config lines (.gitattributes, CREDITS rows) go; dated records are
marked historical. Test names lose "Caddy" (CADDY_*_CSP -> PINNED_*_CSP);
no assertion changes, and the "no Caddy" guards stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 14:15:35 +02:00
co-authored by Claude Opus 5.5
parent 443514c5a2
commit 272ba44c1b
9 changed files with 52 additions and 52 deletions
+5 -5
View File
@@ -570,19 +570,19 @@ BOOTSTRAP_ADMIN_PASSWORD=… python scripts/walkthrough.py # drive the whole p
- **Console security:** `esc()` every dynamic value; bearer token in memory only, cookie session
primary; nothing loads from a CDN (the CSP has no third-party origins). `frame-src` names
Galena's origin only when `GALENA_EMBED` is on.
- **No Caddy, anywhere.** On the platform Atrium's backend is the front door and forwards
- **No reverse proxy, anywhere.** On the platform Atrium's backend is the front door and forwards
`/sygna/*` here with the prefix stripped (uvicorn's `--root-path "$ROOT_PATH"` puts it back);
standalone, `docker-compose.yml` publishes the backend on :8041 with nothing in front. The backend
is its own edge (`app/edge.py`, wired in `main.py`): it serves the console (`frontend/`,
`/frontend` in the image via the `frontend` build context) at `/` LAST, behind
`ConsoleUnlessApi`, so `/api/*` and `/healthz` never fall to it (unknown → 404 problem, wrong
method → 405 + `Allow`); any other GET for a missing file gets `index.html` (Caddy's
`try_files {path} /index.html`). `SecurityHeaders` (pure ASGI, outermost) stamps every response,
errors included, with Caddy's set (except Referrer-Policy, the family's `same-origin`):
method → 405 + `Allow`); any other GET for a missing file gets `index.html` (the SPA
fallback). `SecurityHeaders` (pure ASGI, outermost) stamps every response,
errors included:
nosniff, X-Frame-Options, `Referrer-Policy: same-origin`, `Cross-Origin-Opener-Policy: same-origin`; the console (not
the API — `/api/v1/docs` is Swagger from a CDN) also gets the CSP and `Cache-Control: no-cache`.
`FRAME_ANCESTORS` is `'none'` (default, XFO DENY) or `'self'` (SAMEORIGIN); anything else
refuses start-up. No HSTS (Caddy never sent one here). Also gzip (min 1000 B), a 100 MB
refuses start-up. No HSTS (this console has never sent one). Also gzip (min 1000 B), a 100 MB
request-body cap (`BodySizeLimit`, 413), and uvicorn `--proxy-headers --forwarded-allow-ips
"${FORWARDED_ALLOW_IPS:-127.0.0.1}" --no-server-header` — those flags live ONLY in
`backend/Dockerfile`'s CMD, never a compose `command:`. `FORWARDED_ALLOW_IPS` is never `*`
+8 -7
View File
@@ -5,7 +5,8 @@ Sibling application to **Galena**; designed from day one to merge into one share
- **License:** Apache-2.0 (same as Galena). Permissive-only dependency policy, enforced in CI.
- **Stack:** identical to Galena — FastAPI + SQLAlchemy 2 + Alembic + PostgreSQL 16, Argon2id +
server-side cookie sessions, a no-build static console (vanilla JS), Docker Compose + Caddy.
server-side cookie sessions, a no-build static console (vanilla JS), Docker Compose; the backend
is its own edge (`app/edge.py`), with no reverse proxy.
- **Supersedes:** §4 of [`docs/CRMecenas-Discovery-Report.md`](docs/CRMecenas-Discovery-Report.md).
The discovery report's requirements analysis (§3) still stands; its *technology* recommendation
(Atomic CRM / react-admin / a hosted Postgres BaaS) is withdrawn — see §1.2.
@@ -124,9 +125,9 @@ merge requirement, not a follow-up.
### Infrastructure
```
docker-compose.yml postgres:16 → migrate(+seed) → backend → caddy:2 (only Caddy published)
docker-compose.yml postgres:16 → migrate(+seed) → backend (only the backend published)
db/init/01-roles.sh creates the least-privilege `app` and `migrator` roles
Caddyfile TLS + static console + reverse proxy to the backend
backend/app/edge.py the backend's own edge: static console, security headers, gzip, body cap
.github/workflows pytest (+ coverage) on a Postgres service, then scripts/license_gate.py
```
@@ -633,7 +634,7 @@ sygna/
frontend/ index.html · app.css · app.js · sw.js (no build)
db/init/01-roles.sh
docs/CRMecenas-Discovery-Report.md
docker-compose.yml · Caddyfile · .env.example · .github/workflows/ci.yml
docker-compose.yml · .env.example · .github/workflows/ci.yml
PLAN.md · SHARED.md (Galena sync list) · CLAUDE.md · README.md · LICENSE (Apache-2.0)
```
@@ -665,8 +666,8 @@ sygna/
## 10. Roadmap
**Phase 1 — the spine.** ✅ **Done (Aug 2026).** Repo scaffold mirroring Galena (compose, Caddy,
roles, CI, licence gate). Copied identity/node/authz/errors layer. `party` (+aliases, links),
**Phase 1 — the spine.** ✅ **Done (Aug 2026).** Repo scaffold mirroring Galena (compose, a reverse proxy since retired for the
backend's own edge, roles, CI, licence gate). Copied identity/node/authz/errors layer. `party` (+aliases, links),
`matter`, `matter_party`, `ethical_wall`, `conflict_check`, `lead`, `deadline`, `court_event`,
`time_entry` — 18 tables, 70 routes. Console in Polish: pulpit, matters, matter detail
(parties / deadlines / time / access), parties, intake, timesheet, admin. Conflict check at
@@ -709,7 +710,7 @@ the schedules as auditable data. The figures still need checking against the cur
must be established before Phase 4 can be scheduled.
**Decided (2026-08-13)**
- **Deployment: self-hosted, as Galena.** Docker Compose + Caddy, no managed dependency. A hosted
- **Deployment: self-hosted, as Galena.** Docker Compose (the backend is its own edge), no managed dependency. A hosted
offering may follow but never replaces the self-hosted path — it is what makes `tajemnica
adwokacka` defensible.
- **Shared code: a separately-versioned package.** ~~vendor + enforce, then merge~~ —
+2 -2
View File
@@ -33,8 +33,8 @@ COPY --from=build /install /usr/local
WORKDIR /app
COPY . .
# The static console, which this backend now serves itself (app/main.py mounts it at "/"; there is
# no Caddy in front any more). It lives in the repo's frontend/, outside this build context, so it
# The static console, which this backend now serves itself (app/main.py mounts it at "/"; nothing
# stands in front of it). It lives in the repo's frontend/, outside this build context, so it
# arrives as a NAMED build context: compose passes `additional_contexts: { frontend: ./frontend }`,
# and a bare build from backend/ needs `docker build --build-context frontend=../frontend .`.
# /frontend is exactly where main.py's default (two levels above app/main.py) looks.
+1 -1
View File
@@ -242,7 +242,7 @@ class Settings(BaseSettings):
# CSP `frame-ancestors` on the console, and the matching X-Frame-Options on every response this
# backend sends (app/edge.py). `'none'` (the default) = nobody may frame Sygna (X-Frame-Options:
# DENY), what Caddy sent before this backend served its own console. `'self'` = only this
# DENY), the safe default. `'self'` = only this
# origin may (SAMEORIGIN), for a platform page that embeds Sygna. Nothing else: an origin list
# cannot be expressed in X-Frame-Options, and a typo here must not quietly widen framing, so
# anything else refuses start-up. The quotes are optional (an .env loader may strip them).
+14 -15
View File
@@ -1,9 +1,9 @@
"""What Caddy used to do in front of this backend: security headers, the body cap, the console.
"""This backend's own edge: security headers, the body cap, the console.
The platform no longer runs Caddy. Atrium's backend is the front door and forwards `/sygna/*` here
with the prefix stripped (exactly as `handle_path /sygna/*` did), and a standalone install publishes
uvicorn on host port 8041 with nothing in front. Either way this process now answers for everything a browser
gets, so the rules Sygna's Caddyfile applied live here, unchanged in substance. Same shape as
There is no reverse proxy in front of any module. On the platform Atrium's backend is the front door
(its `app/frontdoor.py`) and forwards `/sygna/*` here with the prefix stripped (uvicorn's
`--root-path` puts it back), and a standalone install publishes uvicorn on host port 8041 with
nothing in front. Either way this process answers for everything a browser gets. Same shape as
Counsel Scorecard's `app/edge.py`.
**Every path comparison reads the ROUTE path** (`starlette._utils.get_route_path`), never
@@ -24,13 +24,12 @@ from starlette.routing import BaseRoute, Match
from starlette.staticfiles import StaticFiles
from starlette.types import ASGIApp, Message, Receive, Scope, Send
# Paths the backend owns. Caddy's split was `@api path /api/v1/* /healthz` → backend, everything
# else → the static console; nothing under these is ever answered by the console. `/api` as a
# Paths the backend owns; everything else is the static console. Nothing under these is ever answered by the console. `/api` as a
# whole rather than `/api/v1` only: an `/api/v2/x` that renders the console's HTML with a 200 is a
# misleading answer to a client, not a deep link.
API_PATHS = ("/api", "/healthz")
# The owner's ceiling for one request body. Caddy set none. It bounds memory; it does not shape the
# The owner's ceiling for one request body. It bounds memory; it does not shape the
# API (document and template uploads keep their own, smaller limits).
MAX_BODY_BYTES = 100 * 1024 * 1024
@@ -40,7 +39,7 @@ def owns_path(path: str) -> bool:
def content_security_policy(frame_ancestors: str, frame_src: str = "'self'") -> str:
"""The console's policy: Sygna's Caddyfile CSP, plus `frame-src`, with frame-ancestors from the
"""The console's policy (pinned by tests/test_edge.py), with frame-ancestors from the
setting. 'unsafe-inline' is required by the theme pre-paint inline <script> and the inline
style="" attributes in index.html. Nothing loads from a CDN — Sygna's console is entirely
same-origin, which is the point when the data is privileged. `frame-src` names Galena's origin
@@ -69,18 +68,18 @@ def _problem(scope: Scope, status: int, title: str, detail: str,
class SecurityHeaders:
"""Caddy's `header { ... }` block, on every response — console, API, 404, 405, 413 and 500.
"""The security headers, on every response — console, API, 404, 405, 413 and 500.
Pure ASGI (not `@app.middleware("http")`) so it wraps the responses the other middlewares
produce and a streamed body is not buffered. Added LAST in main.py, i.e. outermost. Headers are
SET, as Caddy's `header` directive set them, not defaulted.
SET, not defaulted.
Everywhere: nosniff, X-Frame-Options (DENY for `'none'`, SAMEORIGIN for `'self'`),
`Referrer-Policy: same-origin`, `Cross-Origin-Opener-Policy: same-origin`.
On the console only (anything outside /api and /healthz), as Caddy's `handle` block had them:
On the console only (anything outside /api and /healthz):
the CSP and `Cache-Control: no-cache` (revalidate by ETag, so a rebuilt app.js/app.css is picked
up without a hard refresh). Not on the API: /api/v1/docs is Swagger UI from a CDN, which the
console's policy would blank. No HSTS — Sygna's Caddyfile never sent one. The `Server` header is
console's policy would blank. No HSTS — Sygna has never sent one. The `Server` header is
not removed here; uvicorn runs with --no-server-header.
"""
@@ -174,9 +173,9 @@ class BodySizeLimit:
class SpaStaticFiles(StaticFiles):
"""Caddy's `try_files {path} /index.html` + `file_server`: a GET/HEAD for a file that does not
"""The SPA fallback: a GET/HEAD for a file that does not
exist gets the console's index.html (200), so a deep link survives a reload. Other methods keep
StaticFiles' 405, as file_server answered."""
StaticFiles' 405."""
async def get_response(self, path: str, scope: Scope) -> Response:
try:
+4 -4
View File
@@ -196,15 +196,15 @@ def healthz(deep: bool = False) -> dict:
return {"status": "ok", "database": True}
# Caddy's `encode gzip`. Inside SecurityHeaders, so compressed responses carry the headers too.
# Gzip. Inside SecurityHeaders, so compressed responses carry the headers too.
app.add_middleware(GZipMiddleware, minimum_size=1000)
# Caddy's `header { ... }` block. Added LAST, so it is the outermost middleware and also stamps the
# The security headers. Added LAST, so it is the outermost middleware and also stamps the
# responses every other layer produces — 404, 405, 413 and the 500 problem response included.
app.add_middleware(SecurityHeaders, frame_ancestors=settings.frame_ancestors, frame_src=_FRAME_SRC)
# The static console (frontend/), which Caddy used to serve from /srv. Mounted at "/" LAST so every
# The static console (frontend/). Mounted at "/" LAST so every
# API route wins, behind ConsoleUnlessApi so /api/* and /healthz never fall through to it (see its
# docstring), with Caddy's `try_files {path} /index.html` SPA fallback. SYGNA_FRONTEND_DIR overrides
# docstring), with the `index.html` SPA fallback. SYGNA_FRONTEND_DIR overrides
# the location; the default is the repo's ../frontend, which is also where backend/Dockerfile copies
# it (/frontend in the image). Absent (a bare API checkout), the backend simply serves no console.
_FRONTEND = Path(os.environ.get("SYGNA_FRONTEND_DIR")
+1 -1
View File
@@ -132,7 +132,7 @@ check("ARG DREDD_CORE_TOKEN" not in dockerfile and "ENV DREDD_CORE_TOKEN" not in
check("dredd_core_token" in compose and "environment: DREDD_CORE_TOKEN" in compose,
"compose does not pass DREDD_CORE_TOKEN to the build as a secret")
# ── the backend's own edge matches what Caddy did ─────────────────────────────
# ── the backend's own edge is wired as documented ─────────────────────────────
prefix = re.search(r'API_PREFIX = "([^"]+)"', main_py)
check(bool(prefix), "cannot find API_PREFIX in main.py")
if prefix:
+16 -16
View File
@@ -1,4 +1,4 @@
"""DB-free tests for what Caddy used to do in front of the backend (`app/edge.py`, `main.py`).
"""DB-free tests for the backend's own edge (`app/edge.py`, `main.py`).
The backend now serves its own console, sets its own security headers and answers /healthz, both as
a platform module (Atrium forwards /sygna/* with the prefix stripped, uvicorn re-adds it via
@@ -16,9 +16,9 @@ from app.edge import MAX_BODY_BYTES, BodySizeLimit, SecurityHeaders, content_sec
from app.errors import ProblemDetailErrorMiddleware
from app.main import _FRONTEND, app
# Sygna's Caddyfile CSP, character for character, with the `frame-src 'self'` the backend has
# always added (Caddy's policy had none, so default-src 'self' applied: the same thing, spelled out).
CADDY_CSP = ("default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; "
# The console's pinned CSP, character for character (`frame-src 'self'` spelled out, though
# default-src 'self' would imply it).
PINNED_CSP = ("default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; "
"frame-src 'self'; form-action 'self'; img-src 'self' data: blob:; "
"font-src 'self' data:; style-src 'self' 'unsafe-inline'; "
"script-src 'self' 'unsafe-inline'; connect-src 'self'")
@@ -27,15 +27,15 @@ client = TestClient(app)
INDEX = (_FRONTEND / "index.html").read_bytes()
def _assert_caddy_headers(resp, *, console: bool) -> None:
"""Caddy's `header { }` block on everything; its console `handle` added CSP + Cache-Control."""
def _assert_edge_headers(resp, *, console: bool) -> None:
"""The security headers on everything; the console also gets CSP + Cache-Control."""
h = resp.headers
assert h["x-content-type-options"] == "nosniff"
assert h["x-frame-options"] == "DENY"
assert h["referrer-policy"] == "same-origin"
assert h["cross-origin-opener-policy"] == "same-origin"
if console:
assert h["content-security-policy"] == CADDY_CSP
assert h["content-security-policy"] == PINNED_CSP
assert h["cache-control"] == "no-cache"
else:
assert "content-security-policy" not in h
@@ -46,8 +46,8 @@ def _assert_caddy_headers(resp, *, console: bool) -> None:
# ── headers on every kind of response ─────────────────────────────────────────
def test_default_csp_is_caddys_policy():
assert content_security_policy("'none'") == CADDY_CSP
def test_default_csp_is_the_pinned_policy():
assert content_security_policy("'none'") == PINNED_CSP
@pytest.mark.parametrize("method,path,status,console", [
@@ -67,7 +67,7 @@ def test_default_csp_is_caddys_policy():
def test_every_response_carries_the_headers(method, path, status, console):
resp = client.request(method, path)
assert resp.status_code == status
_assert_caddy_headers(resp, console=console)
_assert_edge_headers(resp, console=console)
def test_headers_on_a_500():
@@ -82,14 +82,14 @@ def test_headers_on_a_500():
resp = TestClient(inner, raise_server_exceptions=False).get("/api/boom")
assert resp.status_code == 500
assert resp.headers["content-type"] == "application/problem+json"
_assert_caddy_headers(resp, console=False)
_assert_edge_headers(resp, console=False)
def test_headers_on_a_413():
resp = client.post("/api/v1/auth/login", content=b"",
headers={"content-length": str(MAX_BODY_BYTES + 1)})
assert resp.status_code == 413
_assert_caddy_headers(resp, console=False)
_assert_edge_headers(resp, console=False)
def test_galena_embed_widens_frame_src_only():
@@ -175,7 +175,7 @@ def test_gzip_on_large_responses():
assert len(INDEX) > 1000
resp = client.get("/", headers={"accept-encoding": "gzip"})
assert resp.headers.get("content-encoding") == "gzip"
_assert_caddy_headers(resp, console=True)
_assert_edge_headers(resp, console=True)
# ── behind the platform: ROOT_PATH=/sygna ─────────────────────────────────────
@@ -185,17 +185,17 @@ def test_root_path_prefix_still_routes_console_and_api():
prefixed = TestClient(app, root_path="/sygna")
console = prefixed.get("/sygna/matters/1")
assert console.status_code == 200 and console.content == INDEX
_assert_caddy_headers(console, console=True)
_assert_edge_headers(console, console=True)
assert prefixed.get("/sygna/").content == INDEX
api = prefixed.get("/sygna/api/v1/health")
assert api.status_code == 200 and api.json()["service"] == "sygna"
_assert_caddy_headers(api, console=False)
_assert_edge_headers(api, console=False)
assert prefixed.get("/sygna/healthz").status_code == 200
miss = prefixed.get("/sygna/api/v1/nope")
assert miss.status_code == 404
assert miss.headers["content-type"] == "application/problem+json"
assert miss.json()["instance"] == "/sygna/api/v1/nope"
_assert_caddy_headers(miss, console=False)
_assert_edge_headers(miss, console=False)
wrong = prefixed.post("/sygna/api/v1/health")
assert wrong.status_code == 405 and wrong.headers["allow"] == "GET"
+1 -1
View File
@@ -3,7 +3,7 @@
* Loaded ONLY on the demo deployment: the Netlify build injects it before app.js when no
* SYGNA_BACKEND_URL is configured (see netlify/prepare.sh). It patches window.fetch, answers every
* /api/v1/* call from a seeded dataset kept in localStorage, and never ships in a real deployment
* — the Docker/Caddy build serves index.html without this <script>, so it cannot weaken a real
* — the Docker build serves index.html without this <script>, so it cannot weaken a real
* backend.
*
* It is a SIMULATION of a small Polish firm, not a sandbox of the real thing. Reads are complete