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.

fix(onboarding): allow relay mobile pairing scope

rcourtman86a3f2161cbc
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 4a8240a164..f45f90e93f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -227,6 +227,12 @@ shared `internal/api/security_setup_fix.go` helpers must allow that org's
owner/admin membership to exercise settings-bound pairing routes instead of
requiring a separate configured local admin username that does not exist on
hosted tenants.
+The same setup boundary also owns the dedicated relay-mobile bootstrap read:
+once the backend mints the server-owned Pulse Mobile credential, the QR,
+deep-link, and validation reads in `internal/api/router_routes_ai_relay.go`
+must accept that `relay:mobile:access` scope directly instead of demanding the
+broader settings-read privilege that the pairing token was never meant to
+carry.
The direct Proxmox fallback workspace now also lives explicitly inside this
lifecycle boundary: `InfrastructureWorkspace.tsx`,
`infrastructureWorkspaceModel.ts`,
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index e5b5198b8a..a838f1292d 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -141,6 +141,7 @@ Own canonical runtime payload shapes between backend and frontend.
16. Keep Pulse Mobile relay credential minting and permission ownership on backend ownership: `internal/api/router_routes_auth_security.go`, `internal/api/security_tokens.go`, `internal/api/auth.go`, `internal/api/router_routes_ai_relay.go`, and `frontend-modern/src/api/security.ts` may expose the canonical mobile runtime token creator and governed route gates, but browser callers must only consume that route and must not define the mobile runtime scope, compatibility gate list, or token-purpose metadata locally.
17. Keep hosted tenant browser-session precedence on the shared auth boundary: `internal/api/auth.go`, `internal/api/contract_test.go`, and hosted tenant callers must treat a valid `pulse_session` as authoritative before any no-local-auth anonymous fallback, so cloud handoff can continue into protected hosted routes without flattening the operator back to `anonymous`.
18. Keep tenant settings-scope authorization aligned with org management: `internal/api/security_setup_fix.go`, `internal/api/contract_test.go`, and settings-bound hosted callers must allow the current non-default org owner/admin membership to exercise privileged tenant routes, rather than requiring a separate configured local admin identity after hosted handoff.
+19. Keep mobile onboarding payload reads aligned with the server-owned relay-mobile credential: `internal/api/router_routes_ai_relay.go`, `internal/api/onboarding_handlers.go`, and `internal/api/contract_test.go` must allow the dedicated `relay:mobile:access` scope to reach the governed QR, deep-link, and connection-validation payloads without reintroducing a broader `settings:read` requirement for token-authenticated pairing clients.
## Forbidden Paths
@@ -1589,6 +1590,11 @@ request is scoped to a non-default org, `internal/api/security_setup_fix.go`
must honor the org's owner/admin membership model for settings-bound routes
such as relay-mobile token minting, instead of requiring a separate configured
local admin username that hosted tenants do not carry.
+The same onboarding boundary in `internal/api/router_routes_ai_relay.go` must
+also accept the dedicated `relay:mobile:access` scope for
+`/api/onboarding/qr`, `/api/onboarding/validate`, and
+`/api/onboarding/deep-link`, because those payloads are the canonical
+bootstrap surface for the server-minted mobile credential.
The shared security token contract now also includes single-record metadata
reads. `internal/api/security_tokens.go`,
`internal/api/router_routes_auth_security.go`,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 9f66e7f25a..a4aaee080e 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -876,3 +876,9 @@ recovery-adjacent hosted flows that reuse settings-bound helpers must allow
the current org owner/admin membership to continue through privileged tenant
routes after cloud handoff instead of requiring a separate configured local
admin identity that hosted tenants do not carry.
+That same adjacent onboarding boundary must also keep the dedicated
+relay-mobile bootstrap credential sufficient for QR, deep-link, and
+connection-validation reads, so hosted recovery/support flows that hand a
+paired device back into onboarding do not need to escalate the mobile token to
+the broader settings-read privilege just to fetch the canonical bootstrap
+payload.
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index d7580fd33b..9942baa835 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -946,6 +946,22 @@ func TestContract_HostedOrgManagerSessionCanMintRelayMobileToken(t *testing.T) {
}
}
+func TestContract_RelayMobileScopeCanReadOnboardingDeepLink(t *testing.T) {
+ rawToken := "relay-mobile-onboarding-token-123.12345678"
+ record := newTokenRecord(t, rawToken, []string{config.ScopeRelayMobileAccess}, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodGet, "/api/onboarding/deep-link", nil)
+ req.Header.Set("X-API-Token", rawToken)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+
+ if rec.Code == http.StatusForbidden && strings.Contains(rec.Body.String(), "missing_scope") {
+ t.Fatalf("relay mobile scope should satisfy onboarding deep-link gating, got %d: %s", rec.Code, rec.Body.String())
+ }
+}
+
func TestContract_UnifiedAgentReportResponseJSONSnapshot(t *testing.T) {
payload := map[string]any{
"success": true,
diff --git a/internal/api/router_routes_ai_relay.go b/internal/api/router_routes_ai_relay.go
index c423a953c2..adc67ceb5d 100644
--- a/internal/api/router_routes_ai_relay.go
+++ b/internal/api/router_routes_ai_relay.go
@@ -28,6 +28,7 @@ const (
var (
relayMobileChatCompatibleScopes = []string{config.ScopeRelayMobileAccess, config.ScopeAIChat}
relayMobileExecuteCompatibleScopes = []string{config.ScopeRelayMobileAccess, config.ScopeAIExecute}
+ relayMobileOnboardingScopes = []string{config.ScopeRelayMobileAccess, config.ScopeSettingsRead}
)
func (r *Router) registerAIRelayRoutesGroup() {
@@ -85,20 +86,20 @@ func (r *Router) registerAIRelayRoutesGroup() {
r.mux.HandleFunc("GET /api/settings/relay", RequireAdmin(r.config, RequireScope(config.ScopeSettingsRead, RequireLicenseFeature(r.licenseHandlers, featureRelayKey, r.handleGetRelayConfig))))
r.mux.HandleFunc("PUT /api/settings/relay", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, RequireLicenseFeature(r.licenseHandlers, featureRelayKey, r.handleUpdateRelayConfig))))
r.mux.HandleFunc("GET /api/settings/relay/status", RequireAdmin(r.config, RequireScope(config.ScopeSettingsRead, RequireLicenseFeature(r.licenseHandlers, featureRelayKey, r.handleGetRelayStatus))))
- r.mux.HandleFunc("GET /api/onboarding/qr", RequireAuth(r.config, RequireScope(config.ScopeSettingsRead, func(w http.ResponseWriter, req *http.Request) {
- if !ensureSettingsReadScope(r.config, w, req) {
+ r.mux.HandleFunc("GET /api/onboarding/qr", RequireAuth(r.config, RequireAnyScope(relayMobileOnboardingScopes, func(w http.ResponseWriter, req *http.Request) {
+ if getAPITokenRecordFromRequest(req) == nil && !ensureSettingsReadScope(r.config, w, req) {
return
}
RequireLicenseFeature(r.licenseHandlers, featureRelayKey, r.handleGetOnboardingQR)(w, req)
})))
- r.mux.HandleFunc("POST /api/onboarding/validate", RequireAuth(r.config, RequireScope(config.ScopeSettingsRead, func(w http.ResponseWriter, req *http.Request) {
- if !ensureSettingsReadScope(r.config, w, req) {
+ r.mux.HandleFunc("POST /api/onboarding/validate", RequireAuth(r.config, RequireAnyScope(relayMobileOnboardingScopes, func(w http.ResponseWriter, req *http.Request) {
+ if getAPITokenRecordFromRequest(req) == nil && !ensureSettingsReadScope(r.config, w, req) {
return
}
RequireLicenseFeature(r.licenseHandlers, featureRelayKey, r.handleValidateOnboardingConnection)(w, req)
})))
- r.mux.HandleFunc("GET /api/onboarding/deep-link", RequireAuth(r.config, RequireScope(config.ScopeSettingsRead, func(w http.ResponseWriter, req *http.Request) {
- if !ensureSettingsReadScope(r.config, w, req) {
+ r.mux.HandleFunc("GET /api/onboarding/deep-link", RequireAuth(r.config, RequireAnyScope(relayMobileOnboardingScopes, func(w http.ResponseWriter, req *http.Request) {
+ if getAPITokenRecordFromRequest(req) == nil && !ensureSettingsReadScope(r.config, w, req) {
return
}
RequireLicenseFeature(r.licenseHandlers, featureRelayKey, r.handleGetOnboardingDeepLink)(w, req)
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index fc3b14cce9..01ce44b1d4 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -1302,6 +1302,9 @@ func TestRelayMobileAccessScopeAllowsGovernedMobileRuntimeEndpoints(t *testing.T
path string
body string
}{
+ {method: http.MethodGet, path: "/api/onboarding/qr", body: ""},
+ {method: http.MethodPost, path: "/api/onboarding/validate", body: `{}`},
+ {method: http.MethodGet, path: "/api/onboarding/deep-link", body: ""},
{method: http.MethodGet, path: "/api/ai/patrol/findings", body: ""},
{method: http.MethodGet, path: "/api/ai/findings/finding-1/investigation", body: ""},
{method: http.MethodGet, path: "/api/ai/findings/finding-1/investigation/messages", body: ""},