Run sessions-web behind Authelia, configured only by env vars

Drop the app's own login (password hash, signed cookies, CSRF tokens, rate
limiting): Authelia via Caddy forward_auth is the login. The app refuses any
request without the Remote-User header (optionally limited to
SESSIONS_ALLOWED_USERS) and any cross-site POST (Sec-Fetch-Site / Origin).

The SSH key and the dev box host key now come from environment variables
printed by `sessions-ctl keygen`, so the container needs no secrets store or
mounts. Add compose.yaml so prod's panel can build and deploy it; remove the
Quadlet unit and the files it needed. README covers the panel deploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKYfRST9cTJYae3f7Jf3ac
This commit is contained in:
agent 2026-09-30 14:39:56 +00:00
parent ca66db3aeb
commit b55ea07c96
9 changed files with 254 additions and 332 deletions

View file

@ -8,13 +8,18 @@ model" before changing anything that touches the SSH boundary.
- `dev/` runs on the **dev box**: `sessions_ctl.py` (installed as
`~/.local/bin/sessions-ctl`), systemd user units, `install.sh`.
- `web/` runs on **prod** in a rootless Podman container: `app.py`,
`Containerfile`, Quadlet unit `sessions-web.container`.
`Containerfile`. `compose.yaml` at the root is what prod's panel deploys.
Configured only through env vars; `sessions-ctl keygen` prints them.
## Stack and conventions
- Python ≥ 3.11, **standard library only** on both sides. No pip install, so
there's no supply chain to audit. Keep it that way unless there's a strong reason.
- The web page has **no JavaScript**. Plain forms, POST, then a redirect.
- `sessions-ctl` always prints exactly one JSON object; exit 0/1/2.
- `sessions-ctl` prints exactly one JSON object (except `keygen`: KEY=VALUE
lines on stdout, human note on stderr); exit 0/1/2.
- The web app has no login: Authelia (Caddy forward_auth) in front of it is
the login. It must keep refusing requests without the auth header, and
refusing cross-site POSTs.
- The dev port for local work on the web app is **8470**, bound to 127.0.0.1.
Preview via `ssh -p 14922 -L 8470:localhost:8470 <dev box>`.
@ -22,8 +27,10 @@ model" before changing anything that touches the SSH boundary.
1. Nothing received over SSH reaches a shell or Claude. No "initial prompt"
feature, no free-text arguments. New remote verbs need validation *and* a
test in `dev/tests/test_sessions_ctl.py`.
2. Local-only verbs (`delete`, `refresh-access`, `_launch`) stay out of
`REMOTE_VERBS`.
2. Local-only verbs (`delete`, `refresh-access`, `keygen`, `_launch`) stay out
of `REMOTE_VERBS`.
6. The private key is never written to disk on the dev box outside a temp dir
in `XDG_RUNTIME_DIR` (RAM), which `keygen` removes.
3. `refresh-access` never writes an empty `from=`, and never touches lines
other than the one ending in ` sessions-manager`.
4. The session unit keeps `DBUS_SESSION_BUS_ADDRESS` pointed at nothing.
@ -38,5 +45,7 @@ python3 -m unittest discover -s web/tests
```
To test end to end on the dev box, add a throwaway key with
`from="127.0.0.1",restrict,command=".../sessions-ctl --remote" … sessions-selftest`,
run the container with `--network host` and `SESSIONS_DEV_HOST=127.0.0.1`,
then remove the key line again.
run the container with `--network host`, `SESSIONS_DEV_HOST=127.0.0.1` and the
key as `SESSIONS_SSH_KEY_B64`, send requests with a `Remote-User` header, then
remove the key line again. Never run the real `keygen` from an agent session:
its output is a private key and would end up in the transcript.