diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1b925b4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: ci +on: [push, pull_request] +jobs: + rust: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + with: { components: "rustfmt, clippy" } + - uses: Swatinem/rust-cache@v2 + - run: sudo apt-get update && sudo apt-get install -y restic postgresql-client + - run: cargo fmt --all -- --check + - run: cargo clippy --workspace --all-targets -- -D warnings + - run: cargo test --workspace + supply-chain: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v2 + - run: cargo install cargo-audit --locked && cargo audit + web: + runs-on: ubuntu-latest + defaults: { run: { working-directory: web } } + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: { node-version: 22, cache: npm, cache-dependency-path: web/package-lock.json } + - run: npm ci + - run: npm run typecheck + - run: npm test + - run: npm run build diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7617d11 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +## Unreleased (0.1.0 candidate) + +- Authentication rebuilt: server-side sessions, emergency operator, OIDC (authorization code + PKCE), digest-only + Outpost tokens and pairing codes, rate limiting, central access gate with per-orbit grants. +- Downloads as real, streamed archives with concurrency and disk limits. +- Environments, production-to-staging relations and durable refresh runs with re-authorisation before overwrite. +- Refresh console for QA and a refresh-only access mode. +- Managed PostgreSQL/MySQL capture and restore through Outposts, Restic deduplication, GFS retention. diff --git a/README.md b/README.md index 65a13be..089750e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,12 @@ export TESSERA_VAULT_PASSPHRASE='choose a long private passphrase' The hub listens on **127.0.0.1:8787** unless `TESSERA_LISTEN` is set. Open [http://127.0.0.1:8787](http://127.0.0.1:8787). The OpenAPI document is at `/api-doc/openapi.json`. There is no default passphrase, and new vaults refuse the old published value `dev-vault-key`. Leave `TESSERA_SEED_DEMO` unset; `TESSERA_SEED_DEMO=1` writes demo backup history into the data directory. -With neither operator sessions nor an admin token configured, the admin API is available on loopback only. Set `TESSERA_ADMIN_TOKEN` for API/CLI access and pass it as `Authorization: Bearer ` or `X-Tessera-Admin-Token`. To sign in from the dashboard, configure the separate [operator password hash](docs/DATABASE-CAPTURE.md#operator-sign-in). +Authentication is required by default, including on loopback. Configure at least one of: the emergency operator +(`TESSERA_OPERATOR_PASSWORD_HASH`), a shared API token (`TESSERA_ADMIN_TOKEN`, optionally with +`TESSERA_ADMIN_TOKEN_EXPIRES`), or OIDC single sign-on. The hub refuses to start with none of them. For synthetic local +development only, `TESSERA_LOCAL_DEVELOPMENT=true` allows anonymous loopback access. See +[docs/DATABASE-CAPTURE.md](docs/DATABASE-CAPTURE.md) for operator sign-in, OIDC, per-orbit access grants, downloads, +production-to-staging relations and refresh runs. ### Docker Compose @@ -79,6 +84,14 @@ The agent reads files to detect changes, sends missing chunks and metadata throu If the Restic backup succeeds and registration fails, retry `POST /api/v1/wormhole/restic/commit` with the paired `X-Tessera-Upload-Token` and a JSON body containing `orbit_id` and the Restic `snapshot_id` from the error. Repeating registration for the same snapshot returns the same Tessera snapshot ID. +## Access model + +Browser users sign in with OIDC (or the emergency operator) and receive only the permissions an administrator granted: +`orbit.read`, `snapshot.read`, `capture.run`, `snapshot.download`, globally or per orbit. Everything else is +administrator-only. A person may also be allowed to refresh one staging database from its production source through a +relation grant; they see no other data. Outposts authenticate with their own digest-stored tokens. Production and +staging are separated by explicit, versioned relations, and an overwrite is re-authorised right before it is applied. + ## Architecture See [docs/SPEC.md](docs/SPEC.md). Rust workspace crates: `tessera-core`, `tessera-store`, `tessera-providers`, `tessera-hub`, `tessera-agent`, `tessera-cli`. @@ -90,7 +103,7 @@ See [docs/SPEC.md](docs/SPEC.md). Rust workspace crates: `tessera-core`, `tesser - Set `TESSERA_WORMHOLE_MTLS` to `1` or `true` to open a client-certificate listener. It also needs `TESSERA_WORMHOLE_CERT`, `TESSERA_WORMHOLE_KEY`, and `TESSERA_WORMHOLE_CLIENT_CA`. `TESSERA_WORMHOLE_LISTEN` defaults to `127.0.0.1:8788`. While that listener is up, plain HTTP upload routes answer 403. An agent needs `TESSERA_WORMHOLE_CLIENT_CERT` and `TESSERA_WORMHOLE_CLIENT_KEY` for that listener. Configure `TESSERA_WORMHOLE_CA` when the hub certificate uses a private CA. - PostgreSQL captures still run a full `pg_dump` into a private temporary file. Restic can deduplicate matching bytes in the resulting dump. Allow temporary disk space for one full dump per concurrent capture. The release image includes `pg_dump`; a native hub needs it on `PATH`. - The command provider is outside this release. Creating a command orbit and running it returns `command provider is outside this release; use filesystem or postgres`. -- OIDC is not implemented. The canvas does not attach `TESSERA_ADMIN_TOKEN`. +- OIDC supports a single issuer (authorization code with PKCE). Administrators come only from configuration (`TESSERA_OIDC_ADMIN_SUBJECTS` / `TESSERA_OIDC_ADMIN_GROUPS`); there is no first-user-becomes-admin and no self-registration. Group grants are not re-checked against the IdP during a session. ## License diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..d2cb7b8 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,9 @@ +# Security policy + +Report vulnerabilities privately to the maintainers (use the repository's private security advisory feature, or the +contact listed on the project page). Do not open a public issue for a vulnerability. Expect an acknowledgement within a +few days. + +Supported: the latest release. Tessera holds encrypted backups: keep `TESSERA_VAULT_PASSPHRASE` and the `vault` +directory together, serve the hub over HTTPS outside loopback, and set `TESSERA_TRUSTED_PROXIES` only for proxies you +operate. Hardening notes and the auth design are in `docs/DATABASE-CAPTURE.md` and `tasks/auth-endpoint-contract.md`. diff --git a/scripts/export-public.sh b/scripts/export-public.sh new file mode 100755 index 0000000..387c3d6 --- /dev/null +++ b/scripts/export-public.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Build a clean, single-commit tree for the public repository. Nothing is pushed. +# Usage: scripts/export-public.sh /path/to/empty-dir +set -euo pipefail +out="${1:?target directory}" +[ -z "$(ls -A "$out" 2>/dev/null)" ] || { echo "target must be empty" >&2; exit 1; } +root="$(git rev-parse --show-toplevel)" +git -C "$root" diff --quiet HEAD || { echo "commit or stash first" >&2; exit 1; } +git -C "$root" archive HEAD | tar -x -C "$out" +# Deployment-specific and planning material stays in the private repository. +rm -rf "$out/tasks" "$out/tests/mbu" "$out/docs/MBU-BACKUP-PARITY.md" "$out/docs/MBU-CUTOVER.md" "$out/floorplan" "$out/graft" +if grep -rIlE "mbugroup|backup\.mbu|hafizh|senkensha\.space|teleport" "$out" --exclude-dir=node_modules >/dev/null; then + echo "private references remain:" >&2 + grep -rIlE "mbugroup|backup\.mbu|hafizh|senkensha\.space|teleport" "$out" --exclude-dir=node_modules >&2 + exit 1 +fi +echo "clean tree at $out; review it, then: git init && git add -A && git commit"