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.

Ignore bearer token in security status

rcourtmancb788f18b936
diff --git a/internal/api/security_status_additional_test.go b/internal/api/security_status_additional_test.go
index 27a3b95cce..9a7c71a6fc 100644
--- a/internal/api/security_status_additional_test.go
+++ b/internal/api/security_status_additional_test.go
@@ -33,3 +33,30 @@ func TestSecurityStatusIgnoresInvalidTokenHeader(t *testing.T) {
t.Fatalf("expected tokenScopes to be omitted for invalid token")
}
}
+
+func TestSecurityStatusIgnoresBearerTokenHeader(t *testing.T) {
+ rawToken := "status-bearer-token-123.12345678"
+ record := newTokenRecord(t, rawToken, nil, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodGet, "/api/security/status", nil)
+ req.Header.Set("Authorization", "Bearer "+rawToken)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("expected 200 for security status, got %d", rec.Code)
+ }
+
+ var payload map[string]interface{}
+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {
+ t.Fatalf("decode response: %v", err)
+ }
+ if hint, ok := payload["apiTokenHint"].(string); ok && hint != "" {
+ t.Fatalf("expected apiTokenHint to be empty for bearer token, got %q", hint)
+ }
+ if _, ok := payload["tokenScopes"]; ok {
+ t.Fatalf("expected tokenScopes to be omitted for bearer token")
+ }
+}