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
test: deny non-admin proxy users on admin endpoints
rcourtmandf4ae9d6390d
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.goindex bd1953d642..b68d4fd5e9 100644--- a/internal/api/security_regression_test.go+++ b/internal/api/security_regression_test.go@@ -1616,6 +1616,56 @@ func TestNotificationsRequireProxyAdmin(t *testing.T) {}}+func TestProxyAuthNonAdminDeniedAdminEndpoints(t *testing.T) {+ cfg := newTestConfigWithTokens(t)+ cfg.ProxyAuthSecret = "proxy-secret"+ cfg.ProxyAuthUserHeader = "X-Remote-User"+ cfg.ProxyAuthRoleHeader = "X-Remote-Roles"+ cfg.ProxyAuthAdminRole = "admin"++ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")++ cases := []struct {+ method string+ path string+ body string+ }{+ {method: http.MethodGet, path: "/api/logs/stream", body: ""},+ {method: http.MethodGet, path: "/api/logs/download", body: ""},+ {method: http.MethodGet, path: "/api/logs/level", body: ""},+ {method: http.MethodPost, path: "/api/logs/level", body: `{}`},+ {method: http.MethodGet, path: "/api/updates/check", body: ""},+ {method: http.MethodPost, path: "/api/updates/apply", body: `{}`},+ {method: http.MethodGet, path: "/api/updates/status", body: ""},+ {method: http.MethodGet, path: "/api/updates/plan", body: ""},+ {method: http.MethodGet, path: "/api/updates/history", body: ""},+ {method: http.MethodGet, path: "/api/updates/history/entry", body: ""},+ {method: http.MethodGet, path: "/api/diagnostics", body: ""},+ {method: http.MethodPost, path: "/api/diagnostics/docker/prepare-token", body: `{}`},+ {method: http.MethodPost, path: "/api/license/activate", body: `{}`},+ {method: http.MethodPost, path: "/api/license/clear", body: `{}`},+ {method: http.MethodGet, path: "/api/license/status", body: ""},+ {method: http.MethodGet, path: "/api/notifications/queue/stats", body: ""},+ {method: http.MethodGet, path: "/api/notifications/", body: ""},+ }++ for _, tc := range cases {+ req := httptest.NewRequest(tc.method, tc.path, strings.NewReader(tc.body))+ req.Header.Set("X-Proxy-Secret", cfg.ProxyAuthSecret)+ req.Header.Set("X-Remote-User", "viewer-user")+ req.Header.Set("X-Remote-Roles", "viewer")+ rec := httptest.NewRecorder()+ router.Handler().ServeHTTP(rec, req)++ if rec.Code != http.StatusForbidden {+ t.Fatalf("expected 403 for non-admin proxy user on %s %s, got %d", tc.method, tc.path, rec.Code)+ }+ if !strings.Contains(rec.Body.String(), "Admin privileges required") {+ t.Fatalf("expected admin privilege error on %s %s, got %q", tc.method, tc.path, rec.Body.String())+ }+ }+}+func TestDockerAgentEndpointsRequireDockerReportScope(t *testing.T) {rawToken := "docker-report-token-123.12345678"record := newTokenRecord(t, rawToken, []string{config.ScopeMonitoringRead}, nil)