Repository navigation
[M1.2a] Fleet: join tokens, installation CA and node enrollment - #29
Merged
Merged
Conversation
…n keys with Prisma
…eSQL and enroll a node end to end
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.
Task
[M1.2a] Enrollment foundations on the control plane (first third of M1.2, split recorded in
docs/PLAN.md). Refs #14What changed
Domain (
modules/fleet/domain)evaluateJoinTokenis pure and rejects malformed values before any lookup; every rejection reason maps to one client-facing message so callers cannot probe for existing tokens.sanitizeFacts(agents are trusted for their facts but not for the shape of what reaches the database), SPIFFE identityspiffe://shipkeep/<org>/node/<node>with a strict parser.fleet.join_token.issuedandfleet.node.enrolled(the node is the actor of its own enrollment, with the caller IP).Application
JoinTokenStore(atomicconsume),NodeStore,CertificateAuthority,ConfirmationKeyProvider.IssueJoinToken: returns the value once with the CA fingerprint for the install command; audits the issuance without the value.EnrollNode: validates the token, caps the CSR at 8 KiB, derives and uniquifies the node name, asks the CA for a certificate, records node and certificate, consumes the token last and atomically (a token can never enroll two nodes), emits the audit event, and returns the certificate, CA PEM, lease epoch 1 and the confirmation public key (theEnrollResponseof SPEC 3.2).Infrastructure
@peculiar/x509over Node WebCrypto: self-signed CA (10 years, keyCertSign), node client certificates valid 30 days with CN = node id, SAN URI = SPIFFE id, clientAuth only, random 128-bit serials. The CSR signature is verified and only its public key is used: subject and requested extensions are ignored. Non-Ed25519 keys are refused.kind, concurrent starts converge on one CA) and stored with the private half encrypted byEnvelopeService(scopeinstallation:keys).installation_keys,join_tokens,nodes(unique name per organization),node_certificates; migration20261103125636_fleet.organization_idgets its foreign key when organizations land (M2.3).FleetModulewired into the application. No REST or gRPC surface yet: exposingEnrollis M1.2b and the join-token endpoint waits for RBAC (M2.3), so nothing unauthenticated is reachable.Tests
configureAppis shared withcreateApp.Why
ARCHITECTURE flow 1 and SPEC 3.2: the control plane must be able to mint single-use tokens and sign node identities before any agent can connect. Keeping the CA key under the KEK removes the "root key in a web panel" failure mode this project exists to avoid.
How it was tested
pnpm nx run-many -t lint typecheck test build: all 7 projects green.pnpm test:integration(Testcontainers, clean environment): 4 tests green.pnpm gentwice: no drift. Semgrep custom rules: clean.Security considerations
@peculiar/x5092.2.0 (MIT) is pinned below 3.x because 3.0.0 was published less than seven days ago (pnpmminimumReleaseAge).InstallationKeyadded to SPEC section 4. No agent action changed.Checklist
docs/PLAN.mdare met and tickedbuf lintpass