From 9462c362a5b825bc1120142533d3da2aa6ffa386 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 06:31:06 -0500 Subject: [PATCH 1/3] [scanner] fix: provision per-hive customer match key to hub-hosted spokes Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/added-customer-match-key-provisioning.md | 1 + src/docs/design/customers-hub-consent.md | 4 ++++ src/pkg/hub/hub_keys.go | 12 ++++++++++++ src/pkg/hub/perhive_env_generation_test.go | 5 +++++ src/pkg/hub/perhive_env_reconcile.go | 5 +++++ src/pkg/hub/perhive_env_reconcile_test.go | 5 +++++ src/pkg/hub/saas_provision.go | 6 ++++++ 7 files changed, 38 insertions(+) create mode 100644 changelog.d/added-customer-match-key-provisioning.md diff --git a/changelog.d/added-customer-match-key-provisioning.md b/changelog.d/added-customer-match-key-provisioning.md new file mode 100644 index 0000000000..340622223c --- /dev/null +++ b/changelog.d/added-customer-match-key-provisioning.md @@ -0,0 +1 @@ +- Hub-hosted spokes now receive the per-hive customer match key (`HIVE_CUSTOMER_MATCH_KEY`), so the customers hub import can work once enabled; default behaviour is unchanged. diff --git a/src/docs/design/customers-hub-consent.md b/src/docs/design/customers-hub-consent.md index 2dc70746f6..6ce09561ca 100644 --- a/src/docs/design/customers-hub-consent.md +++ b/src/docs/design/customers-hub-consent.md @@ -257,6 +257,10 @@ constants for size and rate; none of this is final until phase 2. hub. The hub's per-person consent decides what arrives; the switch only says this hive asks. The help text states that the request carries hashed GitHub logins of confirmed customers and nothing else. +- **Match key provisioning.** Hub-hosted spokes receive the per-hive match key + as `HIVE_CUSTOMER_MATCH_KEY` from the hub (provisioning and the per-hive env + reconcile, current master generation). Self-service (`byo-`) hives hold no + master and get no provisioning, so they cannot use the hub import in v1. ## Revocation diff --git a/src/pkg/hub/hub_keys.go b/src/pkg/hub/hub_keys.go index 3221487fa4..6147045143 100644 --- a/src/pkg/hub/hub_keys.go +++ b/src/pkg/hub/hub_keys.go @@ -130,6 +130,16 @@ func provisionInviteKey(hiveID string) string { return derivePerHiveKey(provisionCurrentSecret(), infoInviteKey, hiveID) } +// provisionCustomerMatchKey returns the PER-HIVE key a spoke salts GitHub login +// hashes with for the customers hub import, injected as HIVE_CUSTOMER_MATCH_KEY. +// It is customerMatchKey against the CURRENT generation, so a re-provisioned or +// reconciled spoke moves to the current key after a master rotation (the hub +// still accepts every live generation via customerMatchKeys). Hub-hosted spokes +// never hold the master, so without this the import has no key and stays inert. +func provisionCustomerMatchKey(hiveID string) string { + return customerMatchKey(provisionCurrentSecret(), hiveID) +} + // heartbeatKeyFor returns the per-hive heartbeat bearer the hub EXPECTS from // hiveID. Mirror of provisionHeartbeatKey, resolved against the running hub's // own master rather than the provisioning-time lookup. @@ -354,6 +364,8 @@ const ( // both mints and verifies invite tokens with it, so it is symmetric; it exists // so inviteSigningSecret() no longer has to read the raw master. EnvInviteKey = "HIVE_INVITE_KEY" + // EnvCustomerMatchKey carries the per-hive customers hub import match key. + EnvCustomerMatchKey = "HIVE_CUSTOMER_MATCH_KEY" ) // spokeDomainKey resolves a domain sub-key for spoke-side code. It prefers the diff --git a/src/pkg/hub/perhive_env_generation_test.go b/src/pkg/hub/perhive_env_generation_test.go index d5f4826893..64a35dda73 100644 --- a/src/pkg/hub/perhive_env_generation_test.go +++ b/src/pkg/hub/perhive_env_generation_test.go @@ -65,6 +65,7 @@ func TestDesiredPerHiveEnvUsesCurrentNotPrevious(t *testing.T) { EnvHeartbeatKey: derivePerHiveKey(perHiveGenSecretB, infoHeartbeatKey, hiveID), EnvTerminalKey: derivePerHiveKey(perHiveGenSecretB, infoTerminalKey, hiveID), EnvInviteKey: derivePerHiveKey(perHiveGenSecretB, infoInviteKey, hiveID), + EnvCustomerMatchKey: customerMatchKey(perHiveGenSecretB, hiveID), EnvSSOPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(perHiveGenSecretB, infoSSOEd25519Seed)), envSessionPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(perHiveGenSecretB, infoSessionEd25519Seed)), } @@ -72,6 +73,7 @@ func TestDesiredPerHiveEnvUsesCurrentNotPrevious(t *testing.T) { EnvHeartbeatKey: derivePerHiveKey(perHiveGenSecretA, infoHeartbeatKey, hiveID), EnvTerminalKey: derivePerHiveKey(perHiveGenSecretA, infoTerminalKey, hiveID), EnvInviteKey: derivePerHiveKey(perHiveGenSecretA, infoInviteKey, hiveID), + EnvCustomerMatchKey: customerMatchKey(perHiveGenSecretA, hiveID), EnvSSOPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(perHiveGenSecretA, infoSSOEd25519Seed)), envSessionPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(perHiveGenSecretA, infoSessionEd25519Seed)), } @@ -113,6 +115,9 @@ func TestDesiredPerHiveEnvUsesCurrentNotPrevious(t *testing.T) { if provisionInviteKey(hiveID) != fromCurrent[EnvInviteKey] { t.Error("provisionInviteKey did not follow the current generation") } + if provisionCustomerMatchKey(hiveID) != fromCurrent[EnvCustomerMatchKey] { + t.Error("provisionCustomerMatchKey did not follow the current generation") + } if provisionSessionPublicKey() != fromCurrent[envSessionPublicKey] { t.Error("provisionSessionPublicKey did not follow the current generation") } diff --git a/src/pkg/hub/perhive_env_reconcile.go b/src/pkg/hub/perhive_env_reconcile.go index 934c12723a..dd736cc80e 100644 --- a/src/pkg/hub/perhive_env_reconcile.go +++ b/src/pkg/hub/perhive_env_reconcile.go @@ -132,6 +132,10 @@ func desiredPerHiveEnv(hiveID string) map[string]string { // Without it in this list a rotation would also never converge the // invite key, leaving it derived from a generation the hub has retired. EnvInviteKey: provisionInviteKey(hiveID), + // The customers hub import match key. Hub-hosted spokes never hold the + // master, so this is how they obtain it; reconciled so a rotation + // converges it to the current generation. + EnvCustomerMatchKey: provisionCustomerMatchKey(hiveID), // HIVE_SESSION_KEY is deliberately ABSENT (audit #3234 N2 follow-up). // RESIDUAL-2 made it per-hive as defence-in-depth, but every lane that // ever verified against it — F1 (Go legacy cookie lane), N3 (terminal @@ -188,6 +192,7 @@ func perHiveEnvNames() []string { EnvHeartbeatKey, EnvTerminalKey, EnvInviteKey, + EnvCustomerMatchKey, EnvSSOPublicKey, envSessionPublicKey, } diff --git a/src/pkg/hub/perhive_env_reconcile_test.go b/src/pkg/hub/perhive_env_reconcile_test.go index e9093f187c..02af9355a8 100644 --- a/src/pkg/hub/perhive_env_reconcile_test.go +++ b/src/pkg/hub/perhive_env_reconcile_test.go @@ -68,6 +68,8 @@ func TestDesiredPerHiveEnvMatchesProvisioningTemplate(t *testing.T) { envSessionPublicKey: provisionSessionPublicKey(), EnvTerminalKey: provisionTerminalKey(hiveID), EnvInviteKey: provisionInviteKey(hiveID), + // Issue #19246: the injected key equals customerMatchKey(currentMaster, hive). + EnvCustomerMatchKey: customerMatchKey(provisionCurrentSecret(), hiveID), } for name, v := range expect { if v == "" { @@ -93,6 +95,9 @@ func TestDesiredPerHiveEnvMatchesProvisioningTemplate(t *testing.T) { if other[EnvInviteKey] == want[EnvInviteKey] { t.Error("invite key is identical across hives — not per-hive") } + if other[EnvCustomerMatchKey] == want[EnvCustomerMatchKey] { + t.Error("customer match key is identical across hives — not per-hive") + } } // TestSessionKeyIsPermanentlyRemoved covers the issue #3234 removal: unlike diff --git a/src/pkg/hub/saas_provision.go b/src/pkg/hub/saas_provision.go index 1173952a56..865e902c3f 100644 --- a/src/pkg/hub/saas_provision.go +++ b/src/pkg/hub/saas_provision.go @@ -2669,6 +2669,8 @@ func provisionHive(h *SaaSHive, req *CreateHiveRequest, cluster *ClusterConfig, // injected it no longer does. Minted and verified on the same spoke, so // symmetric; per-hive so an invite link cannot travel between tenants. "InviteKey": provisionInviteKey(h.ID), + // Per-hive customers hub import match key (HIVE_CUSTOMER_MATCH_KEY). + "CustomerMatchKey": provisionCustomerMatchKey(h.ID), // Cluster-aware fields. "HubPublicURL": hubPublicURL(), "ClusterID": cluster.ID, @@ -3682,6 +3684,10 @@ spec: # in-flight invite links. Nothing else is affected. - name: HIVE_INVITE_KEY value: "{{.InviteKey}}" + # The per-hive customers hub import match key. Spokes never hold the + # master, so the hub hands them this derived key instead. + - name: HIVE_CUSTOMER_MATCH_KEY + value: "{{.CustomerMatchKey}}" {{- if .IsNginxIngress}} # HIVE_INGRESS_AUTHZ tells the Node proxy that an nginx ingress # auth-proxy sits IN FRONT of this pod and per-hive-authorizes every From 25740d2d8ed2654832bb8c880350dad71b2d053d Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 06:41:04 -0500 Subject: [PATCH 2/3] [scanner] test: include customer match key in raw-master derivation fixture Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/pkg/hub/hub_generations_f19_wiring_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pkg/hub/hub_generations_f19_wiring_test.go b/src/pkg/hub/hub_generations_f19_wiring_test.go index f5f510278c..3b6a3c8dca 100644 --- a/src/pkg/hub/hub_generations_f19_wiring_test.go +++ b/src/pkg/hub/hub_generations_f19_wiring_test.go @@ -167,6 +167,7 @@ func rawMasterDerivation(master, hiveID string) map[string]string { EnvHeartbeatKey: derivePerHiveKey(master, infoHeartbeatKey, hiveID), EnvTerminalKey: derivePerHiveKey(master, infoTerminalKey, hiveID), EnvInviteKey: derivePerHiveKey(master, infoInviteKey, hiveID), + EnvCustomerMatchKey: customerMatchKey(master, hiveID), EnvSSOPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(master, infoSSOEd25519Seed)), envSessionPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(master, infoSessionEd25519Seed)), } From ab8d3a27329a9d4d0da4ec56501f359c6b0ef514 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 06:52:24 -0500 Subject: [PATCH 3/3] [scanner] test: assert customer match key follows rotation in the F19 wiring test Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/pkg/hub/hub_generations_f19_wiring_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pkg/hub/hub_generations_f19_wiring_test.go b/src/pkg/hub/hub_generations_f19_wiring_test.go index 3b6a3c8dca..aed855e75c 100644 --- a/src/pkg/hub/hub_generations_f19_wiring_test.go +++ b/src/pkg/hub/hub_generations_f19_wiring_test.go @@ -106,6 +106,7 @@ func TestRotationReachesDesiredPerHiveEnv(t *testing.T) { EnvHeartbeatKey: derivePerHiveKey(newSecret, infoHeartbeatKey, hiveID), EnvTerminalKey: derivePerHiveKey(newSecret, infoTerminalKey, hiveID), EnvInviteKey: derivePerHiveKey(newSecret, infoInviteKey, hiveID), + EnvCustomerMatchKey: customerMatchKey(newSecret, hiveID), EnvSSOPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(newSecret, infoSSOEd25519Seed)), envSessionPublicKey: ssoPublicKeyFromSeed(deriveDomainKey(newSecret, infoSessionEd25519Seed)), }