feat: add account avatars and a deployable image

Accounts get a profile page with an uploaded picture, shown in the
sidebar, the room bar, and every human message. Pictures live in the
SQLite database and are served through an authenticated route.

Hardening from the security audit: preview hosts expire after 24 hours
and carry no-referrer; removing a member or archiving a room ends their
event feed, presence socket, and terminal within seconds; previews and
the terminal pin the SSH host key; invites are claimed atomically;
missing accounts spend the same argon2 time as wrong passwords;
registration is closed by default; WebSockets check the origin; and the
master key is created with mode 0600.

The Dockerfile builds one image with the static client and the server.
The Helm chart runs a single replica with a SQLite volume, a wildcard
preview ingress, and the proxy settings the event feed and uploads
need. It refuses more than one replica because state is in process.
This commit is contained in:
vhaudiquet committed 2026-11-28 02:07:26 +01:00
1 parent 7e7a1d2bb6
commit 3b82719d56
38 files changed
+1307 -106

No files matched your search

+46 -8
View File
@@ -35,7 +35,7 @@ one SQLite file.
## Build
Requirements: Rust 1.89+, Node 22+, pnpm, and an SSH server reachable
Requirements: Rust 1.98+, Node 22+, pnpm, and an SSH server reachable
from the machine that runs rhema-together.
```sh
@@ -70,6 +70,30 @@ During client development, run `pnpm dev` in `web/` (port 3000) and
keep the server on port 7800; the Nuxt dev proxy forwards `/api`,
including the terminal WebSocket.
## Deploy
The repository builds a self-contained image. The Dockerfile clones the
Rhema framework at the tag it names, builds the client and server, and
runs the result as UID 10001 with a writable `/data` volume.
```sh
docker build -t registry.example.com/rhema-together:0.1.0 .
docker run --rm -p 7800:7800 -v together-data:/data \
-e TOGETHER_PUBLIC_URL=https://together.example.com \
-e TOGETHER_ALLOW_REGISTRATION=false \
-e TOGETHER_PREVIEW_ORIGIN=https://preview.together.example.com \
registry.example.com/rhema-together:0.1.0
```
For Kubernetes, the chart in `deploy/helm/rhema-together` adds the
deployment, service, ingress, and persistent volume. It also documents
the wildcard DNS, wildcard TLS certificate, proxy buffering, and body
size the app needs. Read that README before exposing the service.
The preview host is a signed subdomain, so the ingress must route all
of `*.preview.<your-domain>` to the same service. The app does not
issue certificates.
## First room
1. **Settings → Providers.** Add a provider kind, model, and key. Keys
@@ -104,12 +128,14 @@ https://preview.together.example.com production
```
Each preview is served from
`<scheme>://r<room>-p<port>-<hmac>.<preview host>/`. The HMAC covers the
room and port and is derived from the server's master key, so a room id
alone is not enough to reach a preview. DNS must resolve every subdomain
of the preview host to the server (a wildcard `*.preview` record), and
TLS must cover the wildcard. A copied preview URL works for anyone who
has it; treat it as a read capability for that port.
`<scheme>://r<room>-p<port>-<expiry>-<hmac>.<preview host>/`. The HMAC
covers the room, port, and expiry and is derived from the server's
master key, so a room id alone is not enough to reach a preview. The
address expires after 24 hours; reloading the pane mints a new one. DNS
must resolve every subdomain of the preview host to the server (a
wildcard `*.preview` record), and TLS must cover the wildcard. A copied
preview URL works for anyone who has it until it expires; treat it as a
read capability for that port.
The proxy forwards ordinary HTTP through an ssh `direct-tcpip` channel
to `127.0.0.1:<port>` inside the sandbox. WebSocket upgrades (Vite HMR)
@@ -147,7 +173,7 @@ Every field can be set in the YAML file (`TOGETHER_CONFIG`, default
| `TOGETHER_SECRET_KEY_FILE` | `data/secret.key` | 32-byte master key (created, mode 0600) |
| `TOGETHER_WEB_DIR` | `web/.output/public` | built client |
| `TOGETHER_MAX_TURN_STEPS` | `48` | step cap per turn |
| `TOGETHER_ALLOW_REGISTRATION` | `true` | whether `/register` works |
| `TOGETHER_ALLOW_REGISTRATION` | `false` | whether `/register` works |
## Security model
@@ -159,6 +185,18 @@ Every field can be set in the YAML file (`TOGETHER_CONFIG`, default
mutating calls.
- Guests can chat, interrupt, use the terminal, and read files. Only
full accounts create rooms, providers, and targets.
- Registration is closed by default; setup and invite links work
without it. A full account can make the server open an SSH connection
to a host it names, so open signup also makes the server reachable
from anywhere as a port scanner. Turn it on only when you trust
everyone who can reach `/register`.
- A preview host is a signed capability for one room and port. It
expires after 24 hours, and preview responses carry
`Referrer-Policy: no-referrer`. A copied URL works until it expires.
- Removing a member or archiving a room ends that account's event feed,
presence socket, and terminal within a few seconds. The terminal and
preview proxy pin the SSH host key on first login and refuse a
changed key.
- Preview URLs are signed capabilities, not authenticated pages.
- The app sets a CSP that frames only `*.<preview host>`, and refuses
to frame itself elsewhere.