swarm-nats-auth: limit hive and swarm-controller subscribe to the subjects they use
A hive's queue credential and the swarm controller's could subscribe to every subject in the swarm account, so a hive could read every other hive's deploy requests and every agent's terminal, state, input and request replies. Their grants now carry a subscribe allow-list: - a hive `hive-<h>`: `$SWARM.knowledge`, `$SWARM.deploy.<h>` and its reply inbox `_INBOX.client.hive-<h>.>` - the reader (swarm-controller): `$SWARM.term.*`, `$SWARM.term.*.sub.*`, `$SWARM.agent-state.*` and its reply inbox `_INBOX.client.<client-id>.>` `swarm_queue_client::connect`, which hive-c0re and swarm-controller both use, now connects with `_INBOX.client.<client-id>` as its inbox prefix, the same shape agents got for their own credential. In async-nats 0.50 every request reply and every ordered consumer (the hive's wanted-state watch, the controller's KV key listings) delivers under that prefix, so the one inbox grant covers them all. A hive or controller still on a build without the prefix has every JetStream reply refused once the responder runs this policy, so the clients need to be rebuilt before, or with, swarm-nats-auth. Closes #4945
This commit is contained in:
parent
22ce8b815a
commit
d0c2b85d45
3 changed files with 159 additions and 27 deletions
|
|
@ -256,8 +256,17 @@ and nothing else. The harness and the subagent daemon connect with
|
|||
`_INBOX.agent.<agent>` as their inbox prefix, so the replies to the icon write
|
||||
and the schedule read arrive. An agent can't read another agent's terminal,
|
||||
state, input or replies. The queue refuses the hive's shared agent client
|
||||
outright. Hives and the swarm controller may still subscribe to any subject in
|
||||
the account.
|
||||
outright.
|
||||
|
||||
Hives and the swarm controller get a subscribe allow-list too, each with its
|
||||
own reply inbox `_INBOX.client.<client-id>.>`, which `swarm_queue_client::connect`
|
||||
sets as their inbox prefix. A KV watch or key listing delivers there as well. A
|
||||
hive may also subscribe to `$SWARM.knowledge` and its own `$SWARM.deploy.<hive>`,
|
||||
so it can't read another hive's deploys or any agent's terminal. The controller
|
||||
may also subscribe to `$SWARM.term.<agent>`, `$SWARM.term.<agent>.sub.<subagent>`
|
||||
and `$SWARM.agent-state.<agent>`, the streams it relays to swarm-ui. A hive or
|
||||
controller that connects with the library's default `_INBOX.<nuid>` prefix gets
|
||||
no replies, so every request it makes times out.
|
||||
|
||||
</details>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue