services.hyperhive.k8s.enable renders a Deployment (swarm-controller,
swarm-notify-router) or CronJob (swarm-ci-metrics) per service this host
deploys into system.build.k8sManifests. The renderer reads each evaluated
unit: its environment, LoadCredential ids, state and runtime directories,
ExecStart and timer. Files the unit names are mounted at the same paths, so
the environment carries over as it is. Secrets are referenced by name only.
No unit changes. checks: k8s-manifests-all-local (kubeconform -strict,
offline schemas) and module-eval-k8s; the allLocal fixture turns the
rendering on.
A retry or backoff policy written out by hand (a capped doubling wait, a
jitter from the clock, a try count with a sleep) goes against the workspace's
own dependency on backon. The rule flags a diff that adds one; the controller
test lists the rule name.
publish -> render_yaml -> validate re-checked validate_username on every user
in the file, humans included. authelia accepts names the charset refuses
(first.last@corp), so one hand-added user made every EnsureAgentIdentity fail
with a 500 until it was removed, while readiness (which only parsed the file)
stayed green. The reserved-name guard already avoids this hazard.
validate now checks only what a write would emit wrong (control characters),
for every user. The charset check stays on the name a request writes, in
handle. A user outside the charset is passed through unchanged and named in a
warn line on each write. Readiness now also runs that check, so a file the
bridge cannot render is not ready.
The handler took `Json<BridgeRequest>`, which axum runs before the handler
body. A caller with no token and a malformed body got axum's rejection
(415/400/422), whose text is serde's ("unknown variant ..., expected one of
..."), and not the one generic 401 an unauthenticated caller is meant to see.
Take the body as bytes, authorize, then parse. A caller that is let in and
sends a body that doesn't parse gets a 400 with the parse error, as before in
substance. The request's content type is no longer checked.
- request.rs pointed at module docs on main.rs for why the request signature
is not verified; they said nothing. It now says why, here and in
docs/4-implementation/swarm/credentials.md ("What authenticates a callout
request"), and so do xkey::open and main.rs's module docs: only the
responder's own key can publish to the request subject, a forger with a
valid bearer gets what a normal connect gets, and nats-server makes a new
xkey at each start and has no option to set it, so there is no key to pin.
The guard is the module-eval case "the callout account has exactly one member
and no system account is configured"; the docs say to revisit this if that
changes.
- request.rs said base64url is written out rather than pulled in; it calls
data_encoding, a direct dependency.
- respond.rs said `now` is injected into sign(); sign() takes no clock.
- oidc_secret.rs named swarm-bao.nix for natsAuthReaders; it is in
swarm-bao-readers.nix.
`handle` checked the store's username charset, which is wider than an agent
name's (it holds humans too: uppercase, `.`, `_`). The roster (`list`) keeps
only subjects that parse as an `Ident`, so `EnsureAgentIdentity("Atlas")`
wrote a user the roster then skipped for good.
Parse the name as an `Ident` first and refuse anything else, before the store
is touched. The refusal goes out the existing error path.
When the store answered that it holds no usable bearer, the cache was reset
to its default, which forgot that the answer had just been asked for. Every
request after that started its own bao login and read, one at a time (up to
5 s each), so anyone sending `Bearer <64 hex>` before Grafana's bearer exists
queued Grafana's real requests behind those lookups, on a route with no rate
limit because the responder was said to read the store at most once per TTL.
Remember the answer for the TTL, as a stored bearer is, and deny without a
lookup until it passes (`empty_until`). A bearer that arrives ends it. The
"at most once per cache TTL" comments in swarm-victorialogs.nix and
swarm-victoriametrics.nix now also say the failure case, one lookup per few
seconds while the store does not answer.
An uncached request read the agent's queue credential (swarm_agent_verify::
verify through Store::lookup) and then its permission grant
(Store::read_optional), and each read did its own bao cert login, so a cold
bearer cost two logins.
Add swarm_agent_verify::Store::connect, which logs in once and returns a
Connection that implements CredentialSource and reads any path. swarm-logs-auth
connects once per uncached request, bounded by the lookup timeout, and uses the
connection for both reads. A login that fails or times out denies the request
and reads nothing. Store's own per-read login stays for swarm-nats-auth.
The user JWT's exp is min(credential exp, now + 1h) with no floor at now.
When this responder's clock is ahead of the identity provider's, a token the
provider calls active can already be over here: the minted JWT then has
exp <= iat, the server refuses the client, and the log says granted=true.
Check respond::outlives(now, expires) before granting. A credential that is
over at now gets the same denial as an inactive token, and the refusal is
logged with the credential's expiry and now (granted=false on the request
line). grant() takes the now the check used, so the JWT it mints and the
check can't disagree.
The ListOperators doc said every other verb admits any active token and this
one is refused to other callers. The bridge's classify admits only the
controller's client id, for all three verbs, and answers any other active
token 403, as the README says. The doc understated the restriction.
swarm-logs-auth's module doc said nginx sends it every /select/logsql/
request. The log store's nginx map sends it only `Bearer swarm-agent.`
requests; Grafana's 64-hex bearer goes to swarm-metrics-auth and everything
else to authelia. swarm-metrics-auth's said it was the metrics store's
responder for Grafana, but the same binary also guards the log store. Both
docs now describe the routing the nginx maps in swarm-victorialogs.nix and
swarm-victoriametrics.nix do.
The "← agents" button sat on a row of its own above the card and read as a
stray control, and "back" was the wrong word beside a visible list. The card's
top line now ends in a close cross (the shared Badge with the close icon, as in
the group page's panes), at every width. A name the roster doesn't have keeps
the "← agents" button, since there is no card to carry the cross.
Each optional read, listing, delete, SSH CA read, alias lookup and versioned
read in SecretStore decided what a 404 (or a 400, or an empty 204) means
inline, next to the vaultrs call. Move those decisions into small functions
(none_when_absent, empty_when_absent, done_when_absent, ssh_ca_key,
entity_from_lookup, versioned) and the cert-role policy write's request into
set_cert_role_policies_request. Behaviour is unchanged.
Test them with constructed ClientError values: 404 is nothing there, every
other status (400, 403, 429, 500, 503) stays the store's error with the
status in the message, a blank SSH CA key is none, an empty alias answer is
a miss and any other parse failure is not, a versioned read keeps the number
and time and a wrong-shaped object is an error. Also pin the cert-role read
structs and the paths the grant names.
The vaultrs call lines themselves stay unit-uncovered by design; the VM tests
drive them against a real bao.