matrix: publish the appservice token from the swarm, not just read it
`glue-matrix-bao-token.nix` has read `secret/swarm/hives/<hive>/matrix/appservice-token` since it landed, but nothing ever wrote that path. The store was empty in every deployment, so every read degraded to "keep what activation minted" and each hive stayed the origin of a value the swarm has to agree on — two hives never converged. `swarm-secret-publish` is now the producer. It already holds a store identity, already writes under the hive prefix, and already runs per hive in the roster, so the mint is a third loop beside the two OIDC copies rather than a second shape of this unit. Idempotence comes from a record of its own, not from the store: this principal is granted `create`/`update` with no `read`, so it cannot ask whether a hive already has a token. It keeps what it minted under `StateDirectory=` (0700 dir, 0600 file) and mints only when that file is missing or empty; the `put` runs every time, because re-putting the same bytes changes nothing for a reader while a mint whose publish failed must not be left as a token this host holds and no hive can reach. The token never becomes a nix literal and never reaches argv: the mint redirects into a file, and the publish hands bao `value=@<path>` so bao opens it itself — the same handling the OIDC loops use. `hive-matrix.nix`'s activation mint stays as the genuine first-boot fallback. It already fires only when the token file is absent, so it cannot clobber a value the store delivered; `hs_token` has no swarm half and is still minted there for real. Refs #4402
This commit is contained in:
parent
7ee7080b21
commit
199afa41c8
5 changed files with 167 additions and 35 deletions
|
|
@ -126,6 +126,15 @@ let
|
|||
# whatever they now hold. **One script with two callers** — the activation
|
||||
# script below and `glue-matrix-bao-token.nix`, which overwrites the
|
||||
# `as_token` with the swarm store's copy and has to re-render afterwards.
|
||||
#
|
||||
# ⚠️ The `as_token` mint here is the FIRST-BOOT FALLBACK, not the normal
|
||||
# route. `swarm-secret-publisher.nix` mints one per hive swarm-side and
|
||||
# publishes it to the store; the reader above overwrites this file before
|
||||
# the homeserver's container starts, so what a hive actually runs on is the
|
||||
# swarm's value. This keeps a hive that has never reached the store working
|
||||
# — and it fires only when the file is absent, so it never clobbers one the
|
||||
# store delivered. (`hs_token` has no swarm half: it is how the homeserver
|
||||
# authenticates to *us*, so it stays hive-local and is minted here for real.)
|
||||
# A second copy of the registration's shape would be a second source of
|
||||
# truth for a format whose mismatch is silent: the homeserver would load a
|
||||
# registration naming a token nobody holds, and every request hive-c0re
|
||||
|
|
|
|||
Loading…
Reference in a new issue