Repository navigation
feat(fleet): a server a restore rolled back is re-adopted on an administrator's confirmation (part of #487) - #518
Merged
Conversation
…istrator's confirmation (part of #487) After a restore from a backup older than a server's last renewal, the agent presents a certificate the installation CA signed and the restored registry never saw, and the gateway refused it for good: the agent stopped trying. The gateway now records such a certificate when TLS verified it, the registry knows no such serial (a revoked or expired serial stays refused), and its node exists and was not removed; the first record is audited. An administrator lists them and confirms with their password and second factor: the certificate is registered for that same node, its others are revoked, audited. The agent presents a refused certificate again every 5 minutes and never enrolls again, so a re-adopted server connects by itself. Signed-off-by: samuel mbabhazi <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Collaborator
Author
Lab acceptance (run28)Setup
Steps
Note: the first refusal came from the open stream's per-second credential check, which this PR leaves as it was. The certificate was therefore recorded at the agent's next connection, 5 minutes later. In a real restore the control plane restarts, so every agent opens a new connection and goes through the recording path at once. |
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 26, 2026
… a password (closes #487) (#519) ## What changed The second part of #487: the Servers page offers the re-adoption that #518 added to the API. - **`sk-node-readoptions`**: a card under *Agent upgrades*, hidden while nothing waits. - It lists each server whose certificate the gateway refused after a restore, with its name, since when it is refused, and until when its certificate is valid. - **Re-adopt** opens a password and authentication-code form, the same proof as a join token. On success the card says the server connects again within 5 minutes, and the server list is refreshed. - A refused proof keeps the server listed, with the runner's error. - Changing organization clears everything. - **API client:** `FleetApi.readoptions` and `FleetApi.readopt`. - **French translations.** - **INSTALL.md** now describes the step on the Servers page. ## Why Closes #487. An administrator recovers a restored server from the page they manage servers on, not with an API call. ## How it was tested - **Unit tests** in `node-readoptions.spec.ts` (4 tests): - nothing is shown while no server waits; - the waiting server is named, the button stays disabled until a password is typed, and the code is trimmed. The call carries the organization, the node and the proof, the success text shows, and the list refreshes; - no empty `totp` is sent, and a refused proof keeps the server listed with no success; - another organization clears the card. - **Full web suite:** 59 files, 371 tests. Web lint and typecheck pass. - **Real lab** (run28, the #518 control plane with this production bundle, in Chromium): - A simulated restore made the gateway record `node-b`'s certificate. - The card listed it in English and French, on desktop and mobile. - **Re-adopt node-b** with the owner's password showed `node-b is re-adopted: it connects again within 5 minutes.`, and the list emptied. Screenshots are in the review page linked in the conversation. **This changes the UI: it waits for the maintainer's validation before merge.** ## Security considerations No new capability: the page calls the routes of #518, which check `node.manage`, the password and second factor, and audit the confirmation. The password field uses `autocomplete="current-password"` and is cleared after each attempt. The certificate serial is not shown. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added a Servers page workflow for re-adopting servers with unrecognized certificates. Administrators can re-adopt a server using their password and, when required, a TOTP code. * The server list refreshes after a successful re-adoption, and the server’s name is shown. * **Bug Fixes** * Failed server-list loads can be retried, and existing server entries remain visible if a reload fails. * **Documentation** * Updated restore instructions to explain how to re-adopt servers from the Servers page. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: samuel mbabhazi <[email protected]>
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.
What changed
The first part of #487, as decided: confirmed re-adoption. A restore from a backup older than a server's last certificate renewal no longer leaves that server unmanageable. The gateway records the certificate it refused, and an administrator confirms with their password, which registers it for that same server. Every step is audited and revocation still holds. The Servers page will offer the step in a second pull request, which needs your validation.
Gateway (
agent-gateway.ts): when the registry refuses a certificate that TLS verified against the installation CA,NodeReadoptions.noticerecords it innode_readoptions, one row per node, when all of these hold:Its first record is audited as
fleet.node.readoption_requested(by the node). Later presentations refreshlast_seen_atat most once a minute. A failure to record changes nothing in the answer: the request stays refused.API
GET /api/v1/organizations/{org}/node-readoptions(node.manage) lists the waiting certificates.POST /api/v1/organizations/{org}/nodes/{node}/readopt(node.manage, session only) takes the caller's password and second factor, the same proof as a join token, and runs in one transaction. It registers the waiting certificate, revokes the node's other certificates, deletes the request and publishesfleet.node.readoptedwith the revoked serials.409for no request, a removed node, a certificate that expired while waiting, or a serial already registered.Data: the migration
node_readoptions, under tenant row security, cascades with its node. The runtime role getsSELECT, INSERT, UPDATE, DELETEon it, and the table joinsTENANT_TABLES.Agent (
gateway/runner.go): a certificate the control plane refuses (Unauthenticated,FailedPrecondition) is presented again every 5 minutes, unchanged, with one error log. The agent never enrolls again. A local identity error (unreadable credentials, a mismatched Welcome) still waits for an operator. A re-adopted server therefore connects by itself. Older agents connect once restarted, as INSTALL.md says.Docs: SPEC 3.1, ADR 0026, INSTALL.md (Back up and restore), THREAT_MODEL, and the restore's closing message in
backup.sh. They no longer promise an unconditional reconnection.Why
Closes part of #487. The gateway requires the presented serial to exist in the registry. After such a restore the agent holds a serial the restored database never saw, and the agent stopped trying for good. The fix accepts nothing by itself: a new certificate needs an administrator's confirmation, and the CA's signature alone is not enough.
How it was tested
node-readoption.spec.ts, 9 tests):gateway.integration.spec.ts):fleet-administration-http.integration.spec.ts):TestRunnerPresentsARefusedCertificateAgainLater): refused, then accepted after a "re-adoption". The agent connects without enrolling again. Restoring the old wait-forever makes the test fail.go test -race ./agent/internal/gateway/passes andgolangci-lintreports 0 issues.api:lint,api:typecheckand prettier pass, andpnpm genregeneratedopenapi.jsonand the API client.Security considerations
node.manageand the caller's password and second factor, under the credential-proof rate limit (token). It is audited with the serials it revoked, and the node's other certificates are revoked in the same transaction.