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.

Make the provider MSP portal honest and self-sufficient without an email provider

rcourtman0e40ec07cbd6
diff --git a/cmd/pulse-control-plane/provider_msp.go b/cmd/pulse-control-plane/provider_msp.go
index 59359a80ba..a3ae00859b 100644
--- a/cmd/pulse-control-plane/provider_msp.go
+++ b/cmd/pulse-control-plane/provider_msp.go
@@ -13,6 +13,7 @@ func newProviderMSPCmd() *cobra.Command {
Short: "Operate a provider-hosted MSP control plane",
}
cmd.AddCommand(newProviderMSPBootstrapCmd())
+ cmd.AddCommand(newProviderMSPPortalLinkCmd())
cmd.AddCommand(newProviderMSPBackupCmd())
cmd.AddCommand(newProviderMSPInstallProofCmd())
cmd.AddCommand(newProviderMSPPreflightCmd())
@@ -58,6 +59,50 @@ func newProviderMSPBootstrapCmd() *cobra.Command {
return cmd
}
+func newProviderMSPPortalLinkCmd() *cobra.Command {
+ var email string
+
+ cmd := &cobra.Command{
+ Use: "portal-link",
+ Short: "Print a one-time portal sign-in link for an account member or pending invitee",
+ Long: `Print a one-time portal sign-in link for an account member or pending invitee.
+
+Use this when the control plane has no email provider configured, so the
+portal cannot send sign-in links or invitation emails itself. The email
+address must already be an account member or hold a pending invitation
+created from the portal Access tab.`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ cfg, err := cloudcp.LoadConfig()
+ if err != nil {
+ return fmt.Errorf("load control plane config: %w", err)
+ }
+ result, err := cloudcp.ProviderMSPPortalLink(cmd.Context(), cfg, cloudcp.ProviderMSPPortalLinkOptions{
+ Email: email,
+ })
+ if err != nil {
+ return err
+ }
+ printProviderMSPPortalLinkResult(result)
+ return nil
+ },
+ }
+ cmd.Flags().StringVar(&email, "email", "", "Email address of the account member or pending invitee")
+ _ = cmd.MarkFlagRequired("email")
+ return cmd
+}
+
+func printProviderMSPPortalLinkResult(result *cloudcp.ProviderMSPPortalLinkResult) {
+ if result == nil {
+ fmt.Println("provider_msp_portal_link_ok=false")
+ return
+ }
+ fmt.Println("provider_msp_portal_link_ok=true")
+ fmt.Printf("email=%s\n", result.Email)
+ fmt.Printf("access_state=%s\n", result.AccessState)
+ fmt.Printf("role=%s\n", result.Role)
+ fmt.Printf("portal_magic_link=%s\n", result.MagicLinkURL)
+}
+
func printProviderMSPBootstrapResult(result *cloudcp.ProviderMSPBootstrapResult) {
if result == nil {
fmt.Println("provider_msp_bootstrap_ok=false")
diff --git a/deploy/provider-msp/.env.example b/deploy/provider-msp/.env.example
index 5fb5c1cffa..96d8630526 100644
--- a/deploy/provider-msp/.env.example
+++ b/deploy/provider-msp/.env.example
@@ -28,7 +28,7 @@ CP_TRUSTED_PROXY_CIDRS=172.30.0.0/24
CP_PROVIDER_MSP_LICENSE_FILE=./provider-msp-license.jwt
# Entitlement lease signing key. setup.sh generates this; the private key
# never leaves this host. Your provider MSP license must bind the derived
-# PUBLIC key (entitlement_signing_public_key) — print it with
+# PUBLIC key (entitlement_signing_public_key); print it with
# `./setup.sh --print-lease-signing-public-key` and include it in your
# license request. The control plane refuses to start if license and key
# do not match.
@@ -43,7 +43,14 @@ CP_STORAGE_MAX_DOCKER_BUILD_CACHE=2GiB
CP_PROOF_TENANT_MAX_AGE=24h
CP_PROOF_TENANT_MATCHERS=proof,canary,rehearsal,msp_prod,ownerseed,owner_seed
-# Email is optional for bootstrap because the CLI can print the first portal link.
+# Email is optional. Without RESEND_API_KEY the portal cannot send sign-in
+# links or invitation emails; instead, print one-time links on this host:
+# docker compose run --rm control-plane provider-msp bootstrap \
+# --account-name "Example MSP" --owner-email [email protected] # owner link
+# docker compose run --rm control-plane provider-msp portal-link \
+# --email [email protected] # teammate link
+# The portal sign-in page shows the same instructions in this state.
+# Portal sessions last 7 days (CP_SESSION_TTL to change).
# Set CP_REQUIRE_EMAIL_PROVIDER=true once transactional email is configured.
CP_REQUIRE_EMAIL_PROVIDER=false
RESEND_API_KEY=
diff --git a/deploy/provider-msp/setup.sh b/deploy/provider-msp/setup.sh
index b5d1b226c6..4af39b37ec 100755
--- a/deploy/provider-msp/setup.sh
+++ b/deploy/provider-msp/setup.sh
@@ -556,12 +556,22 @@ Paths:
- Data dir: ${data_dir}
- Network: ${network}
-Proof:
+Next step: create your operator account (prints your portal sign-in link):
cd ${PULSE_PROVIDER_MSP_INSTALL_DIR}
+ docker compose run --rm control-plane provider-msp bootstrap \\
+ --account-name "Example MSP" --owner-email [email protected]
+
+Prove the platform before the first real client:
./run-install-proof.sh --account-name "Example MSP" --owner-email [email protected]
-Portal:
- https://${domain}/
+Portal (after bootstrap):
+ https://${domain}/portal
+
+Day 2: portal sessions last 7 days. Re-run the bootstrap command above any
+time to print a fresh owner sign-in link, or use
+ docker compose run --rm control-plane provider-msp portal-link --email [email protected]
+for any invited teammate. Set RESEND_API_KEY in .env to enable emailed
+sign-in links instead.
Lease signing public key (your provider MSP license must bind this key;
re-print any time with ./setup.sh --print-lease-signing-public-key):
diff --git a/docs/MSP.md b/docs/MSP.md
index 6745a63265..d3d1063fed 100644
--- a/docs/MSP.md
+++ b/docs/MSP.md
@@ -37,6 +37,31 @@ pulse-control-plane provider-msp recover # restore workspaces from backup or d
pulse-control-plane provider-msp preflight # pre-install environment checks
```
+### Portal sign-in and sessions
+
+The management portal signs you in with one-time links, not passwords. With
+no email provider configured (the bundle default), the portal cannot send
+those links itself; the sign-in page says so and points at the host command
+that prints one:
+
+```bash
+# Owner sign-in link (also safe to re-run any time; it never duplicates the account)
+docker compose run --rm control-plane provider-msp bootstrap \
+ --account-name "Your MSP" --owner-email [email protected]
+
+# Sign-in link for an invited teammate
+docker compose run --rm control-plane provider-msp portal-link --email [email protected]
+```
+
+Teammates are invited from the portal Access tab; without an email provider
+the invitation email is not sent, so print their first sign-in link with
+`portal-link` after inviting them. To let the portal send sign-in links and
+invitations itself, set `RESEND_API_KEY` (plus `PULSE_EMAIL_FROM` and
+`PULSE_EMAIL_REPLY_TO`) in `.env` and restart the control plane.
+
+Portal sessions last 7 days on provider-hosted control planes; override with
+`CP_SESSION_TTL` (Go duration, e.g. `12h`, `168h`).
+
Each client runtime is a normal Pulse instance, so it connects to that
client's infrastructure with the standard methods: agents push over HTTPS for
hosts, and Proxmox/PBS polling reaches across networks through your existing
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 40b7112faf..c7b8150fc6 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -2464,6 +2464,15 @@ a new API state machine, queue contract, or verification-accounting field.
account/billing shell must remain understandable from the primary header,
section title, and factual body content alone instead of depending on a
second context-chip strip to restate the same scope.
+ The bootstrap payload is also the portal's honesty contract about the
+ runtime it runs on: `internal/cloudcp/portal/bootstrap.go` carries
+ `email_sign_in_available` and `provider_hosted_mode`, both the HTML page
+ path and `/api/portal/bootstrap` must populate them from the control-plane
+ environment (`PortalEnvironment`), and the signed-out shell must render
+ the operator sign-in instructions instead of an email-send form whenever
+ `email_sign_in_available` is false. Older payloads without the flags must
+ default to the email form (available) so Pulse-hosted cloud behavior is
+ unchanged.
33. Keep storage wire metadata lossless across shared API payload types.
`frontend-modern/src/types/api.ts` must continue to expose provider-backed
storage metadata such as Proxmox `pool` and `zfsPool` fields when the
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index b41503f9e8..9e207ad65b 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -752,6 +752,26 @@ or other self-hosted uncapped continuity plans.
pairing for handoff, push notifications, and 14-day history; it must not imply that the
native mobile app is a full monitoring dashboard until that product surface
exists.
+ Portal sessions and sign-in delivery are part of this boundary. Session
+ lifetime is configured through `CP_SESSION_TTL` and flows through the
+ control-plane auth service (`SetSessionTTL`/`SessionTTLOrDefault`); portal
+ session issuance sites must use the service value rather than the package
+ constant so provider-hosted MSP control planes can default to 7 days while
+ Pulse-hosted control planes stay at 12 hours.
+ The portal bootstrap payload carries `email_sign_in_available` (false when
+ no transactional email provider is configured) and `provider_hosted_mode`
+ (true for `provider_hosted_msp` control planes). The signed-out portal must
+ not promise an emailed sign-in link when `email_sign_in_available` is
+ false; it must instead present the operator host command
+ (`provider-msp portal-link --email ...`), and the Access invite panel must
+ disclose that invitation emails are not sent in that state. The
+ `provider-msp portal-link` CLI mints one-time portal links only for an
+ existing account member or a pending invitee, never for arbitrary
+ addresses.
+ Workspace-limit rejections from tenant creation must be JSON payloads
+ (`error=workspace_limit_reached` with `message`, `current`, and `limit`)
+ so the portal can present the licence reason instead of a generic failure;
+ the portal API client must not drop non-JSON error bodies.
7. Add or change Stripe provisioning plan resolution through
`internal/cloudcp/stripe/provisioner.go`, `internal/cloudcp/stripe/webhook.go`,
and `pkg/licensing/stripe_subscription.go`. Checkout-session provisioning
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 9cc4e6c706..82f6d3eac7 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -233,6 +233,17 @@ TLS floor in the dynamic config.
Docker subnet, create the storage-admission marker directories, and install a
host-level `DOCKER-USER` rule blocking `169.254.169.254` from tenant
containers when iptables is available.
+ The setup summary must leave the operator on a working next step, not a
+ dead end: it must print the `provider-msp bootstrap` command that creates
+ the operator account and portal sign-in link, and the day-2 sign-in
+ guidance (re-running `bootstrap` for a fresh owner link and
+ `provider-msp portal-link --email` for invited teammates), because the
+ bundle default ships without a transactional email provider and the portal
+ cannot send sign-in links in that state. `.env.example` must document the
+ same commands next to `RESEND_API_KEY` so the runbook and the portal
+ sign-in page agree. `provider-msp portal-link` is part of the packaged
+ day-2 surface and mints links only for existing account members or pending
+ invitees.
Provider-hosted MSP installability must also pass provider-default report
branding through the packaged tenant environment rather than requiring
report-specific operator provisioning. The deployable control-plane config
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index e460cdc698..b3cd47c3f2 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -296,6 +296,12 @@ the `white_label` branding entitlement.
and purchase-return state exactly.
6. Change operator-facing telemetry/adoption reporting through `scripts/telemetry_adoption_report.py` together with the privacy disclosure whenever release-identity interpretation changes.
7. Change data-at-rest encryption-key or control-plane magic-link HMAC key and storage-root hardening semantics through `internal/crypto/crypto.go`, `internal/cloudcp/auth/magiclink.go`, `internal/cloudcp/auth/magiclink_store.go`, and `internal/securityutil/secure_storage_dir.go` together so writable-but-not-owned runtime storage mounts stay supported without weakening file-level secrecy.
+ Control-plane portal session lifetime rides on that same service: the auth
+ service session TTL is configurable (`CP_SESSION_TTL`, longer
+ provider-hosted MSP default) but must stay bounded; non-positive overrides
+ are ignored so a misconfigured caller cannot issue never-expiring or
+ instantly-expired sessions, and session issuance sites must read the
+ service TTL instead of the package constant.
8. Change auth-env password normalization, hosted commercial base URL
normalization, or shared TLS fingerprint verification defaults through
`internal/config/config.go`, `internal/config/watcher.go`, and
diff --git a/internal/cloudcp/account/tenant_handlers.go b/internal/cloudcp/account/tenant_handlers.go
index e8d1070a74..3d121917b1 100644
--- a/internal/cloudcp/account/tenant_handlers.go
+++ b/internal/cloudcp/account/tenant_handlers.go
@@ -177,7 +177,7 @@ func HandleCreateTenantWithWorkspaceLimitPolicy(reg *registry.TenantRegistry, pr
Int("current_count", limitErr.current).
Int("limit", limitErr.limit).
Msg("Tenant creation blocked by workspace limit")
- http.Error(w, limitErr.message, limitErr.statusCode)
+ writeTenantCreateError(w, limitErr.statusCode, limitErr.reason, limitErr.message, limitErr.current, limitErr.limit)
return
}
if provisionErr != nil {
@@ -190,10 +190,13 @@ func HandleCreateTenantWithWorkspaceLimitPolicy(reg *registry.TenantRegistry, pr
Int("current_count", limitErr.Current).
Int("limit", limitErr.Limit).
Msg("Tenant creation blocked by registry workspace limit")
- http.Error(
+ writeTenantCreateError(
w,
- fmt.Sprintf("workspace limit reached: %d of %d allowed", limitErr.Current, limitErr.Limit),
http.StatusForbidden,
+ "workspace_limit_reached",
+ fmt.Sprintf("workspace limit reached: %d of %d allowed", limitErr.Current, limitErr.Limit),
+ limitErr.Current,
+ limitErr.Limit,
)
return
}
@@ -229,6 +232,27 @@ type workspaceLimitError struct {
limit int
}
+type tenantCreateErrorResponse struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ Current int `json:"current,omitempty"`
+ Limit int `json:"limit,omitempty"`
+}
+
+// writeTenantCreateError responds with a JSON error payload so the portal
+// frontend can show the reason (plain http.Error text bodies were dropped by
+// the portal API client and rendered as a generic failure).
+func writeTenantCreateError(w http.ResponseWriter, statusCode int, reason, message string, current, limit int) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(statusCode)
+ encodeJSON(w, tenantCreateErrorResponse{
+ Error: reason,
+ Message: message,
+ Current: current,
+ Limit: limit,
+ })
+}
+
// enforceWorkspaceLimit checks whether the account is allowed to create
// another workspace. Returns nil if creation is allowed, or a
// workspaceLimitError if blocked.
diff --git a/internal/cloudcp/account/tenant_handlers_test.go b/internal/cloudcp/account/tenant_handlers_test.go
index d6823106de..420e1f8a5c 100644
--- a/internal/cloudcp/account/tenant_handlers_test.go
+++ b/internal/cloudcp/account/tenant_handlers_test.go
@@ -12,6 +12,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
+ "strings"
"sync"
"testing"
@@ -450,7 +451,9 @@ func TestCreateWorkspace_MSPStarterLimitEnforced(t *testing.T) {
t.Fatalf("direct provision error = %v, want workspace limit", err)
}
- // The handler should also return the product-level limit response.
+ // The handler should also return the product-level limit response as a
+ // JSON payload the portal frontend can present (plain-text bodies were
+ // dropped by the portal API client and shown as a generic failure).
body := fmt.Sprintf(`{"display_name":"Client %d"}`, workspaceLimit+1)
req := httptest.NewRequest(http.MethodPost, "/api/accounts/"+accountID+"/tenants", bytes.NewBufferString(body))
rec := doRequest(t, mux, req)
@@ -458,6 +461,27 @@ func TestCreateWorkspace_MSPStarterLimitEnforced(t *testing.T) {
if rec.Code != http.StatusForbidden {
t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusForbidden, rec.Body.String())
}
+ if ct := rec.Header().Get("Content-Type"); !strings.Contains(ct, "application/json") {
+ t.Fatalf("content-type = %q, want application/json (body=%q)", ct, rec.Body.String())
+ }
+ var limitPayload struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ Current int `json:"current"`
+ Limit int `json:"limit"`
+ }
+ if err := json.Unmarshal(rec.Body.Bytes(), &limitPayload); err != nil {
+ t.Fatalf("unmarshal limit payload: %v (body=%q)", err, rec.Body.String())
+ }
+ if limitPayload.Error != "workspace_limit_reached" {
+ t.Fatalf("error = %q, want workspace_limit_reached", limitPayload.Error)
+ }
+ if limitPayload.Message == "" {
+ t.Fatal("limit payload message is empty")
+ }
+ if limitPayload.Current != workspaceLimit || limitPayload.Limit != workspaceLimit {
+ t.Fatalf("current/limit = %d/%d, want %d/%d", limitPayload.Current, limitPayload.Limit, workspaceLimit, workspaceLimit)
+ }
}
func TestCreateWorkspace_MSPStarterLimitCannotRacePastHandlerLock(t *testing.T) {
diff --git a/internal/cloudcp/auth/handlers.go b/internal/cloudcp/auth/handlers.go
index 04e43cd3db..b862d9d5f7 100644
--- a/internal/cloudcp/auth/handlers.go
+++ b/internal/cloudcp/auth/handlers.go
@@ -95,7 +95,7 @@ func HandleMagicLinkVerify(svc *Service, reg *registry.TenantRegistry, tenantsDi
writeError(w, http.StatusInternalServerError, "session_error", "Unable to establish portal session")
return
}
- sessionToken, err := svc.GenerateSessionTokenWithVersion(userID, token.Email, sessionVersion, SessionTTL)
+ sessionToken, err := svc.GenerateSessionTokenWithVersion(userID, token.Email, sessionVersion, svc.SessionTTLOrDefault())
if err != nil {
auditEvent(r, "cp_magic_link_verify", "failure").
Err(err).
@@ -112,7 +112,7 @@ func HandleMagicLinkVerify(svc *Service, reg *registry.TenantRegistry, tenantsDi
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
- MaxAge: int(SessionTTL.Seconds()),
+ MaxAge: int(svc.SessionTTLOrDefault().Seconds()),
})
auditEvent(r, "cp_magic_link_verify", "success").
@@ -197,7 +197,7 @@ func HandleMagicLinkVerify(svc *Service, reg *registry.TenantRegistry, tenantsDi
Str("email", token.Email).
Str("user_id", userID).
Msg("Failed to read user session version")
- } else if sessionToken, err := svc.GenerateSessionTokenWithVersion(userID, token.Email, sessionVersion, SessionTTL); err != nil {
+ } else if sessionToken, err := svc.GenerateSessionTokenWithVersion(userID, token.Email, sessionVersion, svc.SessionTTLOrDefault()); err != nil {
log.Warn().
Err(err).
Str("tenant_id", tenant.ID).
@@ -211,7 +211,7 @@ func HandleMagicLinkVerify(svc *Service, reg *registry.TenantRegistry, tenantsDi
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
- MaxAge: int(SessionTTL.Seconds()),
+ MaxAge: int(svc.SessionTTLOrDefault().Seconds()),
})
}
diff --git a/internal/cloudcp/auth/magiclink.go b/internal/cloudcp/auth/magiclink.go
index 0b645410fb..80994ed432 100644
--- a/internal/cloudcp/auth/magiclink.go
+++ b/internal/cloudcp/auth/magiclink.go
@@ -43,10 +43,11 @@ type Token struct {
// Service manages magic link token generation and validation for the control plane.
// It does NOT import internal/api — it is a standalone reimplementation using its own SQLite store.
type Service struct {
- hmacKey []byte
- store *Store
- ttl time.Duration
- now func() time.Time
+ hmacKey []byte
+ store *Store
+ ttl time.Duration
+ sessionTTL time.Duration
+ now func() time.Time
}
// NewService creates a Service backed by a SQLite store in cpDataDir.
diff --git a/internal/cloudcp/auth/magiclink_test.go b/internal/cloudcp/auth/magiclink_test.go
index 4bc4e5fd49..65dd796321 100644
--- a/internal/cloudcp/auth/magiclink_test.go
+++ b/internal/cloudcp/auth/magiclink_test.go
@@ -311,3 +311,42 @@ func TestNewService_HardensExistingPermissiveDataDir(t *testing.T) {
t.Fatalf("data dir perms = %o, want %o", got, privateDirPerm)
}
}
+
+func TestSessionTTLOrDefault(t *testing.T) {
+ dir := t.TempDir()
+ svc, err := NewService(dir)
+ if err != nil {
+ t.Fatalf("NewService: %v", err)
+ }
+ defer svc.Close()
+
+ if got := svc.SessionTTLOrDefault(); got != SessionTTL {
+ t.Fatalf("SessionTTLOrDefault = %v, want package default %v", got, SessionTTL)
+ }
+
+ svc.SetSessionTTL(7 * 24 * time.Hour)
+ if got := svc.SessionTTLOrDefault(); got != 7*24*time.Hour {
+ t.Fatalf("SessionTTLOrDefault = %v, want 168h after SetSessionTTL", got)
+ }
+
+ // Non-positive overrides are ignored so a misconfigured caller cannot
+ // issue never-expiring or instantly-expired sessions.
+ svc.SetSessionTTL(0)
+ if got := svc.SessionTTLOrDefault(); got != 7*24*time.Hour {
+ t.Fatalf("SessionTTLOrDefault = %v, want 168h after ignored zero override", got)
+ }
+
+ // The issued session token must honor the configured TTL.
+ token, err := svc.GenerateSessionToken("u_test", "[email protected]", svc.SessionTTLOrDefault())
+ if err != nil {
+ t.Fatalf("GenerateSessionToken: %v", err)
+ }
+ claims, err := svc.ValidateSessionToken(token)
+ if err != nil {
+ t.Fatalf("ValidateSessionToken: %v", err)
+ }
+ lifetime := claims.ExpiresAt.Sub(claims.IssuedAt)
+ if lifetime != 7*24*time.Hour {
+ t.Fatalf("session lifetime = %v, want 168h", lifetime)
+ }
+}
diff --git a/internal/cloudcp/auth/session.go b/internal/cloudcp/auth/session.go
index bca8affc95..b37b3f6f49 100644
--- a/internal/cloudcp/auth/session.go
+++ b/internal/cloudcp/auth/session.go
@@ -26,6 +26,24 @@ var (
ErrSessionExpired = errors.New("session token expired")
)
+// SetSessionTTL overrides the session token lifetime issued by this service.
+// Values <= 0 leave the default in place.
+func (s *Service) SetSessionTTL(ttl time.Duration) {
+ if s == nil || ttl <= 0 {
+ return
+ }
+ s.sessionTTL = ttl
+}
+
+// SessionTTLOrDefault returns the configured session lifetime, falling back
+// to the package default.
+func (s *Service) SessionTTLOrDefault() time.Duration {
+ if s == nil || s.sessionTTL <= 0 {
+ return SessionTTL
+ }
+ return s.sessionTTL
+}
+
// SessionClaims are the authenticated claims for a control-plane session.
type SessionClaims struct {
UserID string
diff --git a/internal/cloudcp/config.go b/internal/cloudcp/config.go
index d3e68d4e78..8de6542d34 100644
--- a/internal/cloudcp/config.go
+++ b/internal/cloudcp/config.go
@@ -28,6 +28,12 @@ const (
ProviderMSPPlanSourceLicenseFile = "license_file"
ProviderMSPPlanSourceEnvFallback = "environment_fallback"
maxProviderMSPLicenseFileBytes = 64 * 1024
+
+ // cpauthDefaultSessionTTL mirrors cpauth.SessionTTL for Pulse-hosted
+ // control planes; providerHostedSessionTTL is the default for
+ // provider-operated MSP portals (see CP_SESSION_TTL).
+ cpauthDefaultSessionTTL = 12 * time.Hour
+ providerHostedSessionTTL = 7 * 24 * time.Hour
)
// CPConfig holds all configuration for the control plane.
@@ -89,8 +95,9 @@ type CPConfig struct {
LicenseAdminToken string
TrialActivationPrivateKey string
TrialActivationPublicKey string
+ SessionTTL time.Duration // Portal session lifetime (CP_SESSION_TTL)
RequireEmailProvider bool
- ResendAPIKey string // Resend API key (optional — if empty, emails are logged)
+ ResendAPIKey string // Resend API key (optional; if empty, emails are logged)
EmailFrom string // Sender email address (e.g. "[email protected]")
EmailReplyTo string // Support reply address for transactional email
}
@@ -186,6 +193,17 @@ func LoadConfig() (*CPConfig, error) {
if err != nil {
return nil, err
}
+ defaultSessionTTL := cpauthDefaultSessionTTL
+ if controlPlaneMode == ControlPlaneModeProviderHostedMSP {
+ // Provider-hosted portals are operated by the provider themselves and
+ // often run without an email provider, so re-login means minting a
+ // link on the host. A longer session keeps day-2 use painless.
+ defaultSessionTTL = providerHostedSessionTTL
+ }
+ sessionTTL, err := envOrDefaultDuration("CP_SESSION_TTL", defaultSessionTTL)
+ if err != nil {
+ return nil, err
+ }
providerMSPLicenseFile := strings.TrimSpace(os.Getenv("CP_PROVIDER_MSP_LICENSE_FILE"))
providerMSPPlanVersion := pkglicensing.CanonicalizePlanVersion(envOrDefault("CP_PROVIDER_MSP_PLAN_VERSION", defaultProviderHostedMSPPlanVersion))
providerMSPPlanSource := ProviderMSPPlanSourceEnvFallback
@@ -266,6 +284,7 @@ func LoadConfig() (*CPConfig, error) {
// legacy spelling from the retired trial-activation era, kept as a
// fallback for already-deployed control planes.
TrialActivationPrivateKey: envFirstNonEmpty("CP_ENTITLEMENT_SIGNING_PRIVATE_KEY", "CP_TRIAL_ACTIVATION_PRIVATE_KEY"),
+ SessionTTL: sessionTTL,
RequireEmailProvider: envOrDefaultBool("CP_REQUIRE_EMAIL_PROVIDER", true),
ResendAPIKey: strings.TrimSpace(os.Getenv("RESEND_API_KEY")),
EmailFrom: envOrDefault("PULSE_EMAIL_FROM", "[email protected]"),
@@ -452,6 +471,9 @@ func (c *CPConfig) validate() error {
if c.ProofTenantMaxAge <= 0 {
return fmt.Errorf("CP_PROOF_TENANT_MAX_AGE must be greater than 0")
}
+ if c.SessionTTL <= 0 {
+ return fmt.Errorf("CP_SESSION_TTL must be greater than 0")
+ }
if c.RequireEmailProvider {
if strings.TrimSpace(c.ResendAPIKey) == "" {
return fmt.Errorf("RESEND_API_KEY is required when CP_REQUIRE_EMAIL_PROVIDER=true")
diff --git a/internal/cloudcp/config_test.go b/internal/cloudcp/config_test.go
index bff70ca736..8f7b503be8 100644
--- a/internal/cloudcp/config_test.go
+++ b/internal/cloudcp/config_test.go
@@ -955,3 +955,51 @@ func TestLoadConfig_LegacyTrialActivationKeyNameStillWorks(t *testing.T) {
t.Fatal("legacy CP_TRIAL_ACTIVATION_PRIVATE_KEY fallback no longer derives a key")
}
}
+
+func TestLoadConfig_SessionTTLDefaults(t *testing.T) {
+ setRequiredCPEnv(t)
+ t.Setenv("CP_SESSION_TTL", "")
+
+ cfg, err := LoadConfig()
+ if err != nil {
+ t.Fatalf("LoadConfig: %v", err)
+ }
+ if cfg.SessionTTL != 12*time.Hour {
+ t.Fatalf("SessionTTL = %v, want 12h for pulse-hosted mode", cfg.SessionTTL)
+ }
+}
+
+func TestLoadConfig_SessionTTLProviderHostedDefault(t *testing.T) {
+ setProviderHostedMSPEnv(t)
+ t.Setenv("CP_SESSION_TTL", "")
+
+ cfg, err := LoadConfig()
+ if err != nil {
+ t.Fatalf("LoadConfig: %v", err)
+ }
+ if cfg.SessionTTL != 7*24*time.Hour {
+ t.Fatalf("SessionTTL = %v, want 168h for provider-hosted MSP mode", cfg.SessionTTL)
+ }
+}
+
+func TestLoadConfig_SessionTTLOverride(t *testing.T) {
+ setProviderHostedMSPEnv(t)
+ t.Setenv("CP_SESSION_TTL", "36h")
+
+ cfg, err := LoadConfig()
+ if err != nil {
+ t.Fatalf("LoadConfig: %v", err)
+ }
+ if cfg.SessionTTL != 36*time.Hour {
+ t.Fatalf("SessionTTL = %v, want 36h override", cfg.SessionTTL)
+ }
+}
+
+func TestLoadConfig_SessionTTLInvalid(t *testing.T) {
+ setRequiredCPEnv(t)
+ t.Setenv("CP_SESSION_TTL", "not-a-duration")
+
+ if _, err := LoadConfig(); err == nil {
+ t.Fatal("expected error for invalid CP_SESSION_TTL")
+ }
+}
diff --git a/internal/cloudcp/portal/bootstrap.go b/internal/cloudcp/portal/bootstrap.go
index 22468427eb..be6662c24c 100644
--- a/internal/cloudcp/portal/bootstrap.go
+++ b/internal/cloudcp/portal/bootstrap.go
@@ -61,10 +61,28 @@ type BootstrapAccount struct {
SetupTemplates []BootstrapSetupTemplate `json:"setup_templates,omitempty"`
}
+// PortalEnvironment carries control-plane runtime facts the portal frontend
+// needs to render honestly: whether emailed sign-in links can actually be
+// delivered, and whether this is a provider-hosted (self-operated) control
+// plane rather than Pulse-hosted cloud.
+type PortalEnvironment struct {
+ SignupPath string
+ EmailSignInAvailable bool
+ ProviderHostedMode bool
+}
+
+// DefaultPortalEnvironment matches the historical behavior: Pulse-hosted
+// cloud with a working transactional email provider.
+func DefaultPortalEnvironment(signupPath string) PortalEnvironment {
+ return PortalEnvironment{SignupPath: signupPath, EmailSignInAvailable: true}
+}
+
type BootstrapData struct {
Authenticated bool `json:"authenticated"`
Email string `json:"email"`
HasSelfHostedCommercial bool `json:"has_self_hosted_commercial"`
+ EmailSignInAvailable bool `json:"email_sign_in_available"`
+ ProviderHostedMode bool `json:"provider_hosted_mode"`
PublicSiteURL string `json:"public_site_url"`
SupportEmail string `json:"support_email"`
CommercialAPIBaseURL string `json:"commercial_api_base_url"`
@@ -88,6 +106,10 @@ func MarshalBootstrapJSON(data BootstrapData) (template.JS, error) {
}
func BuildBootstrapDataWithSignupPath(authenticated bool, email string, accounts []portalPageAccount, hasSelfHostedCommercial bool, signupPath string) BootstrapData {
+ return BuildBootstrapDataWithEnvironment(authenticated, email, accounts, hasSelfHostedCommercial, DefaultPortalEnvironment(signupPath))
+}
+
+func BuildBootstrapDataWithEnvironment(authenticated bool, email string, accounts []portalPageAccount, hasSelfHostedCommercial bool, env PortalEnvironment) BootstrapData {
bootstrapAccounts := make([]BootstrapAccount, 0, len(accounts))
for _, account := range accounts {
workspaces := make([]BootstrapWorkspace, 0, len(account.Workspaces))
@@ -159,6 +181,8 @@ func BuildBootstrapDataWithSignupPath(authenticated bool, email string, accounts
Authenticated: authenticated,
Email: email,
HasSelfHostedCommercial: hasSelfHostedCommercial,
+ EmailSignInAvailable: env.EmailSignInAvailable,
+ ProviderHostedMode: env.ProviderHostedMode,
PublicSiteURL: defaultPublicSiteURL,
SupportEmail: defaultSupportEmail,
CommercialAPIBaseURL: defaultCommercialAPIBaseURL,
@@ -166,7 +190,7 @@ func BuildBootstrapDataWithSignupPath(authenticated bool, email string, accounts
PortalPath: defaultPortalPath,
BootstrapPath: PortalBootstrapPath,
MagicLinkRequestPath: PortalMagicLinkRequestPath,
- SignupPath: signupPath,
+ SignupPath: env.SignupPath,
LogoutPath: defaultLogoutPath,
AccountAPIBasePath: defaultAccountAPIBasePath,
PortalAPIBasePath: defaultPortalAPIBasePath,
@@ -198,6 +222,10 @@ func BuildAnonymousBootstrapDataWithSignupPath(signupPath string) BootstrapData
return BuildBootstrapDataWithSignupPath(false, "", nil, false, signupPath)
}
+func BuildAnonymousBootstrapDataWithEnvironment(env PortalEnvironment) BootstrapData {
+ return BuildBootstrapDataWithEnvironment(false, "", nil, false, env)
+}
+
func BuildAnonymousBootstrapData() BootstrapData {
return BuildAnonymousBootstrapDataWithSignupPath(PortalSignupPath)
}
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index 711e00a2c3..99ebb8fbc2 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,5 +1,5 @@
{
- "source_hash": "90e5d2ec651ba11669d98c23aa107ea7dc8e07614097c0c655b3e75ded720d17",
+ "source_hash": "dba4960a5e3f046f4331c8b0dd39d1e7cf0b2b6cb1940c80b44e8d1bb0f86883",
"build_inputs": [
"package.json",
"tsconfig.json",
diff --git a/internal/cloudcp/portal/dist/portal_app.css b/internal/cloudcp/portal/dist/portal_app.css
index 887769925a..72c1ea5ec4 100644
--- a/internal/cloudcp/portal/dist/portal_app.css
+++ b/internal/cloudcp/portal/dist/portal_app.css
@@ -1889,6 +1889,48 @@ header .logout-btn:hover,
color: var(--accent);
font-weight: 500;
}
+.portal-auth-command {
+ margin: 0;
+ padding: 12px 14px;
+ border-radius: 8px;
+ background: var(--surface-sunken, #f6f7f9);
+ border: 1px solid var(--line, #e3e6ea);
+ overflow-x: auto;
+}
+.portal-auth-command code {
+ font-family:
+ ui-monospace,
+ SFMono-Regular,
+ Menlo,
+ Consolas,
+ monospace;
+ font-size: 12.5px;
+ white-space: pre;
+ color: var(--ink);
+}
+.access-invite-delivery-note {
+ font-size: 12.5px;
+ color: var(--ink-secondary);
+}
+.access-invite-delivery-note code {
+ font-family:
+ ui-monospace,
+ SFMono-Regular,
+ Menlo,
+ Consolas,
+ monospace;
+ font-size: 11.5px;
+ word-break: break-all;
+}
+.portal-auth-card > p code {
+ font-family:
+ ui-monospace,
+ SFMono-Regular,
+ Menlo,
+ Consolas,
+ monospace;
+ font-size: 12.5px;
+}
.portal-page-header {
display: flex;
flex-direction: column;
diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.js
index 3d33d95aec..855175a482 100644
--- a/internal/cloudcp/portal/dist/portal_app.js
+++ b/internal/cloudcp/portal/dist/portal_app.js
@@ -943,25 +943,35 @@
}
async function readPayload(response) {
var contentType = response.headers && typeof response.headers.get === "function" ? response.headers.get("content-type") || "" : "";
- if (typeof response.json === "function") {
+ if (contentType.includes("application/json") && typeof response.json === "function") {
try {
return await response.json();
} catch {
+ return null;
}
}
- if (contentType.includes("application/json")) {
+ if (typeof response.text === "function") {
+ var text = "";
try {
- return await response.json();
+ text = await response.text();
} catch {
return null;
}
+ if (!text) return null;
+ try {
+ return JSON.parse(text);
+ } catch {
+ return text;
+ }
}
- try {
- var text = await response.text();
- return text || null;
- } catch {
- return null;
+ if (typeof response.json === "function") {
+ try {
+ return await response.json();
+ } catch {
+ return null;
+ }
}
+ return null;
}
function messageFromPayload(payload, fallback) {
if (payload && typeof payload === "object") {
@@ -1420,6 +1430,14 @@
entry.selectedWorkspaceID = "";
});
};
+ function workspaceLimitMessageFromPayload(payload, clientLanguage) {
+ if (!payload || typeof payload !== "object") return "";
+ var body = payload;
+ if (body.error !== "workspace_limit_reached") return "";
+ var entity = clientLanguage ? "client workspaces" : "workspaces";
+ var counts = typeof body.current === "number" && typeof body.limit === "number" && body.limit > 0 ? " (" + body.current + " of " + body.limit + " in use)" : "";
+ return "Your license limit for " + entity + " is reached" + counts + ". Remove a " + (clientLanguage ? "client" : "workspace") + " or upgrade your license to add more.";
+ }
var createWorkspace = async function(accountID) {
var nameEl = getElement("ws-name-" + accountID);
if (!nameEl) return;
@@ -1456,7 +1474,12 @@
revealElementWhenReady("workspace-management-" + accountID);
deps.showToast(accountUsesClientLanguage2(accountID) ? "Client added. Finish onboarding next." : "Workspace created. Finish setup next.");
} catch (error) {
- var message = error instanceof Error ? error.message : accountUsesClientLanguage2(accountID) ? "Failed to add client." : "Failed to create workspace.";
+ var clientLanguage = accountUsesClientLanguage2(accountID);
+ var message = error instanceof Error ? error.message : clientLanguage ? "Failed to add client." : "Failed to create workspace.";
+ if (error instanceof PortalAPIError) {
+ var limitMessage = workspaceLimitMessageFromPayload(error.payload, clientLanguage);
+ if (limitMessage) message = limitMessage;
+ }
deps.store.updateAccountState(function(accountState) {
var entry = ensurePortalAccountUIEntry(accountState, accountID);
failMutationState(entry.createWorkspace, message);
@@ -1645,6 +1668,9 @@
syncLoginStateBootstrapEmail(loginState, bootstrap.email || "");
}, { notify: false });
async function sendMagicLink() {
+ if (deps.store.getBootstrap().email_sign_in_available === false) {
+ return;
+ }
var loginState = deps.store.getLoginState();
var email = String(loginState.emailValue || "").trim();
if (!email) {
@@ -3140,7 +3166,7 @@
if (!setupNeeded.length) return "";
var visible = setupNeeded.slice(0, 5);
return '<section class="workspace-setup-queue" aria-label="' + escapeAttr(clientLanguage ? "Client onboarding queue" : "Unfinished workspace setup") + '"><div class="workspace-setup-queue-header"><div><h3>' + escapeHTML(clientLanguage ? "Clients in setup" : "Unfinished setup") + "</h3><p>" + escapeHTML(clientLanguage ? "Clients stay here until agents, alert routing, and reports are in place." : "Client workspaces stay here until agents, alert routing, and reports are in place.") + "</p></div><span>" + escapeHTML(setupNeededWorkspaceChipLabel(setupNeeded.length, clientLanguage)) + '</span></div><div class="workspace-setup-queue-list">' + visible.map(function(entry) {
- return '<article class="workspace-setup-queue-row"><div class="workspace-setup-queue-main">' + setupBadgeHTML(entry.workspace) + "<div><strong>" + escapeHTML(entry.workspace.display_name) + "</strong><span>" + escapeHTML(entry.account.name + " \xB7 " + workspaceSetupDiagnosticsLine(entry.workspace)) + "</span><small>" + escapeHTML(workspaceSetupFactsLine(entry.workspace)) + '</small></div></div><div class="workspace-setup-queue-actions">' + renderWorkspaceSetupQueueAction(entry, accountAPIBasePath) + (entry.account.can_manage ? '<button type="button" class="btn-secondary btn-compact" data-action="select-workspace" data-account-id="' + escapeAttr(entry.account.id) + '" data-workspace-id="' + escapeAttr(entry.workspace.id) + '">' + escapeHTML(clientLanguage ? "Onboarding" : "Checklist") + "</button>" : renderWorkspaceHandoffForm(entry.account.id, entry.workspace.id, accountAPIBasePath, clientLanguage ? "Open client" : "Open workspace")) + "</div></article>";
+ return '<article class="workspace-setup-queue-row"><div class="workspace-setup-queue-main">' + setupBadgeHTML(entry.workspace) + "<div><strong>" + escapeHTML(entry.workspace.display_name) + "</strong><span>" + escapeHTML(entry.account.name + " \xB7 " + workspaceSetupDiagnosticsLine(entry.workspace)) + "</span><small>" + escapeHTML(workspaceSetupFactsLine(entry.workspace)) + '</small></div></div><div class="workspace-setup-queue-actions">' + renderWorkspaceSetupQueueAction(entry, accountAPIBasePath) + (entry.account.can_manage ? '<button type="button" class="btn-secondary btn-compact" data-action="select-workspace" data-account-id="' + escapeAttr(entry.account.id) + '" data-workspace-id="' + escapeAttr(entry.workspace.id) + '">' + escapeHTML(clientLanguage ? "Client onboarding" : "Setup checklist") + "</button>" : renderWorkspaceHandoffForm(entry.account.id, entry.workspace.id, accountAPIBasePath, clientLanguage ? "Open client" : "Open workspace")) + "</div></article>";
}).join("") + "</div></section>";
}
function workspaceSectionHeaderCopy(accounts, entries) {
@@ -3206,7 +3232,7 @@
) + "</p>" + (workspaceHeaderActions ? '<div style="margin-top: 8px">' + workspaceHeaderActions + "</div>" : "") + "</div>";
return '<section class="account-content-panel account-content-panel-workspaces"><div class="workspace-operations-shell workspace-operations-shell-idle" id="workspace-operations-shell-' + escapeAttr(account.id) + '"><div class="workspace-operations-detail" id="workspace-operations-detail-' + escapeAttr(account.id) + '" hidden>' + workspaceManagement + '</div><div class="workspace-operations-main">' + workspaceHTML + "</div></div></section>";
}
- function renderAccountAccessSection(account) {
+ function renderAccountAccessSection(account, emailSignInAvailable = true) {
var clientLanguage = accountUsesClientLanguage(account);
var hasBilling = account.has_billing === true;
var accessRoleCopy = {
@@ -3216,7 +3242,8 @@
};
var accessTaskStrip = account.can_manage ? '<div class="access-task-strip"><button type="button" class="access-task-button" id="access-task-invite-' + escapeAttr(account.id) + '" data-action="set-access-job" data-account-id="' + escapeAttr(account.id) + '" data-access-job="invite">Invite people</button><button type="button" class="access-task-button" id="access-task-change_role-' + escapeAttr(account.id) + '" data-action="set-access-job" data-account-id="' + escapeAttr(account.id) + '" data-access-job="change_role">Change roles</button><button type="button" class="access-task-button" id="access-task-remove-' + escapeAttr(account.id) + '" data-action="set-access-job" data-account-id="' + escapeAttr(account.id) + '" data-access-job="remove">Remove access</button></div>' : renderSectionContextChips(["View roster", "Owner or admin required"]);
var accessRoleGuide = '<div class="access-policy-panel"><div class="access-panel-heading"><h4>' + (account.can_manage ? "Choose the smallest role" : "Role meanings") + "</h4><p>" + (account.can_manage ? "Match each person to the narrowest role that still lets them do the job they own." : "Use these role meanings to understand what each person on this roster can do.") + '</p></div><div class="access-policy-list"><div class="access-policy-row"><strong>Owner</strong><span>' + escapeHTML(hasBilling ? "Full account, billing, and access control." : "Full account and access control.") + '</span></div><div class="access-policy-row"><strong>Admin</strong><span>' + escapeHTML(accessRoleCopy.admin) + '</span></div><div class="access-policy-row"><strong>Tech</strong><span>' + escapeHTML(accessRoleCopy.tech) + '</span></div><div class="access-policy-row"><strong>Read-only</strong><span>' + escapeHTML(accessRoleCopy.readOnly) + "</span></div></div></div>";
- var accessInvitePanel = account.can_manage ? '<div class="access-invite-panel"><div class="access-panel-heading"><h4>Invite people</h4><p>Add one person with the minimum role they need on this account.</p></div><div class="access-invite"><div><label for="invite-email-' + escapeAttr(account.id) + '">Email</label><input type="email" id="invite-email-' + escapeAttr(account.id) + '" placeholder="[email protected]" autocomplete="off"></div><div><label for="invite-role-' + escapeAttr(account.id) + '">Role</label><select id="invite-role-' + escapeAttr(account.id) + '"><option value="admin">Admin</option><option value="tech">Tech</option><option value="read_only">Read-only</option></select></div><button type="button" class="btn-primary btn-compact" data-action="invite-member" data-account-id="' + escapeAttr(account.id) + '">Invite</button></div></div>' : "";
+ var inviteDeliveryNote = emailSignInAvailable ? "" : '<p class="access-invite-delivery-note">No email provider is configured, so invitation emails are not sent. After inviting, print their one-time sign-in link on the control plane host: <code>docker compose run --rm control-plane provider-msp portal-link --email their@address</code></p>';
+ var accessInvitePanel = account.can_manage ? '<div class="access-invite-panel"><div class="access-panel-heading"><h4>Invite people</h4><p>Add one person with the minimum role they need on this account.</p>' + inviteDeliveryNote + '</div><div class="access-invite"><div><label for="invite-email-' + escapeAttr(account.id) + '">Email</label><input type="email" id="invite-email-' + escapeAttr(account.id) + '" placeholder="[email protected]" autocomplete="off"></div><div><label for="invite-role-' + escapeAttr(account.id) + '">Role</label><select id="invite-role-' + escapeAttr(account.id) + '"><option value="read_only">Read-only</option><option value="tech">Tech</option><option value="admin">Admin</option></select></div><button type="button" class="btn-primary btn-compact" data-action="invite-member" data-account-id="' + escapeAttr(account.id) + '">Invite</button></div></div>' : "";
var accessChangeRolePanel = '<div class="access-job-note-panel"><div class="access-panel-heading"><h4>Change roles on the roster</h4><p>Use the role column in the roster to change one person at a time. Keep each person on the smallest role they need.</p></div></div>' + accessRoleGuide;
var accessRemovePanel = '<div class="access-job-note-panel"><div class="access-panel-heading"><h4>Remove stale access</h4><p>Use removal only when this person should no longer be on this hosted account. Owners may still be protected when they are the last owner.</p></div><div class="access-remove-points"><div class="access-remove-point"><strong>Pick the exact person</strong><span>Use the roster to remove one account member at a time.</span></div><div class="access-remove-point"><strong>Keep current owners safe</strong><span>The last owner cannot be removed until another owner exists.</span></div></div></div>';
return '<section class="account-content-panel account-content-panel-access"><section class="access-management-panel access-section access-section-shell" id="access-section-' + escapeAttr(account.id) + '" data-actor-role="' + escapeAttr(account.role) + '" data-can-manage="' + escapeAttr(account.can_manage ? "true" : "false") + '" data-client-language="' + escapeAttr(clientLanguage ? "true" : "false") + '">' + (!account.can_manage ? '<p class="portal-section-copy">' + escapeHTML("Review who has access. An owner or admin must make changes.") + "</p>" : "") + '<div class="access-management-stats" id="access-stats-' + escapeAttr(account.id) + '"></div><div class="access-shell access-shell-idle" id="access-shell-' + escapeAttr(account.id) + '">' + (account.can_manage ? '<div class="access-shell-detail" id="access-detail-' + escapeAttr(account.id) + '" hidden><div class="access-task-panel" id="access-task-panel-' + escapeAttr(account.id) + '" hidden><div class="access-task-header"><div><h4 id="access-task-title-' + escapeAttr(account.id) + '">Invite people</h4><p id="access-task-copy-' + escapeAttr(account.id) + '"></p></div><button type="button" class="btn-secondary btn-compact" data-action="clear-access-job" data-account-id="' + escapeAttr(account.id) + '">Close panel</button></div><div class="access-task-body" id="access-task-body-invite-' + escapeAttr(account.id) + '" hidden>' + accessInvitePanel + accessRoleGuide + '</div><div class="access-task-body" id="access-task-body-change_role-' + escapeAttr(account.id) + '" hidden>' + accessChangeRolePanel + '</div><div class="access-task-body" id="access-task-body-remove-' + escapeAttr(account.id) + '" hidden>' + accessRemovePanel + "</div></div></div>" : "") + '<div class="access-shell-main"><div class="access-roster-column"><div class="access-roster">' + (account.can_manage ? '<div class="access-roster-toolbar">' + accessTaskStrip + "</div>" : "") + '<div class="access-roster-list" id="access-list-' + escapeAttr(account.id) + '"><div class="access-list-message">Loading\u2026</div></div></div></div></div></div></section></section>';
@@ -3257,7 +3284,8 @@
var hostedViewOnly = isHosted && !canManageHostedTasks;
var retryCopy = isHosted ? hostedViewOnly ? hasBillingSection ? "Review " + primarySectionLabel + " or Access first. If billing is involved, hand it to an owner or admin before you escalate." : "Review " + primarySectionLabel + " or Access first. If account ownership is involved, hand it to an owner or admin before you escalate." : "Retry the same " + primarySectionLabel + (hasBillingSection ? ", Access, or Billing" : " or Access") + " step before you escalate." : "Retry the same Billing step before you escalate.";
var supportActions = isHosted ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="workspaces">' + escapeHTML(primarySectionLabel) + '</button><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Access</button>' + (hasBillingSection ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>' : "") : '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>';
- return '<section class="portal-support-panel"><p>Use Support only after the self-service path fails. Retry the same step before you escalate.</p><div class="portal-support-simple"><div class="portal-support-simple-card"><div class="portal-support-simple-list"><div class="portal-support-simple-row"><strong>Try first</strong><span>' + escapeHTML(retryCopy) + '</span></div><div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, hasHostedBillingAccounts(accounts), clientLanguage)) + '</span></div><div class="portal-support-simple-row"><strong>Include</strong><span>Account, email, and the exact action that failed.</span></div></div><div class="portal-support-simple-actions">' + supportActions + '<a class="portal-support-link" href="mailto:' + escapeAttr(supportEmail) + '">' + escapeHTML(supportEmail) + "</a></div></div></div></section>";
+ var providerOpsRow = context.bootstrap.provider_hosted_mode === true ? '<div class="portal-support-simple-row"><strong>Operations guide</strong><span>Backups, upgrades, firewall baseline, and the validation checklist live in <a href="https://github.com/rcourtman/Pulse/blob/main/docs/MSP.md" target="_blank" rel="noopener">docs/MSP.md</a>.</span></div>' : "";
+ return '<section class="portal-support-panel"><p>Most issues clear on a retry of the same step. If it fails twice, email the details below and we will pick it up from there.</p><div class="portal-support-simple"><div class="portal-support-simple-card"><div class="portal-support-simple-list"><div class="portal-support-simple-row"><strong>Try first</strong><span>' + escapeHTML(retryCopy) + '</span></div><div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, hasHostedBillingAccounts(accounts), clientLanguage)) + '</span></div><div class="portal-support-simple-row"><strong>Include</strong><span>Account, email, and the exact action that failed.</span></div>' + providerOpsRow + '</div><div class="portal-support-simple-actions">' + supportActions + '<a class="portal-support-link" href="mailto:' + escapeAttr(supportEmail) + '">' + escapeHTML(supportEmail) + "</a></div></div></div></section>";
}
function renderHeaderHTML(context) {
if (context.bootstrap.authenticated) {
@@ -3287,7 +3315,7 @@
}).join("") : renderNoHostedWorkspacesSection();
var workspaceSummaryContent = hosted ? renderWorkspaceSummarySection(context) : "";
var accessContent = accounts.length ? accounts.map(function(account) {
- return '<section class="account-surface">' + renderAccountSurfaceHeader(account, accounts.length > 1) + renderAccountAccessSection(account) + "</section>";
+ return '<section class="account-surface">' + renderAccountSurfaceHeader(account, accounts.length > 1) + renderAccountAccessSection(account, context.bootstrap.email_sign_in_available !== false) + "</section>";
}).join("") : renderNoHostedAccessSection();
var selfHostedBillingLeadCopy = showSelfHostedCommercial ? "Use self-hosted billing only for self-hosted purchases." : "Pulse Account owns the commercial handoff for self-hosted upgrades from the app.";
var selfHostedBillingActionsHTML = renderSelfHostedUpgradeActionRow(context);
@@ -3324,6 +3352,7 @@
return '<article class="portal-auth-scope-row"><h3>' + escapeHTML(title) + "</h3><p>" + escapeHTML(copy) + "</p></article>";
}
function renderSignedOutPortalHTML(context) {
+ var providerMode = context.bootstrap.provider_hosted_mode === true;
var statusHTML = "";
if (context.loginState.request.error) {
statusHTML = '<div class="billing-status visible error">' + escapeHTML(context.loginState.request.error) + "</div>";
@@ -3332,7 +3361,16 @@
statusHTML = '<div class="billing-status visible success">' + escapeHTML(successMessage) + '<br><br><strong>Need another link?</strong> <a href="#" data-portal-action="resend-magic-link">Send it again</a>.</div>';
}
var signupHTML = hasSignupPath(context.signupPath) ? '<p class="portal-auth-secondary-action">Need a new Pulse Account? <a href="' + escapeAttr(context.signupPath) + '">Create an account</a>.</p>' : "";
- return '<section class="portal-auth-shell"><div class="portal-auth-intro"><h1>Sign in to Pulse Account</h1><p>Use one commercial email address for hosted workspaces, account access, billing, licenses, refunds, and privacy requests.</p><div class="portal-auth-scope-list" aria-label="Pulse Account scope">' + renderAuthScopeRow("Workspaces", "Open hosted workspaces and review workspace state.") + renderAuthScopeRow("Access", "Review account access and manage roles when permitted.") + renderAuthScopeRow("Billing", "Open hosted billing or self-hosted commercial tools when they apply.") + '</div></div><section class="portal-auth-panel" aria-labelledby="portal-auth-title"><div class="portal-auth-card"><h2 id="portal-auth-title">Email sign-in link</h2><p>Enter the commercial email address for your Pulse account. A sign-in link will be sent to that address.</p><div class="form-group portal-auth-form-group"><label for="portal-login-email">Commercial email</label><input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' + escapeAttr(context.loginState.emailValue || "") + '" data-portal-input="login-email"></div><div class="form-actions portal-auth-actions"><button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' + (context.loginState.request.pending ? "Sending\u2026" : "Send sign-in link") + "</button></div>" + signupHTML + statusHTML + "</div></section></section>";
+ var introHTML = providerMode ? '<h1>Sign in to Pulse Account</h1><p>This portal manages the client workspaces on your Pulse control plane.</p><div class="portal-auth-scope-list" aria-label="Pulse Account scope">' + renderAuthScopeRow("Clients", "Add clients, follow onboarding, and review client health and alerts.") + renderAuthScopeRow("Access", "Invite provider staff and keep every person on the smallest useful role.") + renderAuthScopeRow("Isolation", "Each client runs in its own workspace boundary; opening a client hands you into that boundary.") + "</div>" : '<h1>Sign in to Pulse Account</h1><p>Use one commercial email address for hosted workspaces, account access, billing, licenses, refunds, and privacy requests.</p><div class="portal-auth-scope-list" aria-label="Pulse Account scope">' + renderAuthScopeRow("Workspaces", "Open hosted workspaces and review workspace state.") + renderAuthScopeRow("Access", "Review account access and manage roles when permitted.") + renderAuthScopeRow("Billing", "Open hosted billing or self-hosted commercial tools when they apply.") + "</div>";
+ var cardHTML;
+ if (context.bootstrap.email_sign_in_available === false) {
+ cardHTML = '<h2 id="portal-auth-title">Sign-in links come from your control plane host</h2><p>This control plane has no email provider configured, so it cannot send sign-in links. Generate a one-time link on the host where the control plane runs, then open it in this browser:</p><pre class="portal-auth-command"><code>docker compose run --rm control-plane \\\n provider-msp portal-link --email [email protected]</code></pre><p>Run it from your deploy directory. The email address must already be an account member or hold a pending invitation.</p><p>To enable email sign-in, set <code>RESEND_API_KEY</code> in the control plane <code>.env</code> and restart it.</p>';
+ } else {
+ var emailLabel = providerMode ? "Email" : "Commercial email";
+ var emailIntro = providerMode ? "Enter the email address for your Pulse account. A sign-in link will be sent to that address." : "Enter the commercial email address for your Pulse account. A sign-in link will be sent to that address.";
+ cardHTML = '<h2 id="portal-auth-title">Email sign-in link</h2><p>' + escapeHTML(emailIntro) + '</p><div class="form-group portal-auth-form-group"><label for="portal-login-email">' + escapeHTML(emailLabel) + '</label><input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' + escapeAttr(context.loginState.emailValue || "") + '" data-portal-input="login-email"></div><div class="form-actions portal-auth-actions"><button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' + (context.loginState.request.pending ? "Sending\u2026" : "Send sign-in link") + "</button></div>" + signupHTML + statusHTML;
+ }
+ return '<section class="portal-auth-shell"><div class="portal-auth-intro">' + introHTML + '</div><section class="portal-auth-panel" aria-labelledby="portal-auth-title"><div class="portal-auth-card">' + cardHTML + "</div></section></section>";
}
// src/shell.ts
@@ -3629,6 +3667,10 @@
var signupPath = typeof embeddedBootstrap.signup_path === "string" ? embeddedBootstrap.signup_path : "/signup";
return {
has_self_hosted_commercial: embeddedBootstrap.has_self_hosted_commercial === true,
+ // Default to available so Pulse-hosted cloud (which always has email)
+ // never hides the sign-in form if the flag is missing from an older payload.
+ email_sign_in_available: embeddedBootstrap.email_sign_in_available !== false,
+ provider_hosted_mode: embeddedBootstrap.provider_hosted_mode === true,
public_site_url: embeddedBootstrap.public_site_url || "https://pulserelay.pro",
support_email: embeddedBootstrap.support_email || "[email protected]",
commercial_api_base_url: embeddedBootstrap.commercial_api_base_url || "",
diff --git a/internal/cloudcp/portal/frontend/src/account_runtime.test.ts b/internal/cloudcp/portal/frontend/src/account_runtime.test.ts
index a0f1b643e9..37cf6fbee8 100644
--- a/internal/cloudcp/portal/frontend/src/account_runtime.test.ts
+++ b/internal/cloudcp/portal/frontend/src/account_runtime.test.ts
@@ -27,6 +27,8 @@ async function flushAsync() {
const bootstrapDefaults: Omit<PortalBootstrapData, 'authenticated' | 'email' | 'accounts'> = {
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
diff --git a/internal/cloudcp/portal/frontend/src/account_runtime.ts b/internal/cloudcp/portal/frontend/src/account_runtime.ts
index e63cbdbc58..3f8155a54a 100644
--- a/internal/cloudcp/portal/frontend/src/account_runtime.ts
+++ b/internal/cloudcp/portal/frontend/src/account_runtime.ts
@@ -178,6 +178,20 @@ export function installAccountRuntime(deps: AccountRuntimeDeps): AccountRuntime
});
};
+ // Maps the control plane's workspace_limit_reached payload to copy a
+ // provider can act on; returns '' for any other error payload.
+ function workspaceLimitMessageFromPayload(payload: unknown, clientLanguage: boolean): string {
+ if (!payload || typeof payload !== 'object') return '';
+ var body = payload as { error?: unknown; current?: unknown; limit?: unknown };
+ if (body.error !== 'workspace_limit_reached') return '';
+ var entity = clientLanguage ? 'client workspaces' : 'workspaces';
+ var counts = typeof body.current === 'number' && typeof body.limit === 'number' && body.limit > 0
+ ? ' (' + body.current + ' of ' + body.limit + ' in use)'
+ : '';
+ return 'Your license limit for ' + entity + ' is reached' + counts + '. Remove a ' +
+ (clientLanguage ? 'client' : 'workspace') + ' or upgrade your license to add more.';
+ }
+
var createWorkspace = async function(accountID: string): Promise<void> {
var nameEl = getElement<HTMLInputElement>('ws-name-' + accountID);
if (!nameEl) return;
@@ -214,7 +228,12 @@ export function installAccountRuntime(deps: AccountRuntimeDeps): AccountRuntime
revealElementWhenReady('workspace-management-' + accountID);
deps.showToast(accountUsesClientLanguage(accountID) ? 'Client added. Finish onboarding next.' : 'Workspace created. Finish setup next.');
} catch (error) {
- var message = error instanceof Error ? error.message : (accountUsesClientLanguage(accountID) ? 'Failed to add client.' : 'Failed to create workspace.');
+ var clientLanguage = accountUsesClientLanguage(accountID);
+ var message = error instanceof Error ? error.message : (clientLanguage ? 'Failed to add client.' : 'Failed to create workspace.');
+ if (error instanceof PortalAPIError) {
+ var limitMessage = workspaceLimitMessageFromPayload(error.payload, clientLanguage);
+ if (limitMessage) message = limitMessage;
+ }
deps.store.updateAccountState(function(accountState) {
var entry = ensurePortalAccountUIEntry(accountState, accountID);
failMutationState(entry.createWorkspace, message);
diff --git a/internal/cloudcp/portal/frontend/src/api.test.ts b/internal/cloudcp/portal/frontend/src/api.test.ts
index d91c03bde2..e6f3500714 100644
--- a/internal/cloudcp/portal/frontend/src/api.test.ts
+++ b/internal/cloudcp/portal/frontend/src/api.test.ts
@@ -7,6 +7,8 @@ const bootstrap: PortalBootstrapData = {
authenticated: true,
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
diff --git a/internal/cloudcp/portal/frontend/src/api.ts b/internal/cloudcp/portal/frontend/src/api.ts
index 078b41a668..bf4ab2cc10 100644
--- a/internal/cloudcp/portal/frontend/src/api.ts
+++ b/internal/cloudcp/portal/frontend/src/api.ts
@@ -71,29 +71,41 @@ export function createPortalAPI(context: PortalAPIContext): PortalAPI {
}
async function readPayload(response: Response): Promise<unknown> {
+ // Read the body exactly once. Calling response.json() speculatively and
+ // falling back to response.text() consumed the stream, so non-JSON error
+ // bodies (e.g. plain-text http.Error responses) were silently dropped.
var contentType = response.headers && typeof response.headers.get === 'function'
? response.headers.get('content-type') || ''
: '';
- if (typeof response.json === 'function') {
+ if (contentType.includes('application/json') && typeof response.json === 'function') {
try {
return await response.json();
} catch {
- // Fall through to text/null handling.
+ return null;
}
}
- if (contentType.includes('application/json')) {
+ if (typeof response.text === 'function') {
+ var text = '';
try {
- return await response.json();
+ text = await response.text();
} catch {
return null;
}
+ if (!text) return null;
+ try {
+ return JSON.parse(text);
+ } catch {
+ return text;
+ }
}
- try {
- var text = await response.text();
- return text || null;
- } catch {
- return null;
+ if (typeof response.json === 'function') {
+ try {
+ return await response.json();
+ } catch {
+ return null;
+ }
}
+ return null;
}
function messageFromPayload(payload: unknown, fallback: string): string {
diff --git a/internal/cloudcp/portal/frontend/src/app.test.ts b/internal/cloudcp/portal/frontend/src/app.test.ts
index e65319db67..3b5342706b 100644
--- a/internal/cloudcp/portal/frontend/src/app.test.ts
+++ b/internal/cloudcp/portal/frontend/src/app.test.ts
@@ -26,6 +26,8 @@ async function flushAsync() {
const bootstrapDefaults: Omit<PortalBootstrapData, 'authenticated' | 'email' | 'accounts'> = {
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
@@ -167,6 +169,8 @@ describe('portal app', function() {
authenticated: true,
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: [
{
id: 'acct_1',
@@ -237,6 +241,8 @@ describe('portal app', function() {
authenticated: true,
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: accounts,
});
var fetchMock = vi.fn(async function(input: RequestInfo | URL) {
@@ -246,6 +252,8 @@ describe('portal app', function() {
authenticated: true,
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: accounts,
});
}
diff --git a/internal/cloudcp/portal/frontend/src/auth_controller.test.ts b/internal/cloudcp/portal/frontend/src/auth_controller.test.ts
index 44724eb04a..fc27b9f67b 100644
--- a/internal/cloudcp/portal/frontend/src/auth_controller.test.ts
+++ b/internal/cloudcp/portal/frontend/src/auth_controller.test.ts
@@ -16,6 +16,8 @@ async function flushAsync() {
const bootstrapDefaults: Omit<PortalBootstrapData, 'authenticated' | 'email' | 'accounts'> = {
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
diff --git a/internal/cloudcp/portal/frontend/src/auth_controller.ts b/internal/cloudcp/portal/frontend/src/auth_controller.ts
index 3bdfd1791a..75fa568419 100644
--- a/internal/cloudcp/portal/frontend/src/auth_controller.ts
+++ b/internal/cloudcp/portal/frontend/src/auth_controller.ts
@@ -31,6 +31,11 @@ export function installAuthController(deps: AuthControllerDeps): AuthController
}, { notify: false });
async function sendMagicLink() {
+ if (deps.store.getBootstrap().email_sign_in_available === false) {
+ // The signed-out view replaces the form with operator instructions in
+ // this state; this guard covers any stale markup.
+ return;
+ }
var loginState = deps.store.getLoginState();
var email = String(loginState.emailValue || '').trim();
if (!email) {
diff --git a/internal/cloudcp/portal/frontend/src/billing_view.test.ts b/internal/cloudcp/portal/frontend/src/billing_view.test.ts
index ef29c77bd3..5c7cb4d7ab 100644
--- a/internal/cloudcp/portal/frontend/src/billing_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/billing_view.test.ts
@@ -19,6 +19,8 @@ function createBootstrap(overrides: Partial<PortalBootstrapData> = {}): PortalBo
authenticated: true,
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
diff --git a/internal/cloudcp/portal/frontend/src/runtime.ts b/internal/cloudcp/portal/frontend/src/runtime.ts
index 037e44ee19..4d29afe77a 100644
--- a/internal/cloudcp/portal/frontend/src/runtime.ts
+++ b/internal/cloudcp/portal/frontend/src/runtime.ts
@@ -103,6 +103,10 @@ export function createBootstrapDefaults(
: '/signup';
return {
has_self_hosted_commercial: embeddedBootstrap.has_self_hosted_commercial === true,
+ // Default to available so Pulse-hosted cloud (which always has email)
+ // never hides the sign-in form if the flag is missing from an older payload.
+ email_sign_in_available: embeddedBootstrap.email_sign_in_available !== false,
+ provider_hosted_mode: embeddedBootstrap.provider_hosted_mode === true,
public_site_url: embeddedBootstrap.public_site_url || 'https://pulserelay.pro',
support_email: embeddedBootstrap.support_email || '[email protected]',
commercial_api_base_url: embeddedBootstrap.commercial_api_base_url || '',
diff --git a/internal/cloudcp/portal/frontend/src/shell.test.ts b/internal/cloudcp/portal/frontend/src/shell.test.ts
index 445dc67a4b..4a03fa4022 100644
--- a/internal/cloudcp/portal/frontend/src/shell.test.ts
+++ b/internal/cloudcp/portal/frontend/src/shell.test.ts
@@ -6,6 +6,8 @@ import type { PortalBootstrapData } from './types';
const bootstrapDefaults: Omit<PortalBootstrapData, 'authenticated' | 'email' | 'accounts'> = {
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.test.ts b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
index 5641ea1e77..12bb46c13d 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
@@ -15,6 +15,8 @@ function createBootstrap(overrides: Partial<PortalBootstrapData> = {}): PortalBo
authenticated: true,
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
@@ -340,6 +342,8 @@ describe('shell view', function() {
createContext({
bootstrap: createBootstrap({
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: [
{
id: 'acct_mixed',
@@ -382,6 +386,8 @@ describe('shell view', function() {
createContext({
bootstrap: createBootstrap({
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: [],
}),
})
@@ -789,6 +795,8 @@ describe('shell view', function() {
createContext({
bootstrap: createBootstrap({
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: [
{
id: 'acct_hosted',
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.ts b/internal/cloudcp/portal/frontend/src/shell_view.ts
index c27142f527..dd6fc54629 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.ts
@@ -969,7 +969,7 @@ function renderWorkspaceSetupQueue(entries: WorkspaceSummaryEntry[], accountAPIB
escapeAttr(entry.account.id) +
'" data-workspace-id="' +
escapeAttr(entry.workspace.id) +
- '">' + escapeHTML(clientLanguage ? 'Onboarding' : 'Checklist') + '</button>'
+ '">' + escapeHTML(clientLanguage ? 'Client onboarding' : 'Setup checklist') + '</button>'
: renderWorkspaceHandoffForm(entry.account.id, entry.workspace.id, accountAPIBasePath, clientLanguage ? 'Open client' : 'Open workspace')) +
'</div>' +
'</article>'
@@ -1324,7 +1324,7 @@ function renderAccountWorkspaceSection(account: PortalAccountSummary, accountAPI
);
}
-function renderAccountAccessSection(account: PortalAccountSummary): string {
+function renderAccountAccessSection(account: PortalAccountSummary, emailSignInAvailable = true): string {
var clientLanguage = accountUsesClientLanguage(account);
var hasBilling = account.has_billing === true;
var accessRoleCopy = {
@@ -1360,12 +1360,16 @@ function renderAccountAccessSection(account: PortalAccountSummary): string {
'<div class="access-policy-row"><strong>Read-only</strong><span>' + escapeHTML(accessRoleCopy.readOnly) + '</span></div>' +
'</div>' +
'</div>';
+ var inviteDeliveryNote = emailSignInAvailable
+ ? ''
+ : '<p class="access-invite-delivery-note">No email provider is configured, so invitation emails are not sent. After inviting, print their one-time sign-in link on the control plane host: <code>docker compose run --rm control-plane provider-msp portal-link --email their@address</code></p>';
var accessInvitePanel = account.can_manage
? (
'<div class="access-invite-panel">' +
'<div class="access-panel-heading">' +
'<h4>Invite people</h4>' +
'<p>Add one person with the minimum role they need on this account.</p>' +
+ inviteDeliveryNote +
'</div>' +
'<div class="access-invite">' +
'<div><label for="invite-email-' +
@@ -1377,7 +1381,7 @@ function renderAccountAccessSection(account: PortalAccountSummary): string {
escapeAttr(account.id) +
'">Role</label><select id="invite-role-' +
escapeAttr(account.id) +
- '"><option value="admin">Admin</option><option value="tech">Tech</option><option value="read_only">Read-only</option></select></div>' +
+ '"><option value="read_only">Read-only</option><option value="tech">Tech</option><option value="admin">Admin</option></select></div>' +
'<button type="button" class="btn-primary btn-compact" data-action="invite-member" data-account-id="' +
escapeAttr(account.id) +
'">Invite</button>' +
@@ -1564,15 +1568,19 @@ function renderSupportSection(context: ShellViewContext): string {
(hasBillingSection ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>' : '')
)
: '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>';
+ var providerOpsRow = context.bootstrap.provider_hosted_mode === true
+ ? '<div class="portal-support-simple-row"><strong>Operations guide</strong><span>Backups, upgrades, firewall baseline, and the validation checklist live in <a href="https://github.com/rcourtman/Pulse/blob/main/docs/MSP.md" target="_blank" rel="noopener">docs/MSP.md</a>.</span></div>'
+ : '';
return (
'<section class="portal-support-panel">' +
- '<p>Use Support only after the self-service path fails. Retry the same step before you escalate.</p>' +
+ '<p>Most issues clear on a retry of the same step. If it fails twice, email the details below and we will pick it up from there.</p>' +
'<div class="portal-support-simple">' +
'<div class="portal-support-simple-card">' +
'<div class="portal-support-simple-list">' +
'<div class="portal-support-simple-row"><strong>Try first</strong><span>' + escapeHTML(retryCopy) + '</span></div>' +
'<div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, hasHostedBillingAccounts(accounts), clientLanguage)) + '</span></div>' +
'<div class="portal-support-simple-row"><strong>Include</strong><span>Account, email, and the exact action that failed.</span></div>' +
+ providerOpsRow +
'</div>' +
'<div class="portal-support-simple-actions">' +
supportActions +
@@ -1636,7 +1644,7 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
return (
'<section class="account-surface">' +
renderAccountSurfaceHeader(account, accounts.length > 1) +
- renderAccountAccessSection(account) +
+ renderAccountAccessSection(account, context.bootstrap.email_sign_in_available !== false) +
'</section>'
);
}).join('')
@@ -1750,6 +1758,7 @@ function renderAuthScopeRow(title: string, copy: string): string {
}
export function renderSignedOutPortalHTML(context: ShellViewContext): string {
+ var providerMode = context.bootstrap.provider_hosted_mode === true;
var statusHTML = '';
if (context.loginState.request.error) {
statusHTML = '<div class="billing-status visible error">' + escapeHTML(context.loginState.request.error) + '</div>';
@@ -1764,34 +1773,62 @@ export function renderSignedOutPortalHTML(context: ShellViewContext): string {
var signupHTML = hasSignupPath(context.signupPath)
? '<p class="portal-auth-secondary-action">Need a new Pulse Account? <a href="' + escapeAttr(context.signupPath) + '">Create an account</a>.</p>'
: '';
+ var introHTML = providerMode
+ ? '<h1>Sign in to Pulse Account</h1>' +
+ '<p>This portal manages the client workspaces on your Pulse control plane.</p>' +
+ '<div class="portal-auth-scope-list" aria-label="Pulse Account scope">' +
+ renderAuthScopeRow('Clients', 'Add clients, follow onboarding, and review client health and alerts.') +
+ renderAuthScopeRow('Access', 'Invite provider staff and keep every person on the smallest useful role.') +
+ renderAuthScopeRow('Isolation', 'Each client runs in its own workspace boundary; opening a client hands you into that boundary.') +
+ '</div>'
+ : '<h1>Sign in to Pulse Account</h1>' +
+ '<p>Use one commercial email address for hosted workspaces, account access, billing, licenses, refunds, and privacy requests.</p>' +
+ '<div class="portal-auth-scope-list" aria-label="Pulse Account scope">' +
+ renderAuthScopeRow('Workspaces', 'Open hosted workspaces and review workspace state.') +
+ renderAuthScopeRow('Access', 'Review account access and manage roles when permitted.') +
+ renderAuthScopeRow('Billing', 'Open hosted billing or self-hosted commercial tools when they apply.') +
+ '</div>';
+ var cardHTML;
+ if (context.bootstrap.email_sign_in_available === false) {
+ // No transactional email provider is configured, so a "we sent you a
+ // link" form would be a false promise. Point at the operator command
+ // that actually produces a sign-in link.
+ cardHTML =
+ '<h2 id="portal-auth-title">Sign-in links come from your control plane host</h2>' +
+ '<p>This control plane has no email provider configured, so it cannot send sign-in links. Generate a one-time link on the host where the control plane runs, then open it in this browser:</p>' +
+ '<pre class="portal-auth-command"><code>docker compose run --rm control-plane \\\n provider-msp portal-link --email [email protected]</code></pre>' +
+ '<p>Run it from your deploy directory. The email address must already be an account member or hold a pending invitation.</p>' +
+ '<p>To enable email sign-in, set <code>RESEND_API_KEY</code> in the control plane <code>.env</code> and restart it.</p>';
+ } else {
+ var emailLabel = providerMode ? 'Email' : 'Commercial email';
+ var emailIntro = providerMode
+ ? 'Enter the email address for your Pulse account. A sign-in link will be sent to that address.'
+ : 'Enter the commercial email address for your Pulse account. A sign-in link will be sent to that address.';
+ cardHTML =
+ '<h2 id="portal-auth-title">Email sign-in link</h2>' +
+ '<p>' + escapeHTML(emailIntro) + '</p>' +
+ '<div class="form-group portal-auth-form-group">' +
+ '<label for="portal-login-email">' + escapeHTML(emailLabel) + '</label>' +
+ '<input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' +
+ escapeAttr(context.loginState.emailValue || '') +
+ '" data-portal-input="login-email">' +
+ '</div>' +
+ '<div class="form-actions portal-auth-actions">' +
+ '<button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' +
+ (context.loginState.request.pending ? 'Sending…' : 'Send sign-in link') +
+ '</button>' +
+ '</div>' +
+ signupHTML +
+ statusHTML;
+ }
return (
'<section class="portal-auth-shell">' +
'<div class="portal-auth-intro">' +
- '<h1>Sign in to Pulse Account</h1>' +
- '<p>Use one commercial email address for hosted workspaces, account access, billing, licenses, refunds, and privacy requests.</p>' +
- '<div class="portal-auth-scope-list" aria-label="Pulse Account scope">' +
- renderAuthScopeRow('Workspaces', 'Open hosted workspaces and review workspace state.') +
- renderAuthScopeRow('Access', 'Review account access and manage roles when permitted.') +
- renderAuthScopeRow('Billing', 'Open hosted billing or self-hosted commercial tools when they apply.') +
- '</div>' +
+ introHTML +
'</div>' +
'<section class="portal-auth-panel" aria-labelledby="portal-auth-title">' +
'<div class="portal-auth-card">' +
- '<h2 id="portal-auth-title">Email sign-in link</h2>' +
- '<p>Enter the commercial email address for your Pulse account. A sign-in link will be sent to that address.</p>' +
- '<div class="form-group portal-auth-form-group">' +
- '<label for="portal-login-email">Commercial email</label>' +
- '<input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' +
- escapeAttr(context.loginState.emailValue || '') +
- '" data-portal-input="login-email">' +
- '</div>' +
- '<div class="form-actions portal-auth-actions">' +
- '<button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' +
- (context.loginState.request.pending ? 'Sending…' : 'Send sign-in link') +
- '</button>' +
- '</div>' +
- signupHTML +
- statusHTML +
+ cardHTML +
'</div>' +
'</section>' +
'</section>'
diff --git a/internal/cloudcp/portal/frontend/src/store.test.ts b/internal/cloudcp/portal/frontend/src/store.test.ts
index 8562df68be..fc31b17b5c 100644
--- a/internal/cloudcp/portal/frontend/src/store.test.ts
+++ b/internal/cloudcp/portal/frontend/src/store.test.ts
@@ -5,6 +5,8 @@ import type { PortalBootstrapData } from './types';
const bootstrapDefaults: Omit<PortalBootstrapData, 'authenticated' | 'email' | 'accounts'> = {
has_self_hosted_commercial: false,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
public_site_url: 'https://pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
@@ -82,6 +84,8 @@ describe('portal store', function() {
authenticated: true,
has_self_hosted_commercial: true,
+ email_sign_in_available: true,
+ provider_hosted_mode: false,
accounts: [],
});
diff --git a/internal/cloudcp/portal/frontend/src/styles.css b/internal/cloudcp/portal/frontend/src/styles.css
index 350a8539cf..7832eb59fb 100644
--- a/internal/cloudcp/portal/frontend/src/styles.css
+++ b/internal/cloudcp/portal/frontend/src/styles.css
@@ -1696,6 +1696,35 @@ header .logout-btn:hover,
}
.portal-auth-secondary-action a { color: var(--accent); font-weight: 500; }
+.portal-auth-command {
+ margin: 0;
+ padding: 12px 14px;
+ border-radius: 8px;
+ background: var(--surface-sunken, #f6f7f9);
+ border: 1px solid var(--line, #e3e6ea);
+ overflow-x: auto;
+}
+.portal-auth-command code {
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
+ font-size: 12.5px;
+ white-space: pre;
+ color: var(--ink);
+}
+.access-invite-delivery-note {
+ font-size: 12.5px;
+ color: var(--ink-secondary);
+}
+.access-invite-delivery-note code {
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
+ font-size: 11.5px;
+ word-break: break-all;
+}
+
+.portal-auth-card > p code {
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
+ font-size: 12.5px;
+}
+
/* ── Page-level headers for billing/support ────────────────────── */
.portal-page-header {
display: flex;
diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.ts
index e0b588c266..d1518abf8a 100644
--- a/internal/cloudcp/portal/frontend/src/types.ts
+++ b/internal/cloudcp/portal/frontend/src/types.ts
@@ -55,6 +55,8 @@ export interface PortalBootstrapData {
authenticated: boolean;
email: string;
has_self_hosted_commercial: boolean;
+ email_sign_in_available: boolean;
+ provider_hosted_mode: boolean;
public_site_url: string;
support_email: string;
commercial_api_base_url: string;
diff --git a/internal/cloudcp/portal/handlers.go b/internal/cloudcp/portal/handlers.go
index 48d9f44e90..8cfcc8c747 100644
--- a/internal/cloudcp/portal/handlers.go
+++ b/internal/cloudcp/portal/handlers.go
@@ -291,6 +291,10 @@ func HandlePortalBootstrapWithSignupPath(sessionSvc *cpauth.Service, reg *regist
}
func HandlePortalBootstrapWithSignupPathAndSetupFacts(sessionSvc *cpauth.Service, reg *registry.TenantRegistry, commercialLookup CommercialIdentityLookup, signupPath string, setupFacts WorkspaceSetupFactReader) http.HandlerFunc {
+ return HandlePortalBootstrapWithEnvironment(sessionSvc, reg, commercialLookup, DefaultPortalEnvironment(signupPath), setupFacts)
+}
+
+func HandlePortalBootstrapWithEnvironment(sessionSvc *cpauth.Service, reg *registry.TenantRegistry, commercialLookup CommercialIdentityLookup, env PortalEnvironment, setupFacts WorkspaceSetupFactReader) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
@@ -321,7 +325,7 @@ func HandlePortalBootstrapWithSignupPathAndSetupFacts(sessionSvc *cpauth.Service
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
- encodeJSON(w, BuildBootstrapDataWithSignupPath(true, claims.Email, accounts, resolveSelfHostedCommercial(r.Context(), commercialLookup, claims.Email, accounts), signupPath))
+ encodeJSON(w, BuildBootstrapDataWithEnvironment(true, claims.Email, accounts, resolveSelfHostedCommercial(r.Context(), commercialLookup, claims.Email, accounts), env))
}
}
diff --git a/internal/cloudcp/portal/page.go b/internal/cloudcp/portal/page.go
index ca01fbc73f..e0f27dab8a 100644
--- a/internal/cloudcp/portal/page.go
+++ b/internal/cloudcp/portal/page.go
@@ -80,6 +80,10 @@ const (
var errPortalAuthRequired = errors.New("portal auth required")
func HandlePortalPageWithSignupPathAndSetupFacts(sessionSvc *cpauth.Service, reg *registry.TenantRegistry, commercialLookup CommercialIdentityLookup, faviconHref string, signupPath string, setupFacts WorkspaceSetupFactReader) http.HandlerFunc {
+ return HandlePortalPageWithEnvironment(sessionSvc, reg, commercialLookup, faviconHref, DefaultPortalEnvironment(signupPath), setupFacts)
+}
+
+func HandlePortalPageWithEnvironment(sessionSvc *cpauth.Service, reg *registry.TenantRegistry, commercialLookup CommercialIdentityLookup, faviconHref string, env PortalEnvironment, setupFacts WorkspaceSetupFactReader) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
@@ -97,9 +101,9 @@ func HandlePortalPageWithSignupPathAndSetupFacts(sessionSvc *cpauth.Service, reg
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
- renderPortalPage(w, nonce, faviconHref, BuildBootstrapDataWithSignupPath(true, claims.Email, accounts, resolveSelfHostedCommercial(r.Context(), commercialLookup, claims.Email, accounts), signupPath))
+ renderPortalPage(w, nonce, faviconHref, BuildBootstrapDataWithEnvironment(true, claims.Email, accounts, resolveSelfHostedCommercial(r.Context(), commercialLookup, claims.Email, accounts), env))
case errors.Is(err, errPortalAuthRequired):
- renderPortalPage(w, nonce, faviconHref, BuildAnonymousBootstrapDataWithSignupPath(signupPath))
+ renderPortalPage(w, nonce, faviconHref, BuildAnonymousBootstrapDataWithEnvironment(env))
default:
log.Error().Err(err).Msg("cloudcp.portal.page: validate session")
http.Error(w, "internal error", http.StatusInternalServerError)
diff --git a/internal/cloudcp/provider_msp_portal_link.go b/internal/cloudcp/provider_msp_portal_link.go
new file mode 100644
index 0000000000..17ba4d5f5c
--- /dev/null
+++ b/internal/cloudcp/provider_msp_portal_link.go
@@ -0,0 +1,117 @@
+package cloudcp
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ cpauth "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/auth"
+ "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/registry"
+)
+
+// ProviderMSPPortalLinkOptions describes a portal sign-in link request for an
+// account member or pending invitee on an MSP control plane.
+type ProviderMSPPortalLinkOptions struct {
+ Email string
+}
+
+// ProviderMSPPortalLinkResult is the operator-facing result of minting a
+// portal sign-in link.
+type ProviderMSPPortalLinkResult struct {
+ Email string
+ AccessState string
+ Role string
+ MagicLinkURL string
+}
+
+// ProviderMSPPortalLink mints a one-time portal sign-in link for an existing
+// account member or a pending invitee. It exists so operators without a
+// configured email provider still have a way to deliver sign-in links to
+// teammates; the owner path is covered by BootstrapProviderMSP.
+func ProviderMSPPortalLink(ctx context.Context, cfg *CPConfig, opts ProviderMSPPortalLinkOptions) (*ProviderMSPPortalLinkResult, error) {
+ if err := ctx.Err(); err != nil {
+ return nil, err
+ }
+ if cfg == nil {
+ return nil, fmt.Errorf("control plane config is required")
+ }
+ if !cfg.IsMSPControlPlane() {
+ return nil, fmt.Errorf("provider MSP portal-link requires CP_CONTROL_PLANE_MODE=%s or %s", ControlPlaneModeProviderHostedMSP, ControlPlaneModePulseHostedMSP)
+ }
+
+ email, err := normalizeProviderMSPOwnerEmail(opts.Email)
+ if err != nil {
+ return nil, fmt.Errorf("email is invalid: %w", err)
+ }
+
+ reg, err := registry.NewTenantRegistry(cfg.ControlPlaneDir())
+ if err != nil {
+ return nil, fmt.Errorf("open tenant registry: %w", err)
+ }
+ defer reg.Close()
+
+ accessState, role, err := providerMSPPortalAccessForEmail(reg, email)
+ if err != nil {
+ return nil, err
+ }
+
+ magicLinks, err := cpauth.NewService(cfg.ControlPlaneDir())
+ if err != nil {
+ return nil, fmt.Errorf("init magic link service: %w", err)
+ }
+ defer magicLinks.Close()
+
+ token, err := magicLinks.GeneratePortalToken(email, "")
+ if err != nil {
+ return nil, fmt.Errorf("generate portal magic link: %w", err)
+ }
+ magicLinkURL := cpauth.BuildVerifyURL(cfg.BaseURL, token)
+ if magicLinkURL == "" {
+ return nil, fmt.Errorf("build portal magic link URL")
+ }
+
+ return &ProviderMSPPortalLinkResult{
+ Email: email,
+ AccessState: accessState,
+ Role: role,
+ MagicLinkURL: magicLinkURL,
+ }, nil
+}
+
+// providerMSPPortalAccessForEmail confirms the email already has portal
+// access (an account membership) or a pending invitation, so the CLI cannot
+// be used to mint sessions for arbitrary addresses.
+func providerMSPPortalAccessForEmail(reg *registry.TenantRegistry, email string) (accessState string, role string, err error) {
+ user, err := reg.GetUserByEmail(email)
+ if err != nil {
+ return "", "", fmt.Errorf("lookup user: %w", err)
+ }
+ if user != nil {
+ accountIDs, err := reg.ListAccountsByUser(user.ID)
+ if err != nil {
+ return "", "", fmt.Errorf("list accounts for user: %w", err)
+ }
+ for _, accountID := range accountIDs {
+ membership, err := reg.GetMembership(accountID, user.ID)
+ if err != nil {
+ return "", "", fmt.Errorf("lookup membership: %w", err)
+ }
+ if membership != nil {
+ return "member", string(membership.Role), nil
+ }
+ }
+ }
+
+ invitations, err := reg.ListInvitationsByEmail(email)
+ if err != nil {
+ return "", "", fmt.Errorf("list invitations: %w", err)
+ }
+ for _, invitation := range invitations {
+ if invitation == nil {
+ continue
+ }
+ return "invited", string(invitation.Role), nil
+ }
+
+ return "", "", fmt.Errorf("%s is not an account member and has no pending invitation; invite them from the portal Access tab first", strings.ToLower(email))
+}
diff --git a/internal/cloudcp/routes.go b/internal/cloudcp/routes.go
index 7058eca6bd..e74328795f 100644
--- a/internal/cloudcp/routes.go
+++ b/internal/cloudcp/routes.go
@@ -286,7 +286,12 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {
mux.Handle("/api/accounts/{account_id}/tenants/{tenant_id}/handoff", accountAPILimiter.Middleware(accountSessionAuth(accountIDFromPath, handoffHandler)))
// MSP portal API (session + account-membership authenticated)
- mux.Handle(portal.PortalBootstrapPath, portalAPILimiter.Middleware(sessionAuth(portal.HandlePortalBootstrapWithSignupPathAndSetupFacts(deps.MagicLinks, deps.Registry, portalCommercialLookup, publicCloudSignupPath, portalSetupFacts))))
+ portalEnv := portal.PortalEnvironment{
+ SignupPath: publicCloudSignupPath,
+ EmailSignInAvailable: strings.TrimSpace(deps.Config.ResendAPIKey) != "",
+ ProviderHostedMode: deps.Config.IsProviderHostedMSP(),
+ }
+ mux.Handle(portal.PortalBootstrapPath, portalAPILimiter.Middleware(sessionAuth(portal.HandlePortalBootstrapWithEnvironment(deps.MagicLinks, deps.Registry, portalCommercialLookup, portalEnv, portalSetupFacts))))
mux.Handle(portal.PortalDashboardPath, portalAPILimiter.Middleware(accountSessionAuth(accountIDFromPortalRequest, portal.HandlePortalDashboardWithSetupFacts(deps.Registry, portalSetupFacts))))
mux.Handle(portal.PortalWorkspacePath, portalAPILimiter.Middleware(accountSessionAuth(accountIDFromPortalRequest, portal.HandlePortalWorkspaceDetail(deps.Registry))))
@@ -304,5 +309,5 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {
// MSP/Cloud portal HTML page — self-authenticating (shows login form if no session)
portalPageLimiter := NewCPRateLimiter(60, time.Minute)
- mux.Handle(portal.PortalPagePath, portalPageLimiter.Middleware(http.HandlerFunc(portal.HandlePortalPageWithSignupPathAndSetupFacts(deps.MagicLinks, deps.Registry, portalCommercialLookup, controlPlaneFaviconHref(), publicCloudSignupPath, portalSetupFacts))))
+ mux.Handle(portal.PortalPagePath, portalPageLimiter.Middleware(http.HandlerFunc(portal.HandlePortalPageWithEnvironment(deps.MagicLinks, deps.Registry, portalCommercialLookup, controlPlaneFaviconHref(), portalEnv, portalSetupFacts))))
}
diff --git a/internal/cloudcp/server.go b/internal/cloudcp/server.go
index b60760361b..bce70a1533 100644
--- a/internal/cloudcp/server.go
+++ b/internal/cloudcp/server.go
@@ -86,6 +86,7 @@ func Run(ctx context.Context, version string) error {
return fmt.Errorf("init magic link service: %w", err)
}
defer magicLinkSvc.Close()
+ magicLinkSvc.SetSessionTTL(cfg.SessionTTL)
// Initialize email sender
var emailSender email.Sender
diff --git a/scripts/installtests/provider_msp_deploy_test.go b/scripts/installtests/provider_msp_deploy_test.go
index b53c615d20..33ab257c39 100644
--- a/scripts/installtests/provider_msp_deploy_test.go
+++ b/scripts/installtests/provider_msp_deploy_test.go
@@ -78,6 +78,8 @@ func TestProviderMSPDeployEnvExampleMatchesBootstrapPath(t *testing.T) {
"CP_ENTITLEMENT_SIGNING_PRIVATE_KEY=",
"sudo -E ./setup.sh",
"docker compose run --rm control-plane provider-msp bootstrap",
+ "docker compose run --rm control-plane provider-msp portal-link",
+ "CP_SESSION_TTL",
"docker compose run --rm control-plane provider-msp preflight",
"docker compose run --rm control-plane provider-msp status",
"docker compose run --rm control-plane provider-msp status --require-backup",
@@ -155,6 +157,8 @@ func TestProviderMSPSetupScriptMatchesProviderContract(t *testing.T) {
"PULSE_PROVIDER_MSP_ACCOUNT_NAME",
"PULSE_PROVIDER_MSP_OWNER_EMAIL",
"./run-install-proof.sh",
+ "Next step: create your operator account",
+ "provider-msp portal-link --email",
)
assertNotContainsAny(t, text, "docker network create --subnet")
}