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.

Require auth for admin endpoints with OIDC

rcourtman313df78cf784
diff --git a/internal/api/oidc_admin_auth_test.go b/internal/api/oidc_admin_auth_test.go
new file mode 100644
index 0000000000..7014c75402
--- /dev/null
+++ b/internal/api/oidc_admin_auth_test.go
@@ -0,0 +1,41 @@
+package api
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
+)
+
+func TestAdminEndpointsRequireAuthWhenOIDCEnabled(t *testing.T) {
+ t.Setenv("ALLOW_ADMIN_BYPASS", "")
+ t.Setenv("PULSE_DEV", "")
+ t.Setenv("NODE_ENV", "")
+ resetAdminBypassState()
+
+ dataDir := t.TempDir()
+ cfg := &config.Config{
+ DataPath: dataDir,
+ ConfigPath: dataDir,
+ OIDC: &config.OIDCConfig{
+ Enabled: true,
+ },
+ }
+
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ paths := []string{
+ "/api/system/settings",
+ "/api/diagnostics",
+ }
+
+ for _, path := range paths {
+ req := httptest.NewRequest(http.MethodGet, path, nil)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusUnauthorized {
+ t.Fatalf("expected 401 without auth for %s, got %d", path, rec.Code)
+ }
+ }
+}