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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Report SAML metadata evidence without implying tested sign-in
pulse-triage[bot]5e8b846d6d2a
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex a9b93d411f..2043fb1d2b 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -10555,3 +10555,14 @@ ordinary-user producer/caller controls through the normal installer inventory.Existing boot-logger and NAS-removal tests retain detached execution and exactremoval compatibility. Source fixtures do not establish native Unraid lifecycleor original installed-recovery acceptance.++### Shared SAML diagnostic limits remain separate from agent authority++The API-owned SAML Test now requires IdP identity and a supported HTTP(S) SSO+endpoint before reporting metadata success, and labels metadata/manual results+as untested sign-in (manual certificates are untested too). Incomplete metadata+returns `metadata_incomplete` without details or a manual fallback. This changes+only diagnostic evidence, not agent credentials, enrolment, saved provider+settings, certificate trust or authentication. The adjacent+`TestContractSSOSAMLDiagnosticConsumer` proves read-only authenticated results,+correct audit verdicts and unchanged saved secrets/local administrator recovery.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 482bf35778..6b2f59a680 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -13002,3 +13002,21 @@ refusal. `TestContractSSOEnvironmentBoundaryConsumer` binds actual authenticatedresponses and temporary persistence to the existing editor's request shapes;optional synthetic fixtures support consuming browser proof. These controlsare not a claim of an installed leak or native identity-provider recovery.++### SAML Test reports metadata evidence, not sign-in acceptance++The existing SSO diagnostic on `internal/api/identity_sso_handlers.go` requires+nonblank IdP identity and an HTTP(S) SSO endpoint in a supported binding before+returning metadata success. Incomplete, unsupported or credential-bearing+endpoints return `metadata_incomplete` without success details; selected metadata+cannot fall back to manual settings. Success says only that identity and an SSO+URL were found, explicitly not that sign-in was tested. The manual path checks+URL format only and explicitly leaves certificates and sign-in untested.+Certificate information remains informational; no new trust, save or login+policy is introduced. `TestSAMLConnectionRequiresMetadataEvidence` covers format+and evidence boundaries; `TestContractSSOSAMLDiagnosticConsumer` exercises the+authenticated route, exact wire results, audit verdicts and unchanged settings,+files, saved secrets and local administrator recovery. Existing fetch/parse+categories, metadata-source precedence, limits, rate checks and outbound/TLS+policy remain unchanged. Browser proof consumes those actual synthetic wire+results through the existing Settings editor at desktop and narrow viewports.diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 4f263272fc..b373b88867 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -7984,3 +7984,15 @@ Removing a guessed node must not discard the useful namespace/datastore itmisrepresented. `ProxmoxCoverageTable.test.tsx` checks narrow/full projectionand complete long location text; the parsed inventory regressions also retainreader identity and full repository context without adding reads or routes.++### SAML diagnostic evidence does not establish recovery access++The shared API SAML Test rejects missing IdP identity or a supported HTTP(S)+SSO endpoint as `metadata_incomplete`, without validated details or a fallback+to manual settings. Its success describes metadata evidence only and states+that sign-in was not tested; the manual URL-format result also states that+certificates were not tested. This adds no recovery or certificate-trust+authority, saves no configuration and changes no sign-in service policy.+`TestContractSSOSAMLDiagnosticConsumer` binds the real authenticated diagnostic,+audit success/failure and preserved settings/files/secrets/admin access. Actual+native sign-in and installed recovery remain distinct evidence.diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex c07ab51f39..6de131aa19 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -28419,3 +28419,128 @@ func TestContractSSOUnrepresentedSettingsSurviveSignedProviderEdit(t *testing.T)t.Fatal("SAML runtime did not consume retained settings")}}++// The real authenticated Settings diagnostic must reject incomplete SAML+// evidence without saving the draft, exposing saved secrets, or claiming an+// actual sign-in. These synthetic wire frames also bind consuming-browser proof.+func TestContractSSOSAMLDiagnosticConsumer(t *testing.T) {+ const token = "saml-diagnostic-synthetic-token.12345678"+ record := newTokenRecord(t, token, []string{config.ScopeSettingsRead, config.ScopeSettingsWrite}, nil)+ r := NewRouter(newTestConfigWithTokens(t, record), nil, nil, nil, nil, "test")+ seedRestrictedSSOProvider(t, r)+ before, err := json.Marshal(r.currentSSOConfig())+ if err != nil {+ t.Fatal(err)+ }+ beforeFiles := ssoAdmissionFiles(t, r.config.DataPath)+ beforeAuthUser, beforeAuthPass := r.config.AuthUser, r.config.AuthPass+ logger := &testAuditLogger{}+ setAuditLogger(t, logger)++ const ssoURL = "https://idp.example.test/Case/Sso"+ good := samlDiagnosticMetadata("urn:Synthetic:IdP", samlDiagnosticDescriptor(saml.HTTPRedirectBinding, ssoURL, ""))+ documents := map[string]string{+ "/empty": samlDiagnosticMetadata("urn:Synthetic:IdP", ""),+ "/unsupported": samlDiagnosticMetadata("urn:Synthetic:IdP", samlDiagnosticDescriptor("urn:unsupported:binding", ssoURL, "")),+ "/unsafe": samlDiagnosticMetadata("urn:Synthetic:IdP", samlDiagnosticDescriptor(saml.HTTPPostBinding, "https://synthetic:[email protected]/sso", "")),+ "/good": good,+ "/broken": "not XML",+ }+ var requests atomic.Int32+ server := newIPv4HTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {+ requests.Add(1)+ xml, ok := documents[req.URL.Path]+ if req.Method != http.MethodGet || !ok {+ t.Errorf("unexpected request: %s %s", req.Method, req.URL.Path)+ http.NotFound(w, req)+ return+ }+ w.Header().Set("Content-Type", "application/xml")+ _, _ = w.Write([]byte(xml))+ }))+ defer server.Close()+ var frames []map[string]interface{}+ for _, tt := range []struct {+ name, code string+ cfg *SAMLTestConfig+ }{+ {"fetched-incomplete", "metadata_incomplete", &SAMLTestConfig{IDPMetadataURL: server.URL + "/empty"}},+ {"fetched-unsupported", "metadata_incomplete", &SAMLTestConfig{IDPMetadataURL: server.URL + "/unsupported"}},+ {"fetched-unsafe", "metadata_incomplete", &SAMLTestConfig{IDPMetadataURL: server.URL + "/unsafe"}},+ {"fetched-format-only", "", &SAMLTestConfig{IDPMetadataURL: server.URL + "/good"}},+ {"fetched-parse-failure", "fetch_failed", &SAMLTestConfig{IDPMetadataURL: server.URL + "/broken"}},+ {"metadata-no-manual-fallback", "metadata_incomplete", &SAMLTestConfig{IDPMetadataURL: server.URL + "/empty", IDPMetadataXML: good, IDPSSOURL: ssoURL}},+ {"inline-incomplete", "metadata_incomplete", &SAMLTestConfig{IDPMetadataXML: samlDiagnosticMetadata("urn:Synthetic:IdP", "")}},+ {"inline-format-only", "", &SAMLTestConfig{IDPMetadataXML: good}},+ {"manual-format-only", "", &SAMLTestConfig{IDPSSOURL: ssoURL}},+ {"manual-certificate-untested", "", &SAMLTestConfig{IDPSSOURL: ssoURL, IDPCertificate: "synthetic-not-a-certificate"}},+ } {+ t.Run(tt.name, func(t *testing.T) {+ beforeRequests := requests.Load()+ beforeAudit := len(logger.events)+ payload, _ := json.Marshal(SSOTestRequest{Type: "saml", SAML: tt.cfg})+ req := httptest.NewRequest(http.MethodPost, "/api/security/sso/providers/test", bytes.NewReader(payload))+ req.Header.Set("X-API-Token", token)+ req.Header.Set("Content-Type", "application/json")+ setTestIP(req)+ w := httptest.NewRecorder()+ r.Handler().ServeHTTP(w, req)+ wantStatus := http.StatusOK+ if tt.code != "" {+ wantStatus = http.StatusBadRequest+ }+ if w.Code != wantStatus {+ t.Fatalf("status %d, want %d: %s", w.Code, wantStatus, w.Body.String())+ }+ var result SSOTestResponse+ if err := json.Unmarshal(w.Body.Bytes(), &result); err != nil {+ t.Fatal(err)+ }+ if result.Success != (tt.code == "") || result.Error != tt.code {+ t.Fatalf("misleading diagnostic: %+v", result)+ }+ if result.Success {+ if !strings.Contains(strings.ToLower(result.Message), "not been tested") || result.Details == nil || result.Details.Certificates == nil || result.Details.SupportedScopes == nil {+ t.Fatal("success must retain diagnostic limits and canonical details")+ }+ if tt.cfg.IDPMetadataURL == "" && tt.cfg.IDPMetadataXML == "" && !strings.Contains(result.Message, "Certificates and sign-in") {+ t.Fatal("manual URL test must not claim certificate validation")+ }+ } else if result.Details != nil {+ t.Fatal("failed diagnostic must not return validated details")+ }+ if strings.Contains(w.Body.String(), "fixture-secret") || strings.Contains(w.Body.String(), "synthetic-token") || strings.Contains(w.Body.String(), "SYNTHETIC_PRIVATE") {+ t.Fatal("diagnostic exposed saved credentials or untrusted failure details")+ }+ wantRequests := int32(0)+ if tt.cfg.IDPMetadataURL != "" {+ wantRequests = 1+ }+ if requests.Load() != beforeRequests+wantRequests {+ t.Fatal("test must make one metadata GET at most; never contact SSO or fall back on failure")+ }+ var diagnosticAudits int+ for _, event := range logger.events[beforeAudit:] {+ if event.EventType == "sso_provider_test" {+ diagnosticAudits+++ if event.Success != result.Success {+ t.Fatal("audit must record the diagnostic's actual verdict")+ }+ }+ }+ if diagnosticAudits != 1 {+ t.Fatalf("want one diagnostic audit event, got %d", diagnosticAudits)+ }+ after, err := json.Marshal(r.currentSSOConfig())+ if err != nil || string(before) != string(after) || !reflect.DeepEqual(beforeFiles, ssoAdmissionFiles(t, r.config.DataPath)) || r.config.AuthUser != beforeAuthUser || r.config.AuthPass != beforeAuthPass {+ t.Fatalf("diagnostic changed provider settings, files or local administrator recovery: %v", err)+ }+ frames = append(frames, map[string]interface{}{"name": tt.name, "request": string(payload), "status": w.Code, "body": w.Body.String()})+ })+ }+ encoded, err := json.Marshal(frames)+ if err != nil {+ t.Fatal(err)+ }+ t.Logf("SAML_CONSUMER_FRAMES %s", encoded)+}diff --git a/internal/api/identity_sso_handlers.go b/internal/api/identity_sso_handlers.goindex 34023e1b19..3f6f572a5d 100644--- a/internal/api/identity_sso_handlers.go+++ b/internal/api/identity_sso_handlers.go@@ -976,7 +976,7 @@ func (r *Router) testSAMLConnection(ctx context.Context, cfg *SAMLTestConfig) SS}return SSOTestResponse{Success: true,- Message: "SSO URL is valid (manual configuration)",+ Message: "Only the SAML SSO URL format was checked. Certificates and sign-in have not been tested.",Details: &SSOTestDetails{Type: "saml",SSOURL: cfg.IDPSSOURL,@@ -1019,9 +1019,21 @@ func (r *Router) testSAMLConnection(ctx context.Context, cfg *SAMLTestConfig) SS_ = rawXML // Used for metadata preview endpoint+ // Parsing XML alone does not establish that it describes an IdP with a+ // supported SSO endpoint. Do not present incomplete or unsafe metadata as+ // a successful diagnostic, or fall back to unrelated manual settings.+ // This is a format/evidence check only: do not contact the SSO endpoint+ // or change the sign-in service's certificate or authentication policy.+ if strings.TrimSpace(details.EntityID) == "" || !validateURL(details.SSOURL, []string{"https", "http"}) {+ return SSOTestResponse{+ Message: "The SAML test did not identify an IdP and a usable SSO URL. Check the IdP metadata or manual SSO URL, then test again. Sign-in has not been tested.",+ Error: "metadata_incomplete",+ }+ }+return SSOTestResponse{Success: true,- Message: "SAML metadata validated successfully",+ Message: "SAML metadata includes an IdP identity and an SSO URL. Sign-in has not been tested.",Details: details,}}diff --git a/internal/api/sso_saml_test_evidence_test.go b/internal/api/sso_saml_test_evidence_test.gonew file mode 100644index 0000000000..96aaebe14c--- /dev/null+++ b/internal/api/sso_saml_test_evidence_test.go@@ -0,0 +1,154 @@+package api++import (+ "crypto/ecdsa"+ "crypto/elliptic"+ "crypto/rand"+ "crypto/x509"+ "crypto/x509/pkix"+ "encoding/base64"+ "encoding/pem"+ "fmt"+ "math/big"+ "net/http"+ "sync/atomic"+ "testing"+ "time"++ "github.com/crewjam/saml"+ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ "github.com/stretchr/testify/require"+)++func samlDiagnosticMetadata(entity, descriptor string) string {+ return `<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" entityID="` + entity + `">` + descriptor + `</EntityDescriptor>`+}++func samlDiagnosticDescriptor(binding, endpoint, keys string) string {+ return `<IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">` + keys ++ `<SingleSignOnService Binding="` + binding + `" Location="` + endpoint + `"/></IDPSSODescriptor>`+}++func TestSAMLConnectionRequiresMetadataEvidence(t *testing.T) {+ for _, tt := range []struct{ name, entity, descriptor string }{+ {"empty metadata", "", ""},+ {"no IdP descriptor", "urn:synthetic:idp", ""},+ {"SP only", "urn:synthetic:idp", `<SPSSODescriptor/>`},+ {"missing identity", "", samlDiagnosticDescriptor(saml.HTTPRedirectBinding, "https://idp.example.test/sso", "")},+ {"blank identity", " 	 ", samlDiagnosticDescriptor(saml.HTTPRedirectBinding, "https://idp.example.test/sso", "")},+ {"missing endpoint", "urn:synthetic:idp", samlDiagnosticDescriptor(saml.HTTPRedirectBinding, "", "")},+ {"no endpoints", "urn:synthetic:idp", `<IDPSSODescriptor/>`},+ {"unsupported binding", "urn:synthetic:idp", samlDiagnosticDescriptor("urn:unsupported:binding", "https://idp.example.test/sso", "")},+ {"relative endpoint", "urn:synthetic:idp", samlDiagnosticDescriptor(saml.HTTPRedirectBinding, "/sso", "")},+ {"unsafe endpoint", "urn:synthetic:idp", samlDiagnosticDescriptor(saml.HTTPPostBinding, "javascript:SYNTHETIC_PRIVATE", "")},+ {"credentialled endpoint", "urn:synthetic:idp", samlDiagnosticDescriptor(saml.HTTPPostBinding, "https://synthetic:[email protected]/sso", "")},+ {"blank endpoint", "urn:synthetic:idp", samlDiagnosticDescriptor(saml.HTTPPostBinding, " 	", "")},+ } {+ t.Run(tt.name, func(t *testing.T) {+ result := (&Router{}).testSAMLConnection(t.Context(), &SAMLTestConfig{+ IDPMetadataXML: samlDiagnosticMetadata(tt.entity, tt.descriptor),+ // A manual fallback must not conceal unusable selected metadata.+ IDPSSOURL: "https://manual.example.test/sso",+ })+ require.False(t, result.Success)+ require.Equal(t, "metadata_incomplete", result.Error)+ require.Nil(t, result.Details, "incomplete evidence must not be presented as validated details")+ require.Contains(t, result.Message, "test again")+ require.Contains(t, result.Message, "Sign-in has not been tested.")+ require.NotContains(t, result.Message, "SYNTHETIC_PRIVATE")+ })+ }+}++// Certificates remain diagnostic information, not a new trust or sign-in gate.+// An actual sign-in still verifies the assertion through the existing service.+func TestSAMLConnectionLabelsPartialEvidence(t *testing.T) {+ const endpoint = "https://idp.example.test/Case/Sso?tenant=synthetic"+ for _, binding := range []string{saml.HTTPRedirectBinding, saml.HTTPPostBinding} {+ for _, wrapper := range []bool{false, true} {+ t.Run(fmt.Sprintf("%s/wrapped=%t", binding, wrapper), func(t *testing.T) {+ xml := samlDiagnosticMetadata("urn:Synthetic:IdP", samlDiagnosticDescriptor(binding, endpoint, ""))+ if wrapper {+ xml = `<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata">` + xml + `</EntitiesDescriptor>`+ }+ result := (&Router{}).testSAMLConnection(t.Context(), &SAMLTestConfig{IDPMetadataXML: xml})+ require.True(t, result.Success)+ require.Empty(t, result.Error)+ require.Equal(t, "SAML metadata includes an IdP identity and an SSO URL. Sign-in has not been tested.", result.Message)+ require.Equal(t, "urn:Synthetic:IdP", result.Details.EntityID)+ require.Equal(t, endpoint, result.Details.SSOURL, "do not rewrite opaque identity or endpoint path/query")+ require.Empty(t, result.Details.Certificates)+ })+ }+ }+ for _, cert := range []string{"", "synthetic-not-a-certificate"} {+ t.Run("manual/"+cert, func(t *testing.T) {+ result := (&Router{}).testSAMLConnection(t.Context(), &SAMLTestConfig{IDPSSOURL: endpoint, IDPCertificate: cert})+ require.True(t, result.Success)+ require.Equal(t, endpoint, result.Details.SSOURL)+ require.Equal(t, "Only the SAML SSO URL format was checked. Certificates and sign-in have not been tested.", result.Message)+ require.Empty(t, result.Details.Certificates, "manual certificate remains untested, not invented evidence")+ })+ }+}++func TestSAMLConnectionPreservesCertificateInformation(t *testing.T) {+ key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)+ require.NoError(t, err)+ before, after := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), time.Date(2001, 1, 1, 0, 0, 0, 0, time.UTC)+ cert := &x509.Certificate{SerialNumber: big.NewInt(1), Subject: pkix.Name{CommonName: "Synthetic IdP"}, NotBefore: before, NotAfter: after, KeyUsage: x509.KeyUsageDigitalSignature}+ der, err := x509.CreateCertificate(rand.Reader, cert, cert, &key.PublicKey, key)+ require.NoError(t, err)+ keys := `<KeyDescriptor use="signing"><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><X509Data><X509Certificate>` + base64.StdEncoding.EncodeToString(der) + `</X509Certificate></X509Data></KeyInfo></KeyDescriptor>`+ result := (&Router{}).testSAMLConnection(t.Context(), &SAMLTestConfig{IDPMetadataXML: samlDiagnosticMetadata("urn:synthetic:idp", samlDiagnosticDescriptor(saml.HTTPRedirectBinding, "https://idp.example.test/sso", keys))})+ require.True(t, result.Success, "certificate expiry is reported, not a new diagnostic gate")+ require.Contains(t, result.Message, "Sign-in has not been tested.")+ require.Len(t, result.Details.Certificates, 1)+ require.Equal(t, "CN=Synthetic IdP", result.Details.Certificates[0].Subject)+ require.Equal(t, before, result.Details.Certificates[0].NotBefore)+ require.Equal(t, after, result.Details.Certificates[0].NotAfter)+ require.True(t, result.Details.Certificates[0].IsExpired)++ // Manual malformed certificates still fail in actual service setup; the+ // format-only diagnostic must neither claim nor attempt that validation.+ bad := &SAMLTestConfig{IDPSSOURL: "https://idp.example.test/sso", IDPCertificate: string(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: []byte("invalid")}))}+ require.True(t, (&Router{}).testSAMLConnection(t.Context(), bad).Success)+ _, err = NewSAMLService(t.Context(), "synthetic", &config.SAMLProviderConfig{IDPSSOURL: bad.IDPSSOURL, IDPCertificate: bad.IDPCertificate}, "https://pulse.example.test")+ require.Error(t, err, "the actual service must still refuse malformed manual certificate data")+}++func TestSAMLConnectionKeepsFailureCategories(t *testing.T) {+ for _, tt := range []struct {+ name string+ cfg *SAMLTestConfig+ code string+ }{+ {"missing config", nil, "missing_config"},+ {"missing metadata", &SAMLTestConfig{}, "missing_metadata"},+ {"invalid metadata URL", &SAMLTestConfig{IDPMetadataURL: "javascript:synthetic"}, "invalid_url"},+ {"invalid XML", &SAMLTestConfig{IDPMetadataXML: "not XML"}, "parse_failed"},+ {"invalid manual URL", &SAMLTestConfig{IDPSSOURL: "javascript:synthetic"}, "invalid_url"},+ {"invalid SLO URL", &SAMLTestConfig{IDPSSOURL: "https://idp.example.test/sso", IDPSLOURL: "javascript:synthetic"}, "invalid_url"},+ } {+ t.Run(tt.name, func(t *testing.T) {+ response := (&Router{}).testSAMLConnection(t.Context(), tt.cfg)+ require.False(t, response.Success)+ require.Equal(t, tt.code, response.Error)+ require.Nil(t, response.Details)+ })+ }+}++func TestSAMLConnectionKeepsMetadataTLSVerification(t *testing.T) {+ var requests atomic.Int32+ server := newIPv4TLSServer(t, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {+ requests.Add(1)+ _, _ = w.Write([]byte(testSAMLMetadata))+ }))+ defer server.Close()+ result := (&Router{}).testSAMLConnection(t.Context(), &SAMLTestConfig{IDPMetadataURL: server.URL})+ require.False(t, result.Success)+ require.Equal(t, "fetch_failed", result.Error)+ require.Nil(t, result.Details)+ require.Zero(t, requests.Load(), "an untrusted TLS certificate must be refused before the metadata handler")+}