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.

Block proxy non-admin password changes

rcourtman0867490ae091
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index a60c28134c..8c221d79d0 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -323,6 +323,26 @@ func TestChangePasswordRequiresAuthInAPIMode(t *testing.T) {
}
}
+func TestChangePasswordRejectsProxyNonAdmin(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")
+
+ req := httptest.NewRequest(http.MethodPost, "/api/security/change-password", strings.NewReader(`{}`))
+ 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 password change, got %d", rec.Code)
+ }
+}
+
func TestResetLockoutRequiresAuthInAPIMode(t *testing.T) {
record := newTokenRecord(t, "reset-lockout-token-123.12345678", []string{config.ScopeSettingsWrite}, nil)
cfg := newTestConfigWithTokens(t, record)