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.

Self-issue the MSP evaluation licence, and fix two things it exposed

rcourtman9d9f13e7b0a7
diff --git a/cmd/pulse-control-plane/provider_msp_proof.go b/cmd/pulse-control-plane/provider_msp_proof.go
index c757a7bd69..e7e3671bde 100644
--- a/cmd/pulse-control-plane/provider_msp_proof.go
+++ b/cmd/pulse-control-plane/provider_msp_proof.go
@@ -198,6 +198,7 @@ func newProviderMSPProofRuntimeFromConfig(cfg *cloudcp.CPConfig) (*providerMSPPr
hostedEntitlements := entitlements.NewService(reg, cfg.BaseURL, cfg.TrialActivationPrivateKey)
if cfg.IsProviderHostedMSP() {
+ hostedEntitlements.SetProviderHosted(true)
hostedEntitlements.SetProviderLicense(cfg.ProviderMSPLicenseKey)
}
provisioner := cpstripe.NewProvisioner(
diff --git a/deploy/provider-msp/.env.example b/deploy/provider-msp/.env.example
index b5f5a70049..62c92b49a5 100644
--- a/deploy/provider-msp/.env.example
+++ b/deploy/provider-msp/.env.example
@@ -31,12 +31,16 @@ PULSE_PROVIDER_MSP_ROOT_SPACECHECK_DIR=/var/lib/pulse-provider-msp/spacecheck/ro
PULSE_PROVIDER_MSP_DOCKER_SPACECHECK_DIR=/var/lib/docker/.pulse-provider-msp-spacecheck
CP_TRUSTED_PROXY_CIDRS=172.30.0.0/24
-# Licence file. Leave BLANK to evaluate: the control plane runs on msp_eval,
-# which is the full product capped at 2 client workspaces, so you can stand
-# this up and onboard two real clients without talking to anyone first.
+# Licence file. Leave BLANK and setup.sh self-issues a 2-client evaluation
+# licence for you, bound to the signing key it generates on this host. The
+# private key never leaves the host and you do not have to ask anyone.
#
# Set it to your licence path once you buy. Paid client caps come from the
# licence, never from this file.
+#
+# PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE=1 skips the request on an air-gapped
+# host. The portal and client isolation still work, but client workspaces will
+# not carry MSP capabilities until a licence is installed.
CP_PROVIDER_MSP_LICENSE_FILE=
# Entitlement lease signing key. setup.sh generates this; the private key
# never leaves this host. Your provider MSP license must bind the derived
diff --git a/deploy/provider-msp/setup.sh b/deploy/provider-msp/setup.sh
index 0c13462204..7e0546227d 100755
--- a/deploy/provider-msp/setup.sh
+++ b/deploy/provider-msp/setup.sh
@@ -18,6 +18,8 @@ PULSE_PROVIDER_MSP_SKIP_PULL="${PULSE_PROVIDER_MSP_SKIP_PULL:-0}"
PULSE_PROVIDER_MSP_RUN_INSTALL_PROOF="${PULSE_PROVIDER_MSP_RUN_INSTALL_PROOF:-auto}"
PULSE_PROVIDER_MSP_ACCOUNT_NAME="${PULSE_PROVIDER_MSP_ACCOUNT_NAME:-}"
PULSE_PROVIDER_MSP_OWNER_EMAIL="${PULSE_PROVIDER_MSP_OWNER_EMAIL:-}"
+PULSE_PROVIDER_MSP_LICENSE_URL="${PULSE_PROVIDER_MSP_LICENSE_URL:-https://license.pulserelay.pro}"
+PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE="${PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE:-0}"
log() {
echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] $*"
@@ -334,6 +336,90 @@ Set ${key} in ${env_path} by hand, or check this host can reach the registry."
done
}
+# ensure_eval_license self-issues a capped evaluation license when the operator
+# has not supplied one.
+#
+# An unlicensed control plane starts, but release-build client runtimes only
+# trust entitlement leases chained to a Pulse-signed license, so its client
+# workspaces would run without the capabilities being evaluated. Requesting one
+# by email put a human round-trip in front of the first screen; this asks the
+# license server directly with the public half of the key generated above.
+#
+# The private key never leaves this host. Failure is a warning, not a stop: the
+# portal, provisioning and client isolation all work regardless, and an
+# air-gapped operator can skip it outright.
+ensure_eval_license() {
+ local env_path="${PULSE_PROVIDER_MSP_INSTALL_DIR}/.env"
+ [[ -f "${env_path}" ]] || die "missing ${env_path}"
+
+ if [[ -n "$(env_value CP_PROVIDER_MSP_LICENSE_FILE "${env_path}")" ]]; then
+ return 0
+ fi
+
+ local eval_path="${PULSE_PROVIDER_MSP_INSTALL_DIR}/provider-msp-eval-license.jwt"
+ if [[ -s "${eval_path}" ]]; then
+ log "reusing existing evaluation license ${eval_path}"
+ set_env_value CP_PROVIDER_MSP_LICENSE_FILE "./provider-msp-eval-license.jwt" "${env_path}"
+ return 0
+ fi
+
+ if truthy "${PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE}"; then
+ log "PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE set: staying unlicensed"
+ log " the portal and client isolation work, but client workspaces will not"
+ log " carry MSP capabilities until a license is installed"
+ return 0
+ fi
+
+ have curl || die "curl is required to request an evaluation license"
+
+ # Tolerate failure rather than abort: ensure_generated_secrets has already
+ # created the key, so this only trips on something unexpected, and an
+ # evaluation licence is never worth failing an otherwise good install.
+ #
+ # Tested with `if !` rather than `|| true` inside the substitution: the
+ # derive helper calls die, and `exit` in a subshell terminates it outright
+ # instead of yielding a status `||` could catch, so setup.sh would abort.
+ local public_key=""
+ if ! public_key="$(derive_lease_signing_public_key 2>/dev/null)"; then
+ public_key=""
+ fi
+ if [[ -z "${public_key}" ]]; then
+ log "warning: could not derive the lease signing public key; staying unlicensed"
+ return 0
+ fi
+
+ log "requesting a 2-client evaluation license from ${PULSE_PROVIDER_MSP_LICENSE_URL}"
+ local body response token
+ body="$(printf '{"entitlement_signing_public_key":"%s"}' "${public_key}")"
+ response="$(curl -fsS --max-time 20 \
+ -H 'Content-Type: application/json' \
+ -d "${body}" \
+ "${PULSE_PROVIDER_MSP_LICENSE_URL%/}/v1/provider-msp/eval-license" 2>/dev/null || true)"
+
+ if [[ -z "${response}" ]]; then
+ log "warning: could not reach the license server"
+ log " continuing unlicensed. The portal and client isolation work, but client"
+ log " workspaces will not carry MSP capabilities. Re-run setup.sh to retry,"
+ log " or set CP_PROVIDER_MSP_LICENSE_FILE if you already hold a license."
+ return 0
+ fi
+
+ token="$(printf '%s' "${response}" | jq -r '.license // empty' 2>/dev/null || true)"
+ if [[ -z "${token}" ]]; then
+ log "warning: license server response contained no license; continuing unlicensed"
+ return 0
+ fi
+
+ printf '%s' "${token}" >"${eval_path}"
+ chmod 0600 "${eval_path}"
+ set_env_value CP_PROVIDER_MSP_LICENSE_FILE "./provider-msp-eval-license.jwt" "${env_path}"
+
+ local expires
+ expires="$(printf '%s' "${response}" | jq -r '.expires_at // empty' 2>/dev/null || true)"
+ log "evaluation license installed: 2 client workspaces${expires:+, expires ${expires}}"
+ log " buy a plan and set CP_PROVIDER_MSP_LICENSE_FILE to lift the cap"
+}
+
ensure_generated_secrets() {
local env_path="${PULSE_PROVIDER_MSP_INSTALL_DIR}/.env"
[[ -f "${env_path}" ]] || die "missing ${env_path}"
@@ -667,6 +753,8 @@ main() {
install_deploy_bundle
ensure_env_file
ensure_generated_secrets
+ # After the signing key exists, since the license binds its public half.
+ ensure_eval_license
# After install_docker_ce, which provides the buildx used to read the
# registry, and before validation, which requires the pins to be set.
ensure_image_pins
diff --git a/docs/MSP.md b/docs/MSP.md
index 2038ff4104..98023c2a79 100644
--- a/docs/MSP.md
+++ b/docs/MSP.md
@@ -263,11 +263,19 @@ contact support to get set up or to join the MSP design-partner program.
### Evaluating without a licence
-Leave `CP_PROVIDER_MSP_LICENSE_FILE` blank and the control plane runs on
-`msp_eval`: the same product, capped at 2 client workspaces. Nothing to
-request and nobody to wait for. Stand the stack up, onboard two real clients,
-and confirm the isolation boundary holds on your own infrastructure before
-you spend anything.
+Leave `CP_PROVIDER_MSP_LICENSE_FILE` blank and `setup.sh` self-issues a
+2-client evaluation licence for you. It sends only the public half of the
+signing key it generated on your host, exactly as the paid path does, and the
+private key never leaves the machine. Nothing to request and nobody to wait
+for. Stand the stack up, onboard two real clients, and confirm the isolation
+boundary holds on your own infrastructure before you spend anything.
+
+The evaluation licence lasts 60 days and re-running `setup.sh` reuses the one
+already on disk. On an air-gapped host set
+`PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE=1`; the portal, provisioning and client
+isolation all still work, but client workspaces will not carry MSP capabilities
+until a licence is installed, because release-build client runtimes only trust
+entitlement leases chained to a Pulse-signed licence.
`setup.sh` also resolves the four image pins from their published tags when
you leave them blank, writing the resolved digests back into `.env`. The
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index ef38f8d6b7..516fdd1950 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -3253,9 +3253,18 @@ authenticated bootstrap and does not add a commercial-posture, checkout, or
organization probe.
An MSP control plane without a licence file runs on the `msp_eval` plan
-version, not on the cheapest paid tier. `msp_eval` carries the same MSP
-capabilities and a workspace limit of two, and it is neither purchasable nor
-part of the published pricing ladder. The environment fallback previously
+version, not on the cheapest paid tier. `msp_eval` has a workspace limit of two
+and is neither purchasable nor part of the published pricing ladder.
+
+An earlier revision of this paragraph claimed `msp_eval` "carries the same MSP
+capabilities". That was wrong and is corrected here. A plan version selects the
+workspace cap; it does not by itself entitle a client workspace. Release-build
+client runtimes only trust entitlement leases chained to a Pulse-signed
+provider licence, so a control plane holding no licence at all issues leases
+those runtimes reject, and its client workspaces fall back to Community
+behaviour however the plan version reads. Evaluation therefore depends on the
+self-issued licence described in `deployment-installability`, not on the plan
+default alone. The environment fallback previously
defaulted to `msp_starter`, which granted the full five-workspace Starter
allowance to any unlicensed deployment and left no commercial boundary between
evaluating and buying. `pkg/licensing.PlanVersionMSPEval` is the only spelling
@@ -3268,3 +3277,15 @@ The eval limit must stay strictly below every paid MSP tier. Paid workspace
caps continue to come only from the signed licence file, never from the
environment fallback, and `ProviderMSPPlanSourceEnvFallback` remains the
recorded plan source whenever no licence is present.
+
+
+The capability ceiling for an entitlement lease follows HOSTING, not licensing.
+`entitlements.Service.SetProviderHosted` bounds a provider-operated control
+plane to `ProviderChainedLeaseCapabilities()` whether or not it holds a licence,
+because a provider deployment cannot serve relay, mobile, or push in any
+licensing state. Selecting that ceiling from licence presence, as an earlier
+revision did through `providerChained`, let an unlicensed provider control plane
+fall through to the Pulse-hosted branch and mint leases claiming those three
+Pulse-service-backed capabilities. `providerChained` retains its narrower
+meaning: a Pulse-signed licence is available to embed so release builds can
+verify the lease.
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 67d2e95b94..5c1c110f1b 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -2910,3 +2910,18 @@ unfillable `@sha256:<pin>` placeholders, and a blank
`CP_PROVIDER_MSP_LICENSE_FILE`, so the default install path requires no
credentials and no correspondence. All four images are publicly readable, so
digest resolution must not assume registry authentication.
+
+When no licence path is set, `setup.sh` self-issues a capped evaluation licence
+from the Pulse licence server (`POST /v1/provider-msp/eval-license`) bound to
+the lease signing public key derived from the locally generated private key,
+which never leaves the host. Without this the evaluation is hollow: an
+unlicensed control plane starts, but release-build client runtimes reject its
+unchained entitlement leases and the client workspaces run without the
+capabilities being evaluated.
+
+Self-issue must degrade rather than block. A missing signing key, an
+unreachable licence server, or a response carrying no licence leaves the
+install unlicensed with an explicit warning, and `PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE`
+skips the request outright for air-gapped hosts. An existing evaluation licence
+on disk is reused rather than re-requested. The install must never abort
+because an evaluation licence could not be obtained.
diff --git a/internal/cloudcp/entitlements/service.go b/internal/cloudcp/entitlements/service.go
index bcd838b227..dee01f697b 100644
--- a/internal/cloudcp/entitlements/service.go
+++ b/internal/cloudcp/entitlements/service.go
@@ -28,7 +28,13 @@ type Service struct {
baseURL string
trialActivationPrivateKey string
providerLicense string
- now func() time.Time
+ // providerHosted records that this control plane runs on a provider's own
+ // infrastructure, independently of whether a licence happens to be
+ // present. The capability ceiling follows hosting, not licensing: a
+ // provider deployment cannot back relay, mobile or push whether it is
+ // licensed or not, so it must never mint leases claiming them.
+ providerHosted bool
+ now func() time.Time
}
type RefreshResult struct {
@@ -62,6 +68,21 @@ func (s *Service) SetProviderLicense(licenseKey string) {
s.providerLicense = strings.TrimSpace(licenseKey)
}
+// SetProviderHosted marks this control plane as provider-operated, which bounds
+// the capabilities its leases may claim.
+//
+// This is separate from SetProviderLicense on purpose. Deriving the ceiling
+// from licence presence meant an unlicensed provider deployment fell through to
+// the Pulse-hosted branch and minted leases claiming relay, mobile and push,
+// which a provider deployment cannot serve and which previously produced
+// repeating relay registration failures in client runtimes.
+func (s *Service) SetProviderHosted(providerHosted bool) {
+ if s == nil {
+ return
+ }
+ s.providerHosted = providerHosted
+}
+
func (s *Service) IssueTenantBillingState(tenant *registry.Tenant, requestedSubState pkglicensing.SubscriptionState, requestedPlanVersion, stripeCustomerID, stripeSubscriptionID, stripePriceID string) (*pkglicensing.BillingState, error) {
if s == nil || s.registry == nil {
return nil, fmt.Errorf("hosted entitlement service is unavailable")
@@ -154,7 +175,12 @@ type tenantLeaseContext struct {
stripeAccount *registry.StripeAccount
subscriptionState pkglicensing.SubscriptionState
planVersion string
- providerChained bool
+ // providerChained records that a Pulse-signed provider licence is
+ // available to embed, which is what lets release builds verify the lease.
+ providerChained bool
+ // providerHosted records that this control plane runs on the provider's
+ // own infrastructure, which is what bounds the capability ceiling.
+ providerHosted bool
}
type trialEntitlementContext struct {
@@ -248,6 +274,7 @@ func (s *Service) resolveTenantLeaseContext(tenant *registry.Tenant, requestedSu
subscriptionState: requestedSubState,
planVersion: pkglicensing.CanonicalizePlanVersion(requestedPlanVersion),
providerChained: strings.TrimSpace(s.providerLicense) != "",
+ providerHosted: s.providerHosted,
}
if ctx.planVersion == "" {
ctx.planVersion = pkglicensing.CanonicalizePlanVersion(tenant.PlanVersion)
@@ -369,7 +396,7 @@ func buildPaidEntitlementLeaseClaims(ctx *tenantLeaseContext, instanceHost strin
var capabilities []string
if pkglicensing.ShouldGrantPaidCapabilities(ctx.subscriptionState) {
switch {
- case isMSPPlanVersion(ctx.planVersion) && ctx.providerChained:
+ case isMSPPlanVersion(ctx.planVersion) && ctx.providerHosted:
// Provider-hosted MSP client workspaces lease the chained
// ceiling: MSP tier plus white_label (branded per-client
// reports), minus Pulse-service-backed capabilities (relay,
@@ -460,3 +487,10 @@ func baseDomainFromURL(baseURL string) string {
}
return baseURL
}
+
+// ProviderHosted reports whether this service bounds leases to the
+// provider-operated ceiling. Exposed so the control plane wiring can be
+// verified rather than assumed.
+func (s *Service) ProviderHosted() bool {
+ return s != nil && s.providerHosted
+}
diff --git a/internal/cloudcp/entitlements/service_test.go b/internal/cloudcp/entitlements/service_test.go
index a4e6cd2e9d..e6b6fc79aa 100644
--- a/internal/cloudcp/entitlements/service_test.go
+++ b/internal/cloudcp/entitlements/service_test.go
@@ -563,3 +563,67 @@ func TestIssueTenantBillingStateCloudPlanOmitsProviderLicenseWhenUnset(t *testin
t.Fatalf("cloud lease should not carry white_label, got %v", claims.Capabilities)
}
}
+
+// A provider deployment cannot serve relay, mobile or push whether or not it
+// holds a licence, so it must never mint leases claiming them. The ceiling used
+// to be selected by licence presence, which meant an UNLICENSED provider
+// control plane fell through to the Pulse-hosted branch and claimed exactly
+// those three, producing repeating relay registration failures in the client
+// runtime. Selecting on hosting closes that.
+func TestProviderHostedLeaseNeverClaimsPulseServiceCapabilitiesWhenUnlicensed(t *testing.T) {
+ svc, pub, reg := newTestService(t)
+ svc.SetProviderHosted(true)
+ // Deliberately no SetProviderLicense: this is the unlicensed provider.
+
+ accountID, err := registry.GenerateAccountID()
+ if err != nil {
+ t.Fatalf("GenerateAccountID: %v", err)
+ }
+ if err := reg.CreateAccount(&registry.Account{
+ ID: accountID,
+ Kind: registry.AccountKindMSP,
+ DisplayName: "Unlicensed MSP",
+ }); err != nil {
+ t.Fatalf("CreateAccount: %v", err)
+ }
+
+ tenant := &registry.Tenant{
+ ID: "t-EVALCLIENT1",
+ AccountID: accountID,
+ Email: "[email protected]",
+ State: registry.TenantStateActive,
+ PlanVersion: pkglicensing.PlanVersionMSPEval,
+ }
+ if err := reg.Create(tenant); err != nil {
+ t.Fatalf("Create: %v", err)
+ }
+
+ now := time.Unix(1710000000, 0).UTC()
+ svc.SetNow(func() time.Time { return now })
+
+ state, err := svc.IssueTenantBillingState(tenant, pkglicensing.SubStateActive, pkglicensing.PlanVersionMSPEval, "", "", "")
+ if err != nil {
+ t.Fatalf("IssueTenantBillingState: %v", err)
+ }
+ claims, err := pkglicensing.VerifyEntitlementLeaseToken(state.EntitlementJWT, pub, "t-EVALCLIENT1.cloud.example.com", now)
+ if err != nil {
+ t.Fatalf("VerifyEntitlementLeaseToken: %v", err)
+ }
+
+ capabilities := map[string]bool{}
+ for _, capability := range claims.Capabilities {
+ capabilities[capability] = true
+ }
+ for _, forbidden := range []string{
+ pkglicensing.FeatureRelay,
+ pkglicensing.FeatureMobileApp,
+ pkglicensing.FeaturePushNotifications,
+ } {
+ if capabilities[forbidden] {
+ t.Fatalf("provider-hosted lease must not claim Pulse-service capability %q: %v", forbidden, claims.Capabilities)
+ }
+ }
+ if !capabilities[pkglicensing.FeatureMultiTenant] {
+ t.Fatalf("provider-hosted eval lease should still carry multi_tenant: %v", claims.Capabilities)
+ }
+}
diff --git a/internal/cloudcp/routes.go b/internal/cloudcp/routes.go
index e74328795f..d11925a7e7 100644
--- a/internal/cloudcp/routes.go
+++ b/internal/cloudcp/routes.go
@@ -137,10 +137,7 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {
// Stripe webhook (signature-authenticated)
hostedEntitlements := deps.HostedEntitlements
if hostedEntitlements == nil {
- hostedEntitlements = entitlements.NewService(deps.Registry, deps.Config.BaseURL, deps.Config.TrialActivationPrivateKey)
- if deps.Config.IsProviderHostedMSP() {
- hostedEntitlements.SetProviderLicense(deps.Config.ProviderMSPLicenseKey)
- }
+ hostedEntitlements = NewHostedEntitlementsService(deps.Config, deps.Registry)
}
provisioner := deps.Provisioner
if provisioner == nil {
@@ -311,3 +308,20 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {
portalPageLimiter := NewCPRateLimiter(60, time.Minute)
mux.Handle(portal.PortalPagePath, portalPageLimiter.Middleware(http.HandlerFunc(portal.HandlePortalPageWithEnvironment(deps.MagicLinks, deps.Registry, portalCommercialLookup, controlPlaneFaviconHref(), portalEnv, portalSetupFacts))))
}
+
+// NewHostedEntitlementsService builds the entitlement service with the
+// provider posture applied.
+//
+// Hosting and licensing are set separately and deliberately: hosting bounds
+// what capabilities a lease may claim, while the licence only decides whether
+// release-build client runtimes can verify it. Wiring one without the other is
+// how an unlicensed provider control plane came to mint leases claiming relay,
+// mobile and push.
+func NewHostedEntitlementsService(cfg *CPConfig, reg *registry.TenantRegistry) *entitlements.Service {
+ svc := entitlements.NewService(reg, cfg.BaseURL, cfg.TrialActivationPrivateKey)
+ if cfg.IsProviderHostedMSP() {
+ svc.SetProviderHosted(true)
+ svc.SetProviderLicense(cfg.ProviderMSPLicenseKey)
+ }
+ return svc
+}
diff --git a/internal/cloudcp/routes_test.go b/internal/cloudcp/routes_test.go
index 312a75c4bb..30bb63e099 100644
--- a/internal/cloudcp/routes_test.go
+++ b/internal/cloudcp/routes_test.go
@@ -474,3 +474,46 @@ func TestRegisterRoutes_MSPControlPlaneDisablesPulseHostedBillingRoutes(t *testi
})
}
}
+
+// The capability ceiling for provider deployments is set at wiring time, and
+// getting it wrong is silent: leases still issue, they just claim capabilities
+// a provider deployment cannot serve. Both wiring sites go through
+// NewHostedEntitlementsService so they cannot drift apart again.
+func TestNewHostedEntitlementsService_MarksProviderHosting(t *testing.T) {
+ dir := t.TempDir()
+ reg, err := registry.NewTenantRegistry(dir)
+ if err != nil {
+ t.Fatalf("NewTenantRegistry: %v", err)
+ }
+ t.Cleanup(func() { _ = reg.Close() })
+
+ providerHosted := NewHostedEntitlementsService(&CPConfig{
+ DataDir: dir,
+ BaseURL: "https://msp.example.com",
+ ControlPlaneMode: ControlPlaneModeProviderHostedMSP,
+ }, reg)
+ if !providerHosted.ProviderHosted() {
+ t.Fatal("provider-hosted MSP control plane must bound leases to the provider ceiling")
+ }
+
+ // Unlicensed is still provider-hosted. Deriving the ceiling from licence
+ // presence is the defect this guards.
+ unlicensed := NewHostedEntitlementsService(&CPConfig{
+ DataDir: dir,
+ BaseURL: "https://msp.example.com",
+ ControlPlaneMode: ControlPlaneModeProviderHostedMSP,
+ ProviderMSPLicenseKey: "",
+ }, reg)
+ if !unlicensed.ProviderHosted() {
+ t.Fatal("an unlicensed provider control plane is still provider-hosted")
+ }
+
+ pulseHosted := NewHostedEntitlementsService(&CPConfig{
+ DataDir: dir,
+ BaseURL: "https://cloud.example.com",
+ ControlPlaneMode: ControlPlaneModePulseHosted,
+ }, reg)
+ if pulseHosted.ProviderHosted() {
+ t.Fatal("Pulse-hosted control plane must not be marked provider-hosted")
+ }
+}
diff --git a/internal/cloudcp/server.go b/internal/cloudcp/server.go
index bce70a1533..28d3835a42 100644
--- a/internal/cloudcp/server.go
+++ b/internal/cloudcp/server.go
@@ -13,7 +13,6 @@ import (
cpauth "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/auth"
cpDocker "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/docker"
"github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/email"
- "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/entitlements"
"github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/registry"
cpstripe "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/stripe"
"github.com/rcourtman/pulse-go-rewrite/internal/logging"
@@ -113,10 +112,7 @@ func Run(ctx context.Context, version string) error {
// Build HTTP routes
mux := http.NewServeMux()
- hostedEntitlements := entitlements.NewService(reg, cfg.BaseURL, cfg.TrialActivationPrivateKey)
- if cfg.IsProviderHostedMSP() {
- hostedEntitlements.SetProviderLicense(cfg.ProviderMSPLicenseKey)
- }
+ hostedEntitlements := NewHostedEntitlementsService(cfg, reg)
provisioner := cpstripe.NewProvisioner(
reg,
cfg.TenantsDir(),
diff --git a/scripts/installtests/provider_msp_deploy_test.go b/scripts/installtests/provider_msp_deploy_test.go
index c4eb4efba0..931c01baee 100644
--- a/scripts/installtests/provider_msp_deploy_test.go
+++ b/scripts/installtests/provider_msp_deploy_test.go
@@ -352,8 +352,25 @@ func TestProviderMSPSetupScriptSupportsUnlicensedEvaluation(t *testing.T) {
"default_image_ref",
"resolve_image_digest",
"buildx imagetools inspect",
+ // Self-issue, and the three ways it must degrade instead of blocking.
+ "ensure_eval_license",
+ "/v1/provider-msp/eval-license",
+ "PULSE_PROVIDER_MSP_SKIP_EVAL_LICENSE",
+ "reusing existing evaluation license",
+ "could not reach the license server",
)
+ // The install must never abort because an evaluation licence could not be
+ // obtained. `|| true` inside the substitution does not achieve that: the
+ // derive helper calls die, and exit in a subshell is not a catchable
+ // status, so setup.sh would abort under set -e.
+ if strings.Contains(script, "$(derive_lease_signing_public_key 2>/dev/null || true)") {
+ t.Fatal("eval license key derivation uses `|| true` inside a command substitution, which cannot catch die/exit under set -e")
+ }
+ if !strings.Contains(script, "if ! public_key=\"$(derive_lease_signing_public_key 2>/dev/null)\"") {
+ t.Fatal("eval license key derivation must be guarded so a failure degrades to unlicensed rather than aborting setup")
+ }
+
// A blank licence path means evaluation. If it returns to the
// must-be-non-empty list, setup.sh refuses to start unlicensed again.
if strings.Contains(script, "CP_TRUSTED_PROXY_CIDRS CP_PROVIDER_MSP_LICENSE_FILE") {