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:
@@ -7,5 +7,4 @@
|
||||
*.html text eol=lf
|
||||
*.md text eol=lf
|
||||
*.yml text eol=lf
|
||||
Caddyfile text eol=lf
|
||||
Dockerfile text eol=lf
|
||||
|
||||
@@ -362,20 +362,20 @@ python -m dredd_core.managed provision --sql-only --schema atrium --app-role atr
|
||||
components are optional sidecars, never core.
|
||||
- **No build step for the console.**
|
||||
- **Atrium is the platform's front door (`backend/app/frontdoor.py`, the image's CMD
|
||||
`uvicorn app.frontdoor:outer`).** It replaces Caddy: `/` → 302 `/atrium/`, exact `/<slug>` → 308
|
||||
`uvicorn app.frontdoor:outer`).** It is the only edge, with no reverse proxy in front: `/` → 302 `/atrium/`, exact `/<slug>` → 308
|
||||
`/<slug>/`, Atrium itself via Starlette `Mount("/atrium")` (which sets `root_path` in-process — no
|
||||
`--root-path`; `ROOT_PATH` must be empty or `/atrium`), every other module streamed by one
|
||||
`httpx.AsyncClient` per worker to the FIXED `FRONTDOOR_UPSTREAMS` map (never from the request), and
|
||||
Caddy's plain 404 for the rest. Keep: the raw-path refusals (`%2f %5c %2e %00`, `\`, NUL, `.`/`..`
|
||||
the platform's plain 404 (`NOT_FOUND`) for the rest. Keep: the raw-path refusals (`%2f %5c %2e %00`, `\`, NUL, `.`/`..`
|
||||
segments, non-origin-form targets → 400) checked on `raw_path` BEFORE routing and the raw path
|
||||
forwarded byte-exact minus the prefix; Host unchanged (the modules' Origin-vs-Host guard), inbound
|
||||
`X-Forwarded-*`/`Forwarded` dropped and set anew; hop-by-hop + `Server` stripped both ways;
|
||||
Content-Encoding passed through (`aiter_raw`); nothing buffered; 100 MB cap; a `Location` naming an
|
||||
internal upstream → 502; uvicorn `--no-proxy-headers` (this is the edge — the peer IS the client).
|
||||
Its own responses carry Atrium's headers (DENY); proxied ones carry only the module's. The
|
||||
standalone `docker-compose.yml` runs the SAME CMD with no Caddy: backend on `80:8000`,
|
||||
standalone `docker-compose.yml` runs the SAME CMD with no proxy: backend on `80:8000`,
|
||||
`FRONTDOOR_UPSTREAMS` empty, Atrium at `/atrium` (CI's compose-smoke curls `/atrium/...` and the
|
||||
redirects). There is no root `Caddyfile` any more; never add a compose `command:` override.
|
||||
redirects). There is no reverse-proxy config file and no proxy service; never add one, and never add a compose `command:` override.
|
||||
Tests: `tests/test_frontdoor.py`, ASGI-level so `..` and encodings reach the code unnormalised.
|
||||
- **Path-mounting is ONE decision, taken in two places.** The family serves one module per path on
|
||||
one origin. For Atrium the front door's `Mount("/atrium")` takes both halves at once (it routes on
|
||||
|
||||
+3
-3
@@ -42,8 +42,8 @@ COPY . .
|
||||
RUN useradd -m app && chown -R app /app
|
||||
USER app
|
||||
|
||||
# The console ships IN the image: Atrium serves it itself, there is no Caddy to mount it from any
|
||||
# more. It comes from the build's second context, `frontend` - compose passes
|
||||
# The console ships IN the image: Atrium serves it itself (there is no proxy to serve it from).
|
||||
# It comes from the build's second context, `frontend` - compose passes
|
||||
# `additional_contexts: { frontend: ../frontend }`; by hand:
|
||||
# docker build --build-context frontend=../frontend backend
|
||||
COPY --from=frontend . /frontend
|
||||
@@ -59,7 +59,7 @@ HEALTHCHECK --interval=15s --timeout=5s --retries=10 CMD python -c "import url
|
||||
# the peer address is the client, and that is what client_ip() and the audit
|
||||
# log record. (The front door drops inbound X-Forwarded-* and sets them anew
|
||||
# for the modules, which trust them only from this container.)
|
||||
# --no-server-header Caddy's `-Server`.
|
||||
# --no-server-header no `Server` header naming the software on the platform's edge.
|
||||
# --timeout-keep-alive 5, --limit-concurrency an idle or flooding client cannot pin a worker; past
|
||||
# the limit uvicorn answers 503 instead of queueing without bound.
|
||||
# No --root-path: Mount("/atrium") sets Atrium's root_path in-process. ROOT_PATH must be empty or
|
||||
|
||||
@@ -28,12 +28,12 @@ class Settings(BaseSettings):
|
||||
app_env: str = "production"
|
||||
|
||||
# Where this app is served from, when the family runs one module per path on one origin:
|
||||
# ROOT_PATH=/atrium behind Caddy's `handle_path /atrium/*`. Empty (the default) means this app
|
||||
# owns the root, which is the standalone and dev layout. Stripping in Caddy and re-adding here
|
||||
# are ONE decision, never taken separately: `handle_path` removes the prefix before the backend
|
||||
# sees the request, and uvicorn's --root-path is what puts it back on every URL the server
|
||||
# generates. Strip without it and redirects escape the prefix; add it without stripping and the
|
||||
# prefix is doubled and nothing routes.
|
||||
# ROOT_PATH=/atrium. Empty (the default) means this app owns the root, which is the standalone and
|
||||
# dev layout. Behind the front door (app/frontdoor.py) Atrium is mounted in-process with
|
||||
# Starlette's `Mount("/atrium")`, which strips the prefix from the route path and sets `root_path`
|
||||
# itself, so every URL the server generates stays inside the prefix; no `--root-path` is passed.
|
||||
# That is why only empty or `/atrium` is accepted: any other value would disagree with the mount,
|
||||
# and redirects would escape the prefix or the prefix would be doubled and nothing would route.
|
||||
root_path: str = ""
|
||||
|
||||
@field_validator("root_path")
|
||||
@@ -73,7 +73,7 @@ class Settings(BaseSettings):
|
||||
# The FIXED map of the modules this edge proxies to: `slug=http://service:port`, comma-separated,
|
||||
# e.g. "galena=http://galena-backend:8000,sygna=http://sygna-backend:8000". It is the only place an
|
||||
# upstream address ever comes from; nothing in a request can choose one (no SSRF). A slug left out
|
||||
# answers the platform's plain 404, exactly as Caddy did for a block that was not there. Parsed and
|
||||
# answers the platform's plain 404, the same answer as a path no module claims. Parsed and
|
||||
# validated when the front door is built, so a typo refuses start-up instead of 404ing a module.
|
||||
frontdoor_upstreams: str = ""
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""The platform's front door: the one ASGI app the container runs (`uvicorn app.frontdoor:outer`).
|
||||
|
||||
It replaces Caddy. What Caddy did for the family, this does, and nothing more:
|
||||
It is the platform's only edge; there is no reverse proxy in front of it. It does this, and nothing more:
|
||||
|
||||
* `/` answers 302 to `/atrium/` (302, not 308: which module is the front page is a decision that may
|
||||
change, and a permanent redirect outlives it in every browser cache that saw it);
|
||||
@@ -8,11 +8,10 @@ It replaces Caddy. What Caddy did for the family, this does, and nothing more:
|
||||
bare `/galena` has the document base `/`, so its relative assets and its API base would resolve to
|
||||
the platform root and load Atrium's console into Galena's page;
|
||||
* `/atrium/...` is Atrium itself, mounted in-process at `/atrium` (Starlette's Mount sets
|
||||
`root_path`, so every URL Atrium generates stays inside the prefix - the job uvicorn's
|
||||
`--root-path` did while Caddy stripped the prefix);
|
||||
`root_path`, so every URL Atrium generates stays inside the prefix, with no `--root-path`);
|
||||
* `/<module>/...` streams to that module's backend, from a FIXED map (`FRONTDOOR_UPSTREAMS`). The
|
||||
upstream never comes from the request;
|
||||
* anything else gets Caddy's plain-text 404, word for word.
|
||||
* anything else gets the platform's plain-text 404 (`NOT_FOUND`).
|
||||
|
||||
Every module serves its own console and stamps its own security headers (each one's `edge.py`), so
|
||||
proxied responses pass through untouched apart from hop-by-hop headers and `Server`. What this file
|
||||
@@ -208,7 +207,7 @@ class FrontDoor:
|
||||
base = self.upstreams.get(slug) if _SLUG_RE.match(slug) else None
|
||||
if base is None:
|
||||
# Unknown, and known-but-unconfigured alike: this deployment does not serve that path,
|
||||
# which is what Caddy said for a module with no block. 503 would promise it comes back.
|
||||
# so it gets the platform's plain 404. 503 would promise it comes back.
|
||||
await _respond(send, 404, [(b"content-type", b"text/plain; charset=utf-8")], NOT_FOUND)
|
||||
return
|
||||
await self._proxy(scope, receive, send, base, raw[1 + len(head):])
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ app = FastAPI(
|
||||
redoc_url=None,
|
||||
openapi_url=f"{API_PREFIX}/openapi.json",
|
||||
# The path this app is mounted at, when the family serves one module per path on one origin
|
||||
# (ROOT_PATH=/atrium behind Caddy's `handle_path /atrium/*`). Empty when it owns the root.
|
||||
# (ROOT_PATH=/atrium behind the front door's `Mount("/atrium")`). Empty when it owns the root.
|
||||
# uvicorn is told the same value on the command line and that is what does the real work — it
|
||||
# puts the prefix back on scope["path"], so every URL Starlette generates (slash redirects,
|
||||
# StaticFiles directory redirects) stays inside the prefix. Setting it here as well is what
|
||||
|
||||
@@ -320,20 +320,20 @@ class TestTheDeployReadmeDescribesTheWorldThatExists:
|
||||
class TestThePlainHttpCommentIsTrue:
|
||||
"""A comment read by whoever runs a plain-HTTP trial. It named a setting as required for
|
||||
sign-in; the flag has been auto-detected from the request scheme for a while, and after the
|
||||
cutover Counsel sets no session cookie at all — the hub does. It lived in deploy/Caddyfile; with
|
||||
Caddy gone it lives beside the site address in deploy/.env.example."""
|
||||
cutover Counsel sets no session cookie at all — the hub does. It lives beside the site address in
|
||||
deploy/.env.example."""
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def caddyfile(self) -> str:
|
||||
def env_example(self) -> str:
|
||||
return (DEPLOY / ".env.example").read_text(encoding="utf-8")
|
||||
|
||||
def test_it_no_longer_claims_sign_in_depends_on_it(self, caddyfile):
|
||||
assert "or its sign-in" not in caddyfile
|
||||
assert "the other three follow the request's scheme on their own" not in caddyfile
|
||||
def test_it_no_longer_claims_sign_in_depends_on_it(self, env_example):
|
||||
assert "or its sign-in" not in env_example
|
||||
assert "the other three follow the request's scheme on their own" not in env_example
|
||||
|
||||
def test_it_says_what_is_true_instead(self, caddyfile):
|
||||
assert "auto-detect" in caddyfile
|
||||
assert "SESSION_COOKIE_SECURE=false" in caddyfile, "init.sh still writes it; say so"
|
||||
def test_it_says_what_is_true_instead(self, env_example):
|
||||
assert "auto-detect" in env_example
|
||||
assert "SESSION_COOKIE_SECURE=false" in env_example, "init.sh still writes it; say so"
|
||||
|
||||
def test_the_backend_really_does_auto_detect(self):
|
||||
"""Asserted against the pinned module's own source rather than trusted: the comment is only
|
||||
|
||||
@@ -90,7 +90,7 @@ def test_its_urls_carry_the_passwords_db_env_now_holds(box):
|
||||
def test_the_site_comes_from_the_deployment(box):
|
||||
assert _init("--add", "compass", "--into", str(box)).returncode == 0
|
||||
site = _env_values(box / ".env")["ATRIUM_DOMAIN"]
|
||||
# The per-app *_DOMAIN keys fed only Caddy: --add no longer writes one.
|
||||
# There are no per-app *_DOMAIN keys: --add must not write one.
|
||||
assert "COMPASS_DOMAIN" not in _env_values(box / ".env")
|
||||
assert _env_values(box / "env" / "compass.env")["APP_BASE_URL"] == f"{site}/compass"
|
||||
|
||||
|
||||
+2
-3
@@ -10,10 +10,9 @@
|
||||
|
||||
# THE SITE ADDRESS — ONE for the whole family. atrium-backend is the front door: one site with one
|
||||
# module per path (/atrium, /galena, /sygna, /counsel, /compass). Nothing in compose.yaml reads this key
|
||||
# any more (there is no Caddy to hand it to); it is the deployment's record of its own address, which
|
||||
# any more (the front door needs no host name); it is the deployment's record of its own address, which
|
||||
# `init.sh --add` reads back to write an added module's public addresses, and which the TLS step will
|
||||
# use. The per-app GALENA_DOMAIN / SYGNA_DOMAIN / COUNSEL_DOMAIN / COMPASS_DOMAIN keys fed only Caddy and
|
||||
# are gone; on a box that still has them they are unread and harmless.
|
||||
# use. There are no per-app address keys: on a box that still has old ones they are unread and harmless.
|
||||
# Point the address at the server's public IPv4 (and IPv6) before `up`. The platform serves plain HTTP
|
||||
# on :80 until the TLS step (a certificate in uvicorn, a certbot sidecar). init.sh --ip writes
|
||||
# http://dredd.<ip>.sslip.io (sslip.io resolves it to the IP with no DNS of yours), and writes
|
||||
|
||||
+4
-7
@@ -180,8 +180,7 @@ file names and where each secret is, never a value:
|
||||
> (Galena's git repositories, which are not in the database), `sygna-data` and `compass-data`.
|
||||
> `docker compose down` without `-v` keeps all of them.
|
||||
|
||||
- **`deploy/.env`** — the site address (`ATRIUM_DOMAIN`; the per-app `*_DOMAIN` keys fed only Caddy and
|
||||
are gone, and Galena's `GALENA_PUBLIC_URL` moved to `env/galena.env`), `MODULES_DIR`, `LOCAL_DB_NAME` (`dredd`, the one database
|
||||
- **`deploy/.env`** — the site address (`ATRIUM_DOMAIN`, the one address key; Galena's `GALENA_PUBLIC_URL` moved to `env/galena.env`), `MODULES_DIR`, `LOCAL_DB_NAME` (`dredd`, the one database
|
||||
all four apps share: the `postgres` service's `POSTGRES_DB` and the database every URL connects to)
|
||||
and **`POSTGRES_PASSWORD`**, the superuser's, generated. `initdb` applies it on the **first** start
|
||||
only; changing it later is `ALTER ROLE postgres PASSWORD` inside the container, not an edit here. With
|
||||
@@ -885,12 +884,10 @@ platform-wide guarantee rather than a Galena one.
|
||||
|
||||
**Each module sends its own headers.** Every module serves its console from its own image and stamps
|
||||
its security headers on every response, errors included; each module's `tests/test_edge.py` pins the
|
||||
values that Caddy used to send. The kit's part is the one switch, `FRAME_ANCESTORS='self'` in
|
||||
`compose.yaml`, and `preflight.sh` step 4 checks that each pinned module still has it (the old
|
||||
`caddy_drift.py` compared Caddyfiles, which no longer exist). Galena's ReaderJS viewer
|
||||
values it sends. The kit's part is the one switch, `FRAME_ANCESTORS='self'` in
|
||||
`compose.yaml`, and `preflight.sh` step 4 checks that each pinned module still has it. Galena's ReaderJS viewer
|
||||
(`/static/readerjs/`) keeps its own `SAMEORIGIN` policy whatever the switch says. Galena renders its own
|
||||
link-preview tags from `GALENA_PUBLIC_URL` (`env/galena.env`, carrying `/galena`), which Caddy's
|
||||
`templates` used to do. Counsel's `Strict-Transport-Security` is now sent only over HTTPS. Embedding
|
||||
link-preview tags from `GALENA_PUBLIC_URL` (`env/galena.env`, carrying `/galena`). Counsel's `Strict-Transport-Security` is now sent only over HTTPS. Embedding
|
||||
Galena in Sygna (`GALENA_EMBED`) is still not offered by the kit: `'self'` makes it possible at one
|
||||
origin, but turning it on is a separate, tested change. (`GALENA_FRAME_ANCESTORS` is retired; Galena
|
||||
refuses to start with it set.)
|
||||
|
||||
+1
-1
@@ -361,7 +361,7 @@ write_app_files() {
|
||||
case $app in
|
||||
galena)
|
||||
set_key "$runtime" APP_BASE_URL "$PUBLIC/galena"
|
||||
# Galena renders its own link-preview tags now (Caddy's `templates` did): the address must carry
|
||||
# Galena renders its own link-preview tags from this address, so it must carry
|
||||
# the module's path, or every shared link would unfurl as the platform root.
|
||||
set_key "$runtime" GALENA_PUBLIC_URL "$PUBLIC/galena"
|
||||
set_key "$runtime" ENCRYPTION_MASTER_KEY "$ENCRYPTION_MASTER_KEY" ;;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
`deploy/compose.yaml` builds Galena, Sygna and Counsel Scorecard from `${MODULES_DIR}/galena`,
|
||||
`${MODULES_DIR}/sygna` and `${MODULES_DIR}/counsel` (and Compass from `${MODULES_DIR}/compass/apps/compass`),
|
||||
each image with a second build context, `frontend`, the module's console, which the image serves itself
|
||||
(there is no Caddy to mount it from). Atrium itself is the repository this directory is in.
|
||||
each image with a second build context, `frontend`, the module's console, which the image serves itself. Atrium itself is the repository this directory is in.
|
||||
`MODULES_DIR` is set in `deploy/.env`, which Compose, `push.sh` and `preflight.sh` all read (`init.sh
|
||||
--modules-dir` writes it).
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
# merged (Option B, a managed PostgreSQL provider), each with its own assertions on the rendered
|
||||
# model (lib/compose_checks.py): no reverse proxy, atrium-backend the front door and the only
|
||||
# published port, each module trusting forwarded headers from its own subnet with FRAME_ANCESTORS='self'
|
||||
# 3. (no step: the Caddyfile and its validation are gone with Caddy)
|
||||
# 3. (no step: retired)
|
||||
# 4. header parity: every module checkout exposes the FRAME_ANCESTORS switch ('none' by default, 'self'
|
||||
# allowed, nothing else) in its config and stamps SAMEORIGIN for 'self' in its edge, so the kit's
|
||||
# FRAME_ANCESTORS='self' lands on a setting that exists; Galena's retired GALENA_FRAME_ANCESTORS is
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
|
||||
/* The API is under THIS document's base, not the site root. The family serves one module per path on
|
||||
one origin, so a root-absolute '/api/v1' would leave this module and land on a sibling's backend.
|
||||
document.baseURI is whatever we are served from — '/' standalone, '/atrium/' behind Caddy's
|
||||
`handle_path /atrium/*` — which is the same reason every asset in index.html is relative. Routing
|
||||
document.baseURI is whatever we are served from — '/' standalone, '/atrium/' behind the front
|
||||
door's `Mount("/atrium")` — which is the same reason every asset in index.html is relative. Routing
|
||||
is hash-based, so the base never moves as you navigate. */
|
||||
const API = new URL('api/v1', document.baseURI).pathname;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user