Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Retire legacy self-hosted checkout compatibility paths

rcourtman7c8fddd9f0e1
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 81dbd5d8f3..a227fce61f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -176,6 +176,12 @@ management, and fleet control surfaces.
5. Add or change installer flags, persisted service arguments, or upgrade-safe re-entry behavior through `scripts/install.sh` and `scripts/install.ps1`.
6. Add or change profile management, the extracted agent profiles runtime owner, the pure unified-agent inventory/install model, the API-backed platform connections workspace shell, route model, reporting summary owner, shared install/inventory/dialog section owners, the split infrastructure install/reporting state owners, the split direct-node/discovery infrastructure settings owners plus their shared model, shared frontend install-command assembly, Proxmox setup/install API transport, TrueNAS platform-connection management, VMware platform-connection management, setup-completion install handoff transport, deploy-fallback manual install transport, and fleet-control presentation through `frontend-modern/src/api/agentProfiles.ts`, `frontend-modern/src/api/nodes.ts`, `frontend-modern/src/components/Settings/AgentProfilesPanel.tsx`, `frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts`, `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallPanel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx`, `frontend-modern/src/components/Settings/InfrastructureReportingPanel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInventorySection.tsx`, `frontend-modern/src/components/Settings/InfrastructureActiveRowDetails.tsx`, `frontend-modern/src/components/Settings/InfrastructureIgnoredRowDetails.tsx`, `frontend-modern/src/components/Settings/InfrastructureStopMonitoringDialog.tsx`, `frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx`, `frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx`, `frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts`, `frontend-modern/src/components/Settings/PlatformConnectionsWorkspace.tsx`, `frontend-modern/src/components/Settings/platformConnectionsModel.ts`, `frontend-modern/src/components/Settings/TrueNASSettingsPanel.tsx`, `frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts`, `frontend-modern/src/components/Settings/VMwareSettingsPanel.tsx`, `frontend-modern/src/components/Settings/useVMwareSettingsPanelState.ts`, `frontend-modern/src/components/Settings/ProxmoxSettingsPanel.tsx`, `frontend-modern/src/components/Settings/proxmoxSettingsModel.ts`, `frontend-modern/src/components/Settings/ProxmoxDirectWorkspace.tsx`, `frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx`, `frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx`, `frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx`, `frontend-modern/src/components/Settings/ProxmoxDeleteNodeDialog.tsx`, `frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx`, `frontend-modern/src/components/Settings/ConfiguredNodeTables.tsx`, `frontend-modern/src/components/Settings/SettingsSectionNav.tsx`, `frontend-modern/src/components/Settings/infrastructureSettingsModel.ts`, `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts`, `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts`, `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts`, `frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts`, `frontend-modern/src/components/Settings/NodeModal.tsx`, `frontend-modern/src/components/Settings/nodeModalModel.ts`, `frontend-modern/src/components/Settings/useNodeModalState.ts`, `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`, and `frontend-modern/src/utils/agentInstallCommand.ts`.
Those lifecycle-owned settings hooks may consume websocket state only through `frontend-modern/src/contexts/appRuntime.ts`; they must not import `frontend-modern/src/App.tsx` or recreate root-shell providers.
+ Agent-profile suggestion affordances remain adjacent assistant UX, not a
+ second AI settings reader. `frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts`
+ may gate the Ideas action only from the shared assistant-availability fact
+ seeded by `/api/security/status.sessionCapabilities.assistantEnabled`, and
+ must not probe `/api/settings/ai` just to decide whether that affordance
+ should render.
7. Preserve canonical token-lifecycle reads in shared `internal/api/` auth/security helpers so lifecycle-adjacent setup and install flows do not revoke a displayed relay pairing token after `lastUsedAt` proves that an already paired device is actively depending on that credential.
8. Preserve backend-owned Pulse Mobile relay runtime credential minting in those same shared `internal/api/` auth/security helpers so lifecycle-adjacent setup and install flows reuse the canonical mobile token route instead of reintroducing wildcard or browser-authored runtime token bundles.
9. Preserve the dedicated backend-owned `relay:mobile:access` capability and its governed backward-compatible route inventory plus the shared helper call sites around it, so lifecycle-adjacent setup and install flows do not widen the mobile device credential back into general AI chat/execute scope ownership.
@@ -194,8 +200,8 @@ management, and fleet control surfaces.
boundary. When shared `internal/api/router.go`,
`internal/api/router_routes_cloud.go`, `internal/api/licensing_handlers.go`,
or `internal/api/demo_mode_commercial.go` evolve public
- `/auth/license-purchase-start`, `/auth/license-purchase-handoff`, or
- `/auth/license-purchase-activate`, lifecycle-adjacent setup and fleet
+ `/auth/license-purchase-start` or `/auth/license-purchase-activate`,
+ lifecycle-adjacent setup and fleet
surfaces may rely on that public-route wiring but must not reinterpret the
commercial-owned `portal_handoff_id`, server-resolved checkout intent, purchase-return tokens,
activation-bridge form state, owned billing purchase-arrival states, or
@@ -207,7 +213,8 @@ management, and fleet control surfaces.
host counts, synthesize a second grandfather floor, or treat install-time
fleet inventory as the authority for commercial continuity. They also must
not depend on a status or entitlements read to seal pending grandfather
- continuity, or reinterpret continuity-verification payloads as a real
+ continuity, use those billing reads to restart pending continuity
+ reconciliation, or reinterpret continuity-verification payloads as a real
`0 / limit` monitored-system state.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 4aab21d818..590d86a91e 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -77,6 +77,7 @@ Own canonical runtime payload shapes between backend and frontend.
53. `internal/api/demo_mode_commercial.go`
54. `internal/api/security_status_capabilities.go`
55. `internal/api/demo_middleware.go`
+56. `frontend-modern/src/stores/aiRuntimeState.ts`
## Shared Boundaries
@@ -357,6 +358,17 @@ Own canonical runtime payload shapes between backend and frontend.
backend contract must keep provider test routes bound to the selected
provider's configured model instead of whichever other provider currently
owns the default `model` field.
+24. Keep shared AI runtime reads centralized on that same governed contract:
+ `frontend-modern/src/stores/aiRuntimeState.ts` is the canonical frontend
+ read owner for `/api/settings/ai` and `/api/ai/models`. AI-owned consumers
+ such as `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`,
+ `frontend-modern/src/components/AI/Chat/index.tsx`, and
+ `frontend-modern/src/components/AI/AICostDashboard.tsx` must reuse that
+ shared store for read-side runtime truth, while
+ `frontend-modern/src/components/Settings/useAISettingsState.ts` remains
+ the write-side settings owner. Non-AI settings surfaces such as
+ `frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts`
+ must not probe `/api/settings/ai` just to gate assistant affordances.
23. Keep API-backed first-target onboarding canonical on that same shared
infrastructure-settings boundary:
`frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`,
@@ -558,7 +570,12 @@ browser-facing `GET /v1/checkout/portal-handoff` response must not expose the
bound `checkout_intent_id`, and `POST /v1/checkout/session` must accept only
`portal_handoff_id` for product-originated upgrade arrivals so the license
server resolves the private checkout intent internally before Stripe session
-creation. Pulse's public `GET /auth/license-purchase-activate`
+creation. That same owned contract also retires the old compatibility
+bootstrap surfaces: Pulse must not expose a separate public
+`GET /auth/license-purchase-handoff` resolver, and the commercial server must
+not expose a direct browser bootstrap through `GET /v1/checkout/intent` once
+`portal_handoff_id` is canonical. Pulse's public
+`GET /auth/license-purchase-activate`
callback then serves an auto-submitting bridge into the owned POST activation
path, which redeems the completed checkout through the shared
license/commercial API before returning the browser to the owned billing plan
@@ -1216,7 +1233,11 @@ than ordinary read handlers. `/api/license/status` and
`capture_pending`, `captured_at`) and limit-level
`current_unavailable_reason`, but those request paths must not seal the
grandfather floor synchronously just because a billing read happened to arrive
-after the canonical usage view became available.
+after the canonical usage view became available. Those same read handlers must
+also stay side-effect free with respect to the reconciler lifecycle itself:
+they may observe pending continuity state, but only activation-state
+transitions such as activate, restore, grant refresh, and clear/revocation may
+bootstrap or tear down the pending-floor reconcile loop.
That same configured-path contract now also has an explicit shared owner for
manual auth env files: `internal/api/auth_env_path.go` must remain the only
place that derives `.env` from configured runtime paths, and neighboring
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index c556c6d696..5e8430424b 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -476,8 +476,8 @@ before it starts checkout, so the portal never trusts browser referrer state,
loose `feature` / `return_url` query parameters, or a raw browser-supplied
`checkout_intent_id` for self-hosted purchase completion. The portal proxy
must expose `GET /v1/checkout/portal-handoff` as the canonical browser
-bootstrap and must not keep the retired `GET /v1/checkout/intent` bootstrap
-path alive once `portal_handoff_id` is the owned contract. The browser-facing
+bootstrap, and the retired `GET /v1/checkout/intent` bootstrap must stay
+removed once `portal_handoff_id` is the owned contract. The browser-facing
portal handoff response must reveal only `portal_handoff_id`, feature, and
expiry metadata; it must not disclose the bound `checkout_intent_id`, and
browser checkout creation must post only `portal_handoff_id` so Pulse Account
@@ -801,7 +801,10 @@ status or entitlement reads may expose pending continuity state, but they must
not persist the grandfather floor directly from the request path once a
migrated installation is running. The owning licensing reconciler may backfill
the floor asynchronously after canonical monitored-system usage becomes
-settled.
+settled. The reconcile loop itself is activation-state-owned as well:
+activation, restore, grant refresh, and revocation/clear transitions may
+start or stop continuity reconciliation, but ordinary billing reads must stay
+observer-only and must not bootstrap that background work on demand.
That continuity rule cannot depend on webhook metadata being perfect. The
canonical Stripe price-to-plan lookup in `pkg/licensing/features.go` and
`pkg/licensing/stripe_subscription.go` must recognize the still-renewing
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 816feedceb..a3a05e22e6 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -187,8 +187,8 @@ regression protection.
commercial/router boundary, not the summary-chart hot path. When
`internal/api/router.go`, `internal/api/router_routes_cloud.go`, or
`internal/api/licensing_handlers.go` evolve
- `/auth/license-purchase-start`, `/auth/license-purchase-handoff`, or
- `/auth/license-purchase-activate`, performance work may keep those routes
+ `/auth/license-purchase-start` or `/auth/license-purchase-activate`,
+ performance work may keep those routes
cheap and redirect-safe, but it must not treat purchase-return callbacks as
chart-transport hot paths, fold summary-card caching into commercial
callback behavior, or reuse those public auth endpoints as a justification
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7c83f6eff9..d351c377bb 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -163,8 +163,8 @@ querying, and the operator-facing storage health presentation layer.
adjacent commercial/auth boundary. When `internal/api/router.go`,
`internal/api/router_routes_cloud.go`, `internal/api/licensing_handlers.go`,
or `internal/api/demo_mode_commercial.go` evolve
- `/auth/license-purchase-start`, `/auth/license-purchase-handoff`, or
- `/auth/license-purchase-activate`, storage and recovery may coexist with
+ `/auth/license-purchase-start` or `/auth/license-purchase-activate`,
+ storage and recovery may coexist with
those shared public-route helpers but must not reuse the commercial-owned
`portal_handoff_id`, server-resolved checkout intent, purchase-return tokens, activation-bridge
callbacks, owned billing purchase-arrival states, or demo-hidden
@@ -176,8 +176,9 @@ querying, and the operator-facing storage health presentation layer.
backup counts, or recovery-point presence when commercial continuity is
already defined by the canonical monitored-system resolver and activation
persistence. They also must not rely on billing-status reads to finalize a
- pending grandfather floor or collapse continuity-verification payloads
- into a real `0 / limit` monitored-system reading.
+ pending grandfather floor, use those reads to restart continuity
+ reconciliation, or collapse continuity-verification payloads into a real
+ `0 / limit` monitored-system reading.
## Forbidden Paths
diff --git a/frontend-modern/vite.config.ts b/frontend-modern/vite.config.ts
index a0c0ee66b3..0047a3f095 100644
--- a/frontend-modern/vite.config.ts
+++ b/frontend-modern/vite.config.ts
@@ -204,10 +204,6 @@ export default defineConfig({
target: backendUrl,
changeOrigin: true,
},
- '/auth/license-purchase-handoff': {
- target: backendUrl,
- changeOrigin: true,
- },
'/auth/license-purchase-activate': {
target: backendUrl,
changeOrigin: true,
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 79a5ea0681..91983adeae 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -5129,7 +5129,6 @@ func TestContract_DemoModeCommercialSurfacePolicy(t *testing.T) {
{method: http.MethodGet, path: "/api/upgrade-metrics/stats"},
{method: http.MethodPost, path: "/api/upgrade-metrics/events"},
{method: http.MethodGet, path: licensePurchaseStartPath},
- {method: http.MethodGet, path: licensePurchaseHandoffPath},
{method: http.MethodGet, path: "/auth/trial-activate"},
}
@@ -5302,54 +5301,6 @@ func TestContract_SelfHostedPurchaseHandoffJSONSnapshot(t *testing.T) {
assertJSONSnapshot(t, got, want)
}
-func TestContract_SelfHostedPurchaseLegacyHandoffJSONSnapshot(t *testing.T) {
- handler := createTestHandler(t)
- handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
-
- returnToken := issuePurchaseReturnToken(t, handler, "default", "max_monitored_systems")
- req := httptest.NewRequest(
- http.MethodGet,
- "https://pulse.example.com"+licensePurchaseHandoffPath+
- "?purchase_return_token="+url.QueryEscape(returnToken),
- nil,
- )
- rec := httptest.NewRecorder()
-
- handler.HandleCheckoutHandoff(rec, req)
-
- if rec.Code != http.StatusOK {
- t.Fatalf("status=%d, want %d: %s", rec.Code, http.StatusOK, rec.Body.String())
- }
- if got := rec.Header().Get("Access-Control-Allow-Origin"); got != "*" {
- t.Fatalf("allow-origin=%q, want *", got)
- }
- if got := rec.Header().Get("Cache-Control"); got != "no-store" {
- t.Fatalf("cache-control=%q, want no-store", got)
- }
-
- var payload struct {
- Feature string `json:"feature"`
- ActivationURLTemplate string `json:"activation_url_template"`
- }
- if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {
- t.Fatalf("decode payload: %v", err)
- }
-
- wantTemplate, err := licensePurchaseActivationTemplateURL(
- "https://pulse.example.com"+licensePurchaseActivationPath,
- returnToken,
- )
- if err != nil {
- t.Fatalf("licensePurchaseActivationTemplateURL: %v", err)
- }
- if payload.Feature != "max_monitored_systems" {
- t.Fatalf("feature=%q, want max_monitored_systems", payload.Feature)
- }
- if payload.ActivationURLTemplate != wantTemplate {
- t.Fatalf("activation_url_template=%q, want %q", payload.ActivationURLTemplate, wantTemplate)
- }
-}
-
func TestContract_HandoffExchangeJSONSnapshot(t *testing.T) {
key := []byte("test-handoff-key")
configDir := t.TempDir()
diff --git a/internal/api/demo_middleware_test.go b/internal/api/demo_middleware_test.go
index c96a942d28..c2f770b678 100644
--- a/internal/api/demo_middleware_test.go
+++ b/internal/api/demo_middleware_test.go
@@ -58,7 +58,6 @@ func TestDemoModeMiddleware(t *testing.T) {
{"demo on hidden commercial posture", true, http.MethodGet, "/api/license/commercial-posture", "", false, http.StatusNotFound, true},
{"demo on hidden license entitlements", true, http.MethodGet, "/api/license/entitlements", "", false, http.StatusNotFound, true},
{"demo on hidden checkout start", true, http.MethodGet, "/auth/license-purchase-start", "", false, http.StatusNotFound, true},
- {"demo on hidden checkout handoff", true, http.MethodGet, "/auth/license-purchase-handoff", "", false, http.StatusNotFound, true},
{"demo on hidden license activate", true, http.MethodPost, "/api/license/activate", "", false, http.StatusNotFound, true},
{"demo on hidden purchase start", true, http.MethodGet, licensePurchaseStartPath, "", false, http.StatusNotFound, true},
{"demo on hidden trial activation", true, http.MethodGet, "/auth/trial-activate", "", false, http.StatusNotFound, true},
diff --git a/internal/api/demo_mode_commercial.go b/internal/api/demo_mode_commercial.go
index dda0a12876..76ceac334f 100644
--- a/internal/api/demo_mode_commercial.go
+++ b/internal/api/demo_mode_commercial.go
@@ -38,11 +38,6 @@ var publicDemoCommercialPolicies = []publicDemoCommercialRoutePolicy{
exposure: publicDemoCommercialExposureHidden,
matches: exactDemoCommercialMethodPath(http.MethodGet, "/auth/license-purchase-start"),
},
- {
- route: licensePurchaseHandoffPath,
- exposure: publicDemoCommercialExposureHidden,
- matches: exactDemoCommercialMethodPath(http.MethodGet, licensePurchaseHandoffPath),
- },
{
route: "/api/license/activate",
exposure: publicDemoCommercialExposureHidden,
diff --git a/internal/api/demo_mode_commercial_test.go b/internal/api/demo_mode_commercial_test.go
index 25200fc101..4bf24c8b1e 100644
--- a/internal/api/demo_mode_commercial_test.go
+++ b/internal/api/demo_mode_commercial_test.go
@@ -69,10 +69,6 @@ func routeBelongsToPublicDemoCommercialBoundary(route string) bool {
return true
case route == "GET "+licensePurchaseStartPath:
return true
- case route == licensePurchaseHandoffPath:
- return true
- case route == "GET "+licensePurchaseHandoffPath:
- return true
case route == "GET /api/license/runtime-capabilities":
return false
case strings.HasPrefix(route, "/api/license/"):
diff --git a/internal/api/license_handlers_test.go b/internal/api/license_handlers_test.go
index b6bfdf0a8c..42ef6579ad 100644
--- a/internal/api/license_handlers_test.go
+++ b/internal/api/license_handlers_test.go
@@ -711,7 +711,7 @@ func TestHandleCheckoutStart_RedirectsToPulseAccountWithSignedReturnState(t *tes
t.Fatalf("method = %s, want POST", r.Method)
}
if err := json.NewDecoder(r.Body).Decode(&capturedReq); err != nil {
- t.Fatalf("decode checkout intent request: %v", err)
+ t.Fatalf("decode checkout portal handoff request: %v", err)
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]any{
@@ -768,7 +768,7 @@ func TestHandleCheckoutStart_RedirectsToPulseAccountWithSignedReturnState(t *tes
}
if capturedReq.Feature != "relay" {
- t.Fatalf("checkout intent feature = %q, want relay", capturedReq.Feature)
+ t.Fatalf("checkout portal handoff feature = %q, want relay", capturedReq.Feature)
}
activationURL, err := url.Parse(capturedReq.SuccessURL)
@@ -804,91 +804,6 @@ func TestHandleCheckoutStart_RedirectsToPulseAccountWithSignedReturnState(t *tes
}
}
-func TestHandleCheckoutHandoff_ResolvesServerOwnedPurchaseRecord(t *testing.T) {
- handler := createTestHandler(t)
- handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
-
- store := handler.purchaseCheckoutHandoffStore()
- if store == nil {
- t.Fatal("expected purchase checkout handoff store")
- }
- handoffID, err := store.issue(
- "max_monitored_systems",
- "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
- time.Now().UTC().Add(time.Hour),
- )
- if err != nil {
- t.Fatalf("issue purchase handoff: %v", err)
- }
-
- req := httptest.NewRequest(
- http.MethodGet,
- "https://pulse.example.com"+licensePurchaseHandoffPath+"?purchase_handoff_id="+url.QueryEscape(handoffID),
- nil,
- )
- rec := httptest.NewRecorder()
-
- handler.HandleCheckoutHandoff(rec, req)
-
- if rec.Code != http.StatusOK {
- t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusOK, rec.Body.String())
- }
- var resp struct {
- Feature string `json:"feature"`
- ActivationURLTemplate string `json:"activation_url_template"`
- }
- if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
- t.Fatalf("unmarshal response: %v", err)
- }
- if resp.Feature != "max_monitored_systems" {
- t.Fatalf("feature = %q, want max_monitored_systems", resp.Feature)
- }
- if resp.ActivationURLTemplate != "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}" {
- t.Fatalf("activation_url_template = %q", resp.ActivationURLTemplate)
- }
-}
-
-func TestHandleCheckoutHandoff_ReturnsVerifiedActivationTemplate(t *testing.T) {
- handler := createTestHandler(t)
- handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
-
- returnToken := issuePurchaseReturnToken(t, handler, "default", "max_monitored_systems")
- req := httptest.NewRequest(
- http.MethodGet,
- "https://pulse.example.com"+licensePurchaseHandoffPath+"?purchase_return_token="+url.QueryEscape(returnToken),
- nil,
- )
- rec := httptest.NewRecorder()
-
- handler.HandleCheckoutHandoff(rec, req)
-
- if rec.Code != http.StatusOK {
- t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusOK, rec.Body.String())
- }
-
- var resp struct {
- Feature string `json:"feature"`
- ActivationURLTemplate string `json:"activation_url_template"`
- }
- if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
- t.Fatalf("unmarshal response: %v", err)
- }
- if resp.Feature != "max_monitored_systems" {
- t.Fatalf("feature = %q, want max_monitored_systems", resp.Feature)
- }
-
- expectedTemplate, err := licensePurchaseActivationTemplateURL(
- "https://pulse.example.com"+licensePurchaseActivationPath,
- returnToken,
- )
- if err != nil {
- t.Fatalf("licensePurchaseActivationTemplateURL: %v", err)
- }
- if resp.ActivationURLTemplate != expectedTemplate {
- t.Fatalf("activation_url_template = %q, want %q", resp.ActivationURLTemplate, expectedTemplate)
- }
-}
-
func TestHandleCheckoutActivation_GETRendersAutoSubmitBridge(t *testing.T) {
handler := createTestHandler(t)
handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
diff --git a/internal/api/licensing_bridge.go b/internal/api/licensing_bridge.go
index 7990823bbc..2b19466adf 100644
--- a/internal/api/licensing_bridge.go
+++ b/internal/api/licensing_bridge.go
@@ -34,6 +34,7 @@ type licenseFeatureChecker = pkglicensing.FeatureChecker
type licenseFeaturesResponse = pkglicensing.LicenseFeaturesResponse
type activateLicenseRequestModel = pkglicensing.ActivateLicenseRequest
type activateLicenseResponseModel = pkglicensing.ActivateLicenseResponse
+type activationStateModel = pkglicensing.ActivationState
type trialStartDecisionModel = pkglicensing.TrialStartDecision
type trialStartDenialReasonModel = pkglicensing.TrialStartDenialReason
type billingStoreModel = pkglicensing.BillingStore
@@ -58,8 +59,6 @@ type trialActivationClaimsModel = pkglicensing.TrialActivationClaims
type purchaseReturnClaimsModel = pkglicensing.PurchaseReturnClaims
type entitlementLeaseClaimsModel = pkglicensing.EntitlementLeaseClaims
type licenseTier = pkglicensing.Tier
-type checkoutIntentRequestModel = pkglicensing.CheckoutIntentRequest
-type checkoutIntentResponseModel = pkglicensing.CheckoutIntentResponse
type checkoutPortalHandoffRequestModel = pkglicensing.CheckoutPortalHandoffRequest
type checkoutPortalHandoffResponseModel = pkglicensing.CheckoutPortalHandoffResponse
diff --git a/internal/api/licensing_handlers.go b/internal/api/licensing_handlers.go
index c78c8a4860..8215efcaec 100644
--- a/internal/api/licensing_handlers.go
+++ b/internal/api/licensing_handlers.go
@@ -25,8 +25,6 @@ import (
const (
trialStartRateLimitBurst = 6
trialStartRateLimitWindow = 15 * time.Minute
- licensePurchaseHandoffPath = "/auth/license-purchase-handoff"
- licensePurchaseHandoffIDField = "purchase_handoff_id"
licensePurchaseStartPath = "/auth/license-purchase-start"
licensePurchaseActivationPath = "/auth/license-purchase-activate"
licensePurchaseSessionIDField = "session_id"
@@ -60,7 +58,6 @@ type LicenseHandlers struct {
trialLimiter *RateLimiter
trialReplay *jtiReplayStore
trialInitiations *trialSignupInitiationStore
- purchaseHandoffs *purchaseCheckoutHandoffStore
trialRedeemer func(token string) (*hostedTrialRedemptionResponse, error)
monitor *monitoring.Monitor
mtMonitor *monitoring.MultiTenantMonitor
@@ -80,11 +77,9 @@ func NewLicenseHandlers(mtp *config.MultiTenantPersistence, hostedMode bool, cfg
var trialReplay *jtiReplayStore
var trialInitiations *trialSignupInitiationStore
- var purchaseHandoffs *purchaseCheckoutHandoffStore
if mtp != nil {
trialReplay = &jtiReplayStore{configDir: mtp.BaseDataDir()}
trialInitiations = &trialSignupInitiationStore{configDir: mtp.BaseDataDir()}
- purchaseHandoffs = &purchaseCheckoutHandoffStore{configDir: mtp.BaseDataDir()}
}
return &LicenseHandlers{
@@ -94,7 +89,6 @@ func NewLicenseHandlers(mtp *config.MultiTenantPersistence, hostedMode bool, cfg
trialLimiter: NewRateLimiter(trialStartRateLimitBurst, trialStartRateLimitWindow),
trialReplay: trialReplay,
trialInitiations: trialInitiations,
- purchaseHandoffs: purchaseHandoffs,
}
}
@@ -283,21 +277,6 @@ func (h *LicenseHandlers) purchaseReturnSigningKey() ([]byte, error) {
return signingKey, nil
}
-func (h *LicenseHandlers) purchaseCheckoutHandoffStore() *purchaseCheckoutHandoffStore {
- if h == nil {
- return nil
- }
- if h.purchaseHandoffs != nil {
- return h.purchaseHandoffs
- }
- dataDir := h.purchaseReturnDataDir()
- if strings.TrimSpace(dataDir) == "" {
- return nil
- }
- h.purchaseHandoffs = &purchaseCheckoutHandoffStore{configDir: dataDir}
- return h.purchaseHandoffs
-}
-
func pulseAccountUpgradeURLForRequest(portalHandoffID string, query url.Values) (string, error) {
portalURL := strings.TrimSpace(pulseAccountPortalURLFromLicensing(""))
if portalURL == "" {
@@ -352,25 +331,6 @@ func publicAbsoluteURLForPath(r *http.Request, cfg *config.Config, path string)
return base.ResolveReference(relative).String(), nil
}
-func licensePurchaseHandoffURLForRequest(
- r *http.Request,
- cfg *config.Config,
- handoffID string,
-) (string, error) {
- baseURL := publicBaseURLForRequest(r, cfg)
- if baseURL == "" {
- return "", fmt.Errorf("purchase handoff base url is unavailable")
- }
- parsed, err := url.Parse(baseURL + licensePurchaseHandoffPath)
- if err != nil || parsed == nil {
- return "", fmt.Errorf("parse purchase handoff url: %w", err)
- }
- query := parsed.Query()
- query.Set(licensePurchaseHandoffIDField, strings.TrimSpace(handoffID))
- parsed.RawQuery = query.Encode()
- return parsed.String(), nil
-}
-
func licensePurchaseActivationTemplateURL(returnURL, returnToken string) (string, error) {
parsed, err := url.Parse(strings.TrimSpace(returnURL))
if err != nil || parsed == nil {
@@ -472,13 +432,6 @@ func writeLicensePurchaseActivationContinuePage(
)
}
-func writePublicPurchaseHandoffHeaders(w http.ResponseWriter) {
- w.Header().Set("Access-Control-Allow-Origin", "*")
- w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
- w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
- w.Header().Set("Cache-Control", "no-store")
-}
-
func (h *LicenseHandlers) verifiedPurchaseReturnClaims(
r *http.Request,
returnToken string,
@@ -522,7 +475,6 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ
if err := h.ensureEvaluatorForOrg(orgID, svc); err != nil {
log.Warn().Str("org_id", orgID).Err(err).Msg("Failed to refresh license evaluator for org")
}
- h.ensureLegacyGrandfatherReconcileLoop(orgID, svc)
h.ensureHostedEntitlementRefreshForOrg(orgID, svc)
// We need persistence too, reconstruct it or cache it?
// Reconstructing persistence is cheap (just a struct with path).
@@ -539,6 +491,7 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ
}
service := newLicenseService()
+ h.bindLegacyGrandfatherReconcileOwnership(orgID, service)
// Wire license server client and persistence so activation / refresh can use them.
lsClient := newLicenseServerClientFromLicensing("")
@@ -560,7 +513,7 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ
if err := service.RestoreActivation(activationState); err != nil {
log.Warn().Str("org_id", orgID).Err(err).Msg("Failed to restore activation")
} else {
- h.ensureLegacyGrandfatherReconcileLoop(orgID, service)
+ h.reconcileLegacyMigrationGrandfatherFloor(ctx, orgID, service)
if clearErr := h.setCommercialMigrationState(orgID, nil); clearErr != nil {
log.Warn().Str("org_id", orgID).Err(clearErr).Msg("Failed to clear commercial migration state after activation restore")
}
@@ -615,13 +568,16 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ
service.StopGrantRefresh() // stop our orphaned refresh loop if started
service.StopRevocationPoll() // stop our orphaned revocation poller if started
svc := actual.(*licenseService)
- h.ensureLegacyGrandfatherReconcileLoop(orgID, svc)
+ // Re-home legacy continuity ownership onto the canonical service when
+ // concurrent first-request initialization races create an orphan.
+ h.stopLegacyGrandfatherReconcileLoop(orgID)
+ h.syncLegacyGrandfatherReconcileOwnership(orgID, svc)
h.ensureHostedEntitlementRefreshForOrg(orgID, svc)
p, pErr := h.getPersistenceForOrg(orgID)
return svc, p, pErr
}
- h.ensureLegacyGrandfatherReconcileLoop(orgID, service)
+ h.syncLegacyGrandfatherReconcileOwnership(orgID, service)
h.ensureHostedEntitlementRefreshForOrg(orgID, service)
return service, persistence, nil
@@ -1528,70 +1484,6 @@ func (h *LicenseHandlers) HandleCheckoutStart(w http.ResponseWriter, r *http.Req
http.Redirect(w, r, destination, http.StatusSeeOther)
}
-// HandleCheckoutHandoff verifies the signed checkout handoff and returns the
-// canonical Pulse activation URL template for Pulse Account checkout success.
-func (h *LicenseHandlers) HandleCheckoutHandoff(w http.ResponseWriter, r *http.Request) {
- writePublicPurchaseHandoffHeaders(w)
- if r.Method == http.MethodOptions {
- w.WriteHeader(http.StatusNoContent)
- return
- }
- if r.Method != http.MethodGet {
- http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
- return
- }
-
- if handoffID := strings.TrimSpace(r.URL.Query().Get(licensePurchaseHandoffIDField)); handoffID != "" {
- handoffStore := h.purchaseCheckoutHandoffStore()
- if handoffStore == nil {
- http.Error(w, "purchase handoff is unavailable", http.StatusServiceUnavailable)
- return
- }
- record, found, err := handoffStore.resolve(handoffID, time.Now().UTC())
- if err != nil {
- log.Warn().Err(err).Msg("Purchase handoff record lookup failed")
- http.Error(w, "purchase handoff is invalid", http.StatusBadRequest)
- return
- }
- if !found || record == nil {
- http.Error(w, "purchase handoff is invalid", http.StatusBadRequest)
- return
- }
-
- w.Header().Set("Content-Type", "application/json")
- _ = json.NewEncoder(w).Encode(map[string]string{
- "activation_url_template": strings.TrimSpace(record.ActivationURLTemplate),
- "feature": strings.TrimSpace(record.Feature),
- })
- return
- }
-
- returnToken := strings.TrimSpace(r.URL.Query().Get(licensePurchaseReturnTokenField))
- if returnToken == "" {
- http.Error(w, "purchase handoff id or return token is required", http.StatusBadRequest)
- return
- }
- claims, err := h.verifiedPurchaseReturnClaims(r, returnToken)
- if err != nil {
- log.Warn().Err(err).Msg("Purchase handoff token verification failed")
- http.Error(w, "purchase handoff is invalid", http.StatusBadRequest)
- return
- }
-
- activationURLTemplate, err := licensePurchaseActivationTemplateURL(claims.ReturnURL, returnToken)
- if err != nil {
- log.Warn().Err(err).Msg("Purchase handoff activation template build failed")
- http.Error(w, "purchase handoff is invalid", http.StatusBadRequest)
- return
- }
-
- w.Header().Set("Content-Type", "application/json")
- _ = json.NewEncoder(w).Encode(map[string]string{
- "activation_url_template": activationURLTemplate,
- "feature": strings.TrimSpace(claims.Feature),
- })
-}
-
// HandleCheckoutActivation handles the local checkout return at
// /auth/license-purchase-activate. GET renders the auto-submitting bridge for
// a completed Stripe redirect, while POST redeems the completed session into a
diff --git a/internal/api/purchase_checkout_handoff_store.go b/internal/api/purchase_checkout_handoff_store.go
deleted file mode 100644
index 3c4c64d1f5..0000000000
--- a/internal/api/purchase_checkout_handoff_store.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package api
-
-import (
- "crypto/rand"
- "crypto/sha256"
- "database/sql"
- "encoding/base64"
- "encoding/hex"
- "fmt"
- "net/url"
- "os"
- "path/filepath"
- "strings"
- "sync"
- "time"
-
- _ "modernc.org/sqlite"
-)
-
-const purchaseCheckoutHandoffTTL = 2 * time.Hour
-
-type purchaseCheckoutHandoffRecord struct {
- Feature string
- ActivationURLTemplate string
-}
-
-type purchaseCheckoutHandoffStore struct {
- once sync.Once
- db *sql.DB
- mu sync.Mutex
-
- configDir string
- initErr error
-}
-
-func (s *purchaseCheckoutHandoffStore) init() {
- s.once.Do(func() {
- dir := filepath.Clean(s.configDir)
- if strings.TrimSpace(dir) == "" {
- s.initErr = fmt.Errorf("configDir is required")
- return
- }
- secretsDir := filepath.Join(dir, "secrets")
- if err := os.MkdirAll(secretsDir, handoffPrivateDirPerm); err != nil {
- s.initErr = fmt.Errorf("create purchase handoff secrets dir: %w", err)
- return
- }
- if err := os.Chmod(secretsDir, handoffPrivateDirPerm); err != nil {
- s.initErr = fmt.Errorf("chmod purchase handoff secrets dir: %w", err)
- return
- }
-
- dbPath := filepath.Join(secretsDir, "purchase_checkout_handoff.db")
- dsn := dbPath + "?" + url.Values{
- "_pragma": []string{
- "busy_timeout(30000)",
- "journal_mode(WAL)",
- "synchronous(NORMAL)",
- },
- }.Encode()
-
- db, err := sql.Open("sqlite", dsn)
- if err != nil {
- s.initErr = fmt.Errorf("open purchase handoff db: %w", err)
- return
- }
- db.SetMaxOpenConns(1)
- db.SetMaxIdleConns(1)
- db.SetConnMaxLifetime(0)
-
- schema := `
- CREATE TABLE IF NOT EXISTS purchase_checkout_handoffs (
- handoff_hash TEXT PRIMARY KEY,
- feature TEXT NOT NULL,
- activation_url_template TEXT NOT NULL,
- expires_at INTEGER NOT NULL
- );
- CREATE INDEX IF NOT EXISTS idx_purchase_checkout_handoffs_expires_at
- ON purchase_checkout_handoffs(expires_at);
- `
- if _, err := db.Exec(schema); err != nil {
- _ = db.Close()
- s.initErr = fmt.Errorf("init purchase handoff schema: %w", err)
- return
- }
- for _, path := range []string{dbPath, dbPath + "-wal", dbPath + "-shm"} {
- if err := hardenPrivateFile(path, handoffPrivateFilePerm); err != nil {
- _ = db.Close()
- s.initErr = fmt.Errorf("harden purchase handoff file permissions: %w", err)
- return
- }
- }
-
- s.db = db
- })
-}
-
-func (s *purchaseCheckoutHandoffStore) issue(
- feature string,
- activationURLTemplate string,
- expiresAt time.Time,
-) (string, error) {
- s.init()
- if s.initErr != nil {
- return "", s.initErr
- }
- if s.db == nil {
- return "", fmt.Errorf("purchase handoff store not initialized")
- }
- activationURLTemplate = strings.TrimSpace(activationURLTemplate)
- if activationURLTemplate == "" {
- return "", fmt.Errorf("activation_url_template is required")
- }
- expiresAt = expiresAt.UTC()
- if expiresAt.IsZero() {
- expiresAt = time.Now().UTC().Add(purchaseCheckoutHandoffTTL)
- }
-
- rawID, err := randomPurchaseCheckoutHandoffID()
- if err != nil {
- return "", err
- }
- handoffHash := hashPurchaseCheckoutHandoffID(rawID)
-
- s.mu.Lock()
- defer s.mu.Unlock()
-
- if err := s.cleanupExpiredLocked(time.Now().UTC()); err != nil {
- return "", err
- }
- if _, err := s.db.Exec(
- `INSERT INTO purchase_checkout_handoffs (handoff_hash, feature, activation_url_template, expires_at)
- VALUES (?, ?, ?, ?)`,
- handoffHash,
- strings.TrimSpace(feature),
- activationURLTemplate,
- expiresAt.Unix(),
- ); err != nil {
- return "", fmt.Errorf("insert purchase handoff: %w", err)
- }
- return rawID, nil
-}
-
-func (s *purchaseCheckoutHandoffStore) resolve(
- rawID string,
- now time.Time,
-) (*purchaseCheckoutHandoffRecord, bool, error) {
- s.init()
- if s.initErr != nil {
- return nil, false, s.initErr
- }
- if s.db == nil {
- return nil, false, fmt.Errorf("purchase handoff store not initialized")
- }
- handoffHash := hashPurchaseCheckoutHandoffID(rawID)
- if handoffHash == "" {
- return nil, false, nil
- }
- now = now.UTC()
-
- s.mu.Lock()
- defer s.mu.Unlock()
-
- if err := s.cleanupExpiredLocked(now); err != nil {
- return nil, false, err
- }
-
- record := &purchaseCheckoutHandoffRecord{}
- var expiresAt int64
- err := s.db.QueryRow(
- `SELECT feature, activation_url_template, expires_at
- FROM purchase_checkout_handoffs
- WHERE handoff_hash = ?`,
- handoffHash,
- ).Scan(&record.Feature, &record.ActivationURLTemplate, &expiresAt)
- if err == sql.ErrNoRows {
- return nil, false, nil
- }
- if err != nil {
- return nil, false, fmt.Errorf("lookup purchase handoff: %w", err)
- }
- if expiresAt <= now.Unix() {
- if _, deleteErr := s.db.Exec(
- `DELETE FROM purchase_checkout_handoffs WHERE handoff_hash = ?`,
- handoffHash,
- ); deleteErr != nil {
- return nil, false, fmt.Errorf("delete expired purchase handoff: %w", deleteErr)
- }
- return nil, false, nil
- }
- return record, true, nil
-}
-
-func (s *purchaseCheckoutHandoffStore) cleanupExpiredLocked(now time.Time) error {
- if _, err := s.db.Exec(
- `DELETE FROM purchase_checkout_handoffs WHERE expires_at <= ?`,
- now.UTC().Unix(),
- ); err != nil {
- return fmt.Errorf("cleanup purchase handoffs: %w", err)
- }
- return nil
-}
-
-func hashPurchaseCheckoutHandoffID(raw string) string {
- raw = strings.TrimSpace(raw)
- if raw == "" {
- return ""
- }
- sum := sha256.Sum256([]byte(raw))
- return hex.EncodeToString(sum[:])
-}
-
-func randomPurchaseCheckoutHandoffID() (string, error) {
- buf := make([]byte, 32)
- if _, err := rand.Read(buf); err != nil {
- return "", fmt.Errorf("generate purchase handoff id: %w", err)
- }
- return "pch1_" + base64.RawURLEncoding.EncodeToString(buf), nil
-}
diff --git a/internal/api/purchase_checkout_handoff_store_test.go b/internal/api/purchase_checkout_handoff_store_test.go
deleted file mode 100644
index 105ee5597c..0000000000
--- a/internal/api/purchase_checkout_handoff_store_test.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package api
-
-import (
- "testing"
- "time"
-)
-
-func TestPurchaseCheckoutHandoffStore_IssueAndResolve(t *testing.T) {
- store := &purchaseCheckoutHandoffStore{configDir: t.TempDir()}
- expiresAt := time.Now().UTC().Add(time.Hour)
-
- handoffID, err := store.issue(
- "relay",
- "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
- expiresAt,
- )
- if err != nil {
- t.Fatalf("issue: %v", err)
- }
- if handoffID == "" {
- t.Fatal("expected opaque handoff id")
- }
-
- record, found, err := store.resolve(handoffID, time.Now().UTC())
- if err != nil {
- t.Fatalf("resolve: %v", err)
- }
- if !found || record == nil {
- t.Fatal("expected stored handoff record")
- }
- if record.Feature != "relay" {
- t.Fatalf("record.Feature = %q, want relay", record.Feature)
- }
-}
-
-func TestPurchaseCheckoutHandoffStore_RejectsExpiredRecords(t *testing.T) {
- store := &purchaseCheckoutHandoffStore{configDir: t.TempDir()}
- expiresAt := time.Now().UTC().Add(5 * time.Minute)
-
- handoffID, err := store.issue(
- "relay",
- "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
- expiresAt,
- )
- if err != nil {
- t.Fatalf("issue: %v", err)
- }
-
- record, found, err := store.resolve(handoffID, expiresAt.Add(time.Second))
- if err != nil {
- t.Fatalf("resolve: %v", err)
- }
- if found || record != nil {
- t.Fatal("expected expired handoff record to be unavailable")
- }
-}
diff --git a/internal/api/route_inventory_test.go b/internal/api/route_inventory_test.go
index b99ef16dcb..fdb5933558 100644
--- a/internal/api/route_inventory_test.go
+++ b/internal/api/route_inventory_test.go
@@ -278,7 +278,6 @@ var publicRouteAllowlist = []string{
"/api/auto-register",
"/auth/cloud-handoff",
"/auth/trial-activate",
- licensePurchaseHandoffPath,
licensePurchaseActivationPath,
"/install.sh",
"/install.ps1",
@@ -338,7 +337,6 @@ var bareRouteAllowlist = []string{
"/api/clusters/",
"/auth/cloud-handoff",
"/auth/trial-activate",
- licensePurchaseHandoffPath,
licensePurchaseActivationPath,
"/ws",
"/api/saml/",
@@ -458,7 +456,6 @@ var allRouteAllowlist = []string{
"PUT /api/upgrade-metrics/config",
"GET /api/admin/upgrade-metrics-funnel",
"GET /auth/license-purchase-start",
- licensePurchaseHandoffPath,
"GET /api/orgs",
"POST /api/orgs",
"GET /api/orgs/{id}",
diff --git a/internal/api/router.go b/internal/api/router.go
index b4b2028366..635b02b217 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -3482,7 +3482,6 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
"/api/ai/oauth/callback", // OAuth callback from Anthropic for Claude subscription auth
"/auth/cloud-handoff", // Cloud control plane handoff (token-authenticated)
"/auth/trial-activate", // Hosted trial signup callback (token-authenticated)
- "/auth/license-purchase-handoff", // Self-hosted checkout handoff resolution for Pulse Account
"/auth/license-purchase-activate", // Self-hosted checkout return (session-authenticated via commercial backend)
}
diff --git a/internal/api/router_routes_cloud.go b/internal/api/router_routes_cloud.go
index 3c03ab55d4..b8ca7445f2 100644
--- a/internal/api/router_routes_cloud.go
+++ b/internal/api/router_routes_cloud.go
@@ -74,8 +74,6 @@ func (r *Router) registerHostedRoutes(hostedSignupHandlers *HostedSignupHandlers
if r.licenseHandlers != nil {
// Self-hosted commercial checkout handoff: mint a signed return token and redirect into Pulse Account.
r.mux.HandleFunc("GET /auth/license-purchase-start", RequireAuth(routerConfig, r.licenseHandlers.HandleCheckoutStart))
- // Public cross-origin handoff resolver: Pulse Account uses the signed token to recover the verified local activation URL.
- r.mux.HandleFunc("/auth/license-purchase-handoff", r.licenseHandlers.HandleCheckoutHandoff)
// Hosted trial signup callback: signed token activation flow for self-hosted Pulse Pro trials.
r.mux.HandleFunc("/auth/trial-activate", r.licenseHandlers.HandleTrialActivation)
// Self-hosted commercial checkout return: complete purchase activation without manual key entry.
diff --git a/pkg/licensing/license_server_client.go b/pkg/licensing/license_server_client.go
index 50529eae63..3696181456 100644
--- a/pkg/licensing/license_server_client.go
+++ b/pkg/licensing/license_server_client.go
@@ -37,22 +37,6 @@ type CheckoutSessionResult struct {
PlanKey string `json:"plan_key,omitempty"`
}
-// CheckoutIntentRequest is the canonical server-owned request for a hosted
-// self-hosted checkout handoff.
-type CheckoutIntentRequest struct {
- Feature string `json:"feature,omitempty"`
- SuccessURL string `json:"success_url"`
- CancelURL string `json:"cancel_url"`
-}
-
-// CheckoutIntentResponse is the canonical checkout-intent record returned by
-// the license server.
-type CheckoutIntentResponse struct {
- CheckoutIntentID string `json:"checkout_intent_id"`
- Feature string `json:"feature,omitempty"`
- ExpiresAt int64 `json:"expires_at,omitempty"`
-}
-
// CheckoutPortalHandoffRequest is the canonical server-owned request for a
// Pulse Account portal bootstrap record that hides commercial flow state from
// the browser.
@@ -228,38 +212,6 @@ func (c *LicenseServerClient) GetCheckoutSessionResult(ctx context.Context, sess
return &result, nil
}
-// CreateCheckoutIntent stores a server-owned self-hosted checkout intent and
-// returns its commercial checkout_intent_id.
-func (c *LicenseServerClient) CreateCheckoutIntent(ctx context.Context, req CheckoutIntentRequest) (*CheckoutIntentResponse, error) {
- body, err := json.Marshal(req)
- if err != nil {
- return nil, fmt.Errorf("marshal checkout intent request: %w", err)
- }
-
- httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/v1/checkout/intent", bytes.NewReader(body))
- if err != nil {
- return nil, fmt.Errorf("create checkout intent request: %w", err)
- }
- httpReq.Header.Set("Content-Type", "application/json")
- httpReq.Header.Set("Accept", "application/json")
-
- resp, err := c.httpClient.Do(httpReq)
- if err != nil {
- return nil, fmt.Errorf("checkout intent request failed: %w", err)
- }
- defer resp.Body.Close()
-
- if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
- return nil, c.parseError(resp)
- }
-
- var result CheckoutIntentResponse
- if err := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)).Decode(&result); err != nil {
- return nil, fmt.Errorf("decode checkout intent response: %w", err)
- }
- return &result, nil
-}
-
// CreateCheckoutPortalHandoff stores a server-owned Pulse Account bootstrap
// record and returns an opaque portal_handoff_id for browser navigation.
func (c *LicenseServerClient) CreateCheckoutPortalHandoff(ctx context.Context, req CheckoutPortalHandoffRequest) (*CheckoutPortalHandoffResponse, error) {
diff --git a/pkg/licensing/license_server_client_test.go b/pkg/licensing/license_server_client_test.go
index c2d87d4ac5..f9df5a266c 100644
--- a/pkg/licensing/license_server_client_test.go
+++ b/pkg/licensing/license_server_client_test.go
@@ -326,61 +326,6 @@ func TestClientGetCheckoutSessionResult(t *testing.T) {
})
}
-func TestClientCreateCheckoutIntent(t *testing.T) {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.Method != http.MethodPost {
- t.Errorf("Method = %q, want POST", r.Method)
- }
- if r.URL.Path != "/v1/checkout/intent" {
- t.Errorf("Path = %q, want /v1/checkout/intent", r.URL.Path)
- }
- if r.Header.Get("Content-Type") != "application/json" {
- t.Errorf("Content-Type = %q, want application/json", r.Header.Get("Content-Type"))
- }
- if r.Header.Get("Accept") != "application/json" {
- t.Errorf("Accept = %q, want application/json", r.Header.Get("Accept"))
- }
-
- var req CheckoutIntentRequest
- if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
- t.Fatalf("decode request: %v", err)
- }
- if req.Feature != "max_monitored_systems" {
- t.Fatalf("Feature = %q, want max_monitored_systems", req.Feature)
- }
- if req.SuccessURL != "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}" {
- t.Fatalf("SuccessURL = %q", req.SuccessURL)
- }
- if req.CancelURL != "https://pulse.example.com/settings/system/billing/plan?intent=max_monitored_systems&purchase=cancelled" {
- t.Fatalf("CancelURL = %q", req.CancelURL)
- }
-
- w.WriteHeader(http.StatusOK)
- _ = json.NewEncoder(w).Encode(CheckoutIntentResponse{
- CheckoutIntentID: "cki_test_123",
- Feature: "max_monitored_systems",
- ExpiresAt: 1_775_000_000,
- })
- }))
- defer server.Close()
-
- client := NewLicenseServerClient(server.URL)
- result, err := client.CreateCheckoutIntent(context.Background(), CheckoutIntentRequest{
- Feature: "max_monitored_systems",
- SuccessURL: "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
- CancelURL: "https://pulse.example.com/settings/system/billing/plan?intent=max_monitored_systems&purchase=cancelled",
- })
- if err != nil {
- t.Fatalf("CreateCheckoutIntent failed: %v", err)
- }
- if result.CheckoutIntentID != "cki_test_123" {
- t.Fatalf("CheckoutIntentID = %q, want cki_test_123", result.CheckoutIntentID)
- }
- if result.Feature != "max_monitored_systems" {
- t.Fatalf("Feature = %q, want max_monitored_systems", result.Feature)
- }
-}
-
func TestClientCreateCheckoutPortalHandoff(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {