mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-03 18:43:38 +01:00
`/api/auto-register` accepts `agent:report` tokens so a Proxmox agent can refresh the API token Pulse holds for its own node when that connection stops working. Every monitored host holds such a token, including Docker-only and Kubernetes-only hosts, and nothing an agent says about itself proves which connection is its own. ## What changed The proof is now the install grant. An admin-issued, first-host-bound, expiring grant may still adopt or create a source, and spending it records the connection's address on the token. Without an available grant, an agent token may refresh the credentials of an existing PVE or PBS connection, or a cluster member, only at that recorded address. The match is on the same port as well as the same host. The stored address and TLS pin stay as they are, and any other request gets a 403 that changes nothing. These don't count as proof: - `serverName` - candidate addresses - a rebindable bound hostname - host reports The registration check also changed: - It reports `canRegister` on the same terms, so an agent doesn't rotate a credential it can't register. - When it spends a grant on an existing source, it records that source's own address rather than the agent's first candidate. The handler also stops logging the raw request body when auto-register JSON fails to parse. ## Unchanged Setup-token registration, and creating or adopting a source through the install grant. ## Behaviour change An agent whose token never spent a grant keeps its current connection rather than replacing it. Reinstalling the agent from a fresh install command, or re-running the node setup, refreshes it. ## Tests Seven new tests in `config_handlers_canonical_auto_register_test.go`: - Refusals: - four token kinds against PVE, cluster-member and PBS targets; - a second connection on another port; - no moved address or foreign pin. - Heals: - a recorded node, a primary and a non-primary cluster member, and a legacy PBS record; - a grant spent through a fallback candidate. - The check's `canRegister`. Five of them fail against the previous handler. `./internal/api/configapi` and `./internal/api -run 'AutoRegister|AgentToken'` pass. Closes #4190