[docs] Previews (the API for Fabrica, names, the token from the team vault), Ianitor anywhere (Linux, Docker, Windows Server in Caddy mode, NixOS), team sign-in in api.md, the Custos ticket's T4 part; release 0.2.0: the pipeline builds and tests the Linux tarball, the Windows zip and the image; the NixOS previews option; Docker and Linux smoke scripts

This commit is contained in:
2026-11-17 20:59:42 +01:00
parent d5d522fe4b
commit defd722cc2
15 changed files with 549 additions and 15 deletions
+18
View File
@@ -272,6 +272,24 @@ secret = "ui-proof" # listed in ianitor.toml: secrets = ["ui-proof"]
Why not the Unix socket now: edge's upstreams are `host:port` in the schema; a socket upstream is a
schema and compiler change in both engines, and the proof header needs neither.
## Team sign-in without Authelia (T4)
On a server without Authelia, people sign in with links (crates/control/src/team.rs):
- `ianitor-control team setup-link --config <c>` prints the first admin's link, `https://<admin host>/#signin=isc_…`
(one use, 7 days, only while the team has nobody). The UI posts the code to `POST /api/v1/session` (no token; the
`X-Ianitor-UI: 1` header and a same-origin page are required) and gets the `__Host-ianitor` cookie (HttpOnly,
Secure, SameSite=Strict, 30 days).
- Admins invite: `POST /api/v1/team/invites {name, role}` → `{link_fragment}` (Settings → Team → Invite).
- `GET /api/v1/team`, `DELETE /api/v1/team/members/{id}` (the last admin stays), `PUT /api/v1/team/me/root`
(your Tessera root), `POST /api/v1/session/end`.
- A `member` gets `403 team.admin_only` on tokens, the team, the engine switch and the CA's renewal and requests.
Browser writes need `X-Ianitor-UI: 1` (`403 request.csrf`).
## Branch previews (T4)
`/api/v1/previews`, and tokens with `"scope": "previews"` that may call nothing else: docs/previews.md.
## Certificates (the Domi CA)
Everything is in [pki.md](pki.md); the calls:
+18
View File
@@ -92,3 +92,21 @@ against the `domi-approve` public key before issuing. No new crypto in Custos.
with `pathlen:0`, after a match-code approval on the phone.
- A CSR with another CN, a bad signature or a request for a CA without pathLen 0 is refused.
- An `x509_csr` request against any other key is `out_of_scope`.
## T4 (2026-11-17): what Ianitor on any server needs from Custos
Not filed; written for the Custos session that picks it up. Each item has a working stand-in in Ianitor today.
1. **A target kind for an HTTP API token** (`http-token`: `host`, `secret`), so the team vault can hold Ianitor's
previews-only token and hand it to Fabrica per preview deployment through `target.request` (CustosPublic
`docs/TEAM.md`, "Target credentials"). Stand-in: the `registry` kind (a token with a host), docs/previews.md.
2. **A generic team approval** (`approve.request`: a canonical statement, the request's match code on every
member's card, an answer that carries the existing `custos team approval v1` statements and a proof
`verify_proof` can check), so Ianitor can ask a teammate to approve an admin change (a new API token, a member,
the engine switch, a renewal) without asking the team's release key to sign anything. Signing a dummy artifact
with `sign.request` is not a stand-in: Ianitor would choose the digest the release key signs. Stand-in: admin
changes need the admin role (crates/control/src/team.rs).
3. **A browser Domi key** (Fundamentum's web client): a WebCrypto key certified by the member's Tessera root, so a
sign-in is a signed challenge, not a link. Stand-in: one-time setup and invite links that make a session cookie;
members may record their Tessera root, and the team list shows its match code (`tessera match v1`, the same
digits Custos shows).
+80
View File
@@ -0,0 +1,80 @@
# Ianitor anywhere (T4)
Four ways to run Ianitor, one config model. Fabrica's coherence roadmap (`docs/32_coherence.md`, §2.5 and T4).
| | Engine | Package | Install | Secrets |
| :-- | :-- | :-- | :-- | :-- |
| Linux with systemd | Pingora (edge) | `ianitor-X.Y.Z-linux-x86_64.tar.gz` + `install.sh` | one line, below | `/var/lib/ianitor/credentials` (0700, random, made by setup) |
| Docker | Pingora (edge) | the image from `deploy/docker/Dockerfile`, `deploy/docker/compose.yaml` | `docker compose up -d` | the `state` volume's `credentials/` |
| Windows Server | **Caddy** (Caddy mode) | `ianitor-X.Y.Z-windows-x86_64.zip` | `install.ps1` | `%ProgramData%\Ianitor\credentials` (ACL: Administrators, SYSTEM, LocalService) |
| NixOS | Pingora, Caddy fallback | the flake (`nixosModules.ianitor`) | `nixos-rebuild` | systemd credentials (`LoadCredential`) |
Everywhere: control listens on 127.0.0.1:7878 only; only the engine binds 80 and 443; the web UI is the admin host
(`IANITOR_ADMIN_HOST`) through the engine. Without Authelia, people sign in with team links (Settings → Team,
docs/api.md); the installer prints the first admin's link (`ianitor-control team setup-link`).
## Linux (systemd)
```bash
curl -fsSL https://gitea.marek-novak.cz/mnovak/Ianitor/releases/download/v0.2.0/install.sh | sudo IANITOR_ADMIN_HOST=ianitor.example.org IANITOR_PREVIEW_DOMAIN=preview.example.org IANITOR_PREVIEW_UPSTREAMS=10.0.0.0/8 sh
```
It checks the tarball against the release's `SHA256SUMS`, installs `/usr/local/bin/ianitor-{control,edge}`, the web
UI, `ianitor-control.service` and `ianitor-edge.service` (users `ianitor` and `ianitor-edge`, the NixOS module's
hardening), writes `/etc/ianitor/control.toml` once (`deploy/linux/setup.sh`: every `IANITOR_*` variable is
listed there), starts both and prints the sign-in link. Running it again upgrades and keeps config and state. No
Caddy fallback here (the engine switch is NixOS-only); header-rule secrets need a `LoadCredential=` line each.
## Docker
```bash
cd deploy/docker && printf 'IANITOR_ADMIN_HOST=ianitor.example.org\nIANITOR_PREVIEW_DOMAIN=preview.example.org\nIANITOR_PREVIEW_UPSTREAMS=app\n' > .env && docker compose up -d && docker compose exec control ianitor-entrypoint setup-link
```
Two services from one image: `edge` (ports 80/443) and `control` in edge's network namespace, so the API stays on
loopback. Read-only root, no capabilities, `no-new-privileges`, user 10001. Previews of other containers: attach them
to the compose network and list their names in `IANITOR_PREVIEW_UPSTREAMS`.
## Windows Server (Caddy mode)
Pingora's Windows support is preliminary upstream, so Windows runs control with Caddy as the data plane: same UI,
same TOML, compiled to Caddy JSON; the differential suite runs on Windows with Windows paths to keep that honest.
From the unpacked zip, in an elevated PowerShell (Git for Windows installed):
```bash
powershell -ExecutionPolicy Bypass -File install.ps1 -AdminHost ianitor.example.org -PreviewDomain preview.example.org -PreviewUpstreams "10.0.0.0/8,127.0.0.1:20000-29999"
```
Three services as LocalService, restarted on failure: `IanitorCaddy` (`caddy run` on the last good `caddy.json`),
`IanitorControl` (`ianitor-control service control`) and `IanitorGuard` (the Caddy trial deadline, its own process
so a hung control cannot leave Caddy on an unconfirmed change). Caddy 2.11.7 is fetched by the installer and its
SHA-512 checked against the pinned value. Caddy's admin API listens on 127.0.0.1:2019 (Windows has no Unix socket
for it); any local process could reach it, so the machine should run nothing untrusted. Logs:
`%ProgramData%\Ianitor\logs`. Domi certificates have no revocation list, so Windows' own TLS (Schannel, curl.exe)
needs `--ssl-no-revoke`; browsers accept them once the Domi root is trusted.
## NixOS
Unchanged (`nixosModules.ianitor`, docs/deploy/beside-caddy.md), plus `services.ianitor.previews.{domain, tls, auth,
upstreams, defaultTtlSeconds}`.
## The Domi CA anywhere
With `tls = domi` the root stays offline (`ianitor-control ca init` on another machine). Start the intermediate in
the UI (Certificates → banner Renew) or `POST /api/v1/certs/intermediate/renewal`, sign the CSR offline
(`ianitor-control ca sign`), install it (`ianitor-control pki install <crt> --config <c>`), then restart control so
it adds the admin host with a certificate it can now issue. `scripts/smoke-windows.ps1` does all of it with a
throw-away root.
## Routes on any git host
`IANITOR_ROUTES_REMOTE` (an `https://` URL on Gitea, GitHub or GitLab) and `IANITOR_ROUTES_HOST`
(`gitea`, `github` → user `x-access-token`, `gitlab` → `oauth2`); the token goes in the credentials folder as
`routes-token`. Kept changes are pushed there, as on NixOS.
## Smoke tests (what was run for T4, 2026-11-17)
- Windows: `scripts/smoke-windows.ps1` (installer with `-NoService`, Caddy and control in the console, PKI, the
preview client, the preview through Caddy, close). The services themselves (SCM start, LocalService ACLs, ports 80
and 443) were not exercised on this PC.
- Docker and Linux: see the T4 handover in docs/ROADMAP.md.
+107
View File
@@ -0,0 +1,107 @@
# Branch previews (T4)
Every branch Fabrica builds can get its own address: `<branch>--<project>.<preview domain>`, with a certificate
from the Domi CA (internal) or Let's Encrypt (public). It closes when the branch is merged, or when its lifetime
runs out. Fabrica's coherence roadmap, `docs/32_coherence.md` in Fabrica, phase T4.
## Set up (once per server)
1. A wildcard DNS record for the preview domain points at the server: `*.preview.example.org`.
2. `[previews]` in control.toml (the installers write it from `IANITOR_PREVIEW_DOMAIN` and
`IANITOR_PREVIEW_UPSTREAMS`; NixOS: `services.ianitor.previews`):
```toml
[previews]
domain = "preview.example.org"
tls = "domi" # or "letsencrypt" (one certificate per preview; mind the rate limits)
auth = "none" # or "forward-auth" (behind the site's Authelia)
upstreams = ["10.0.0.0/8", "127.0.0.1:20000-29999", "app.internal", "*.svc.internal:8080"]
default_ttl_secs = 259200 # 72 h; min_ttl_secs 300, max_ttl_secs 30 days, max_previews 100, sweep_secs 30
```
`upstreams` is the allow list of where previews may send traffic: a network (`10.0.0.0/8`, `fd00::/8`), an
address with a port or port range (`127.0.0.1:20000-29999`), a name (`app.internal`) or every name under a suffix
(`*.svc.internal`), each with an optional port. Nothing else is accepted. Whatever the list says, a preview can never
point at control's own port, Caddy's admin port (2019 and the configured one), an unspecified, link-local or
multicast address, or an IPv4-mapped IPv6 address. A name is checked as written, not as it resolves: list only names
you control.
3. A token for Fabrica that may only manage previews:
`ianitor-control token create --name "Fabrica previews" --scope previews --config <control.toml>`, or
Settings → API → *Previews only* → New token. It goes into the Custos team vault (see *The token* below).
## The API
All calls carry `Authorization: Bearer <token>`; the token may be a full one or a previews-only one. A previews-only
token gets `403 token.scope` on every other route, reads included.
| Call | Body | Answer |
| :-- | :-- | :-- |
| `POST /api/v1/previews` | `{project, branch, upstream, ttl?}` | `202 {preview, apply}`: opens the branch's preview, or moves it (new upstream, new lifetime) |
| `GET /api/v1/previews/{hostname}` | | `200 {preview}` with `state`: `applying`, `live` or `failed` (with `problem`) |
| `GET /api/v1/previews` | | `200 {items, domain}` |
| `POST /api/v1/previews/close` | `{project, branch}` | `202 {apply}`: on merge or branch deletion; `404` when there is none |
| `DELETE /api/v1/previews/{hostname}` | | `202 {apply}`; `404 preview.not_found` for any host that is not a preview |
- `project` is Fabrica's project name (`mnovak/Arca`, `github:acme/web`): 1–128 of `A-Za-z0-9._/:-`.
- `branch` is the branch as the git host names it, any characters except control characters, up to 255 bytes.
- `upstream` is `http(s)://host:port` with no path, user or query, and must be in the allow list.
- `ttl` is seconds (default `default_ttl_secs`).
- A preview is an ordinary host file in the routes repository (`hosts/<name>.toml` with a `[preview]` table),
so it goes through the same validation, compilers, differential tests and commit-confirmed apply (trial, watch,
revert) as any host, and shows in History. Its answers carry `X-Robots-Tag: noindex, nofollow`.
- The apply is live when `GET /api/v1/previews/{hostname}` says `live`; poll every 2 s. A failed apply (the branch
build did not answer during the watch) says `failed` with Ianitor's reason, and the preview is not served.
- Errors: `preview.off` (no `[previews]`), `preview.taken` (another host or branch has that name),
`preview.branch`, `preview.project`, `preview.ttl`, `preview.upstream`, `preview.upstream_not_allowed`,
`preview.too_many`, `token.scope`.
## Names
The label is `<branch part>--<project part>` (core `preview::label`, tests in `crates/core/tests/preview.rs`):
- each part is lowercased, every run of other characters than `a-z0-9` becomes one `-`, dashes trimmed; the project
part is the repository name only (after the last `/` or `:`);
- if that lost anything (case, a character, the owner, length), the part gets `-` and 6 hex digits of SHA-256 of
the whole original, so `feature/login` and `feature-login`, or `alice/app` and `bob/app`, never share a host;
- the branch part is 3–40 characters, the project part 1–20, so the label is at most 62 and never has `--` in
positions 3–4 (reserved for IDNA; Let's Encrypt refuses those).
| Project | Branch | Host |
| :-- | :-- | :-- |
| `shop` | `fix-42` | `fix-42--shop.preview.example.org` |
| `mnovak/Arca` | `main` | `main--arca-4a93cc.preview.example.org` |
| `github:acme/Web.App` | `feature/Ünï ../../etc` | `feature-n-etc-50d099--web-app-4ff2e1.preview.example.org` |
Two branches can still collide only by a 24-bit hash collision; control then answers `409 preview.taken` instead of
taking the other branch's host.
## The token, from the Custos team vault
The previews-only token is a secret: it lives in the team vault, and Fabrica gets it per deployment, the way it
gets any target credential (Custos `docs/27_team_vault.md`, Fabrica `docs/handover/t1-sign-request.md`): the preview
build is signed under the team's `preview` environment (0 approvals: the test key signs at once), the sign reply's
ticket authorises one `target.request` for the Ianitor target of that project and environment, and the token comes
back sealed to Fabrica's one-time key. Fabrica uses it for that deployment and drops it.
Custos's target kinds today are `ssh-key`, `winrm`, `openssh`, `registry` and `kubeconfig`; an API token for an HTTP
service has no kind of its own yet. Until Custos adds one (`http-token`, written up in docs/custos-ticket.md), keep
it as `registry` (a token with a host), which carries the same fields.
## A client
`scripts/preview.sh` (curl and jq) and `scripts/preview.ps1` are what a Fabrica pipeline step runs until Fabrica has
a preview step of its own:
```bash
IANITOR_URL=https://ianitor.example.org IANITOR_PREVIEW_TOKEN=… scripts/preview.sh open mnovak/Arca "$BRANCH" http://10.0.0.7:8080 86400
```
```bash
scripts/preview.sh close mnovak/Arca "$BRANCH"
```
## Screens
Previews (the nav): every open preview with its state, branch, project, upstream and when it closes (1 click);
Close → Close preview (2 clicks).