feat(cluster): remote edit of a peer's mapping (v2.6.1)#21
Merged
Conversation
…(v2.6.1) Operators can now edit a remote node's mapping from the fleet table, not just start/stop/restart it. - Key-guarded peer endpoints: GET /api/cluster/mapping-data (mapping config + the peer's serial ports + IP candidates) and POST /api/cluster/mapping-save (validate + persist + apply on the target). Both in _CLUSTER_PEER_PATHS (PUBLIC + CSRF-exempt). - Browser-facing proxies (operator+, allowlist-checked): GET /api/cluster/peer-form and POST /api/cluster/peer-save. The edit form is rendered on the CONTROLLING node (so the CSRF token belongs to the browser's session), with _mapping_form.html in a "remote mode" that targets the proxy and carries the peer routing; the save is then forwarded to the peer with the shared key. - mapping_save refactored to share _save_mapping_from_form; peer HTTP generalized to get_peer/post_peer. Edit button on remote rows. - tests/test_cluster.py: extends the two-node test with a remote edit (form loads from the peer + a save changes the peer's mapping) and the mapping-save key guard. - Version 2.6.1 (single-sourced in app/__init__.py); README/ROADMAP + screenshots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the cluster fleet-management story: operators can now edit a remote node's mapping from the unified view, not just start/stop/restart it (the last open item from the v2.6.x list).
How it works
The hard part is that the edit form must carry the browser's own CSRF token and post same-origin, while the data and the save belong to a different node. So:
GET /api/cluster/mapping-datareturns the mapping's config + that node's serial ports + IP candidates;POST /api/cluster/mapping-savevalidates + persists + applies on the target. Both are in_CLUSTER_PEER_PATHS(PUBLIC + CSRF-exempt — authed by the shared key).GET /api/cluster/peer-form(operator+, allowlist-checked) fetches the peer's data and renders_mapping_form.htmlin remote mode — the form targets/api/cluster/peer-saveand carries the peer routing as hiddenscheme/host/portfields. The CSRF token is the browser's, so the same-origin submit passes the normal gate.POST /api/cluster/peer-save(operator+, allowlist-checked) strips the routing fields and forwards the rest to the peer's key-guardedmapping-save; on a peer-side validation error it re-renders the form with the message.Refactors
mapping_savenow shares_save_mapping_from_formwith the peer save (no logic drift).get_peer/post_peer(control + edit reuse them).Security
Same model as remote control: an operator+ session on a cluster node + the shared key is required; the local role gates initiation, the key authorizes the cross-node call, and the known-address allowlist bounds the target (anti-SSRF). Remote edit is start/stop/restart's sibling — the destructive surface is the same one already shipped in v2.6.0.
Tests
tests/test_cluster.pyextends the two-node (manual-peer) test: the peer's mapping loads into the form routed topeer-save, themapping-savekey guard returns 403 without the key, and a remote edit changes the peer's mapping (verified via the peer's/api/cluster/local). Full suite 32/32; ruff clean.Version 2.6.1; README (TR/EN) + ROADMAP updated; screenshots regenerated (remote rows now show Start + Edit).