Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9564be6
docs(specs): spec 030 implementation briefs and open decisions OD-7..…
claude Nov 15, 2026
9402741
docs(specs): spec 030 per-cluster root setting (OD-7..OD-9), raise OD-10
claude Nov 15, 2026
bb3ac77
docs(specs): spec 030 settle OD-10 (remote control-plane namespace on…
claude Nov 15, 2026
5c3511f
feat(operator): security override, status and cluster namespace CRD f…
claude Nov 15, 2026
295abe1
feat(api): servers:security permission and security override messages
claude Nov 15, 2026
e9bd7e0
feat(api): field-level check for server security overrides
claude Nov 15, 2026
c590362
feat(operator): resolve module security defaults and per-server overr…
claude Nov 15, 2026
bfe860b
feat(api): shape validation for server security overrides
claude Nov 15, 2026
223ce39
feat(gp-module): validate and preview template security settings
claude Nov 15, 2026
a3f70df
test(mcp-server): security fields round-trip through read-only tools
claude Nov 15, 2026
b56cead
docs(specs): spec 030 mark US1 and US2 backend tasks done
claude Nov 15, 2026
8c62282
feat(operator): hold root-override servers while the cluster disallow…
claude Nov 15, 2026
5132a01
feat(api): per-cluster allow-root setting, root rule and security audit
claude Nov 15, 2026
cb38a96
feat(chart): Helm-created security settings ConfigMap and narrow API …
claude Nov 15, 2026
49394cd
test(e2e): security override restart, root hold and API permission tests
claude Nov 15, 2026
9b846c9
docs: server security overrides and per-cluster allow-root setting
claude Nov 15, 2026
186f359
fix(chart): grant the security settings ConfigMap through its own Role
claude Nov 15, 2026
7d9cd3e
fix(operator): keep the template fsGroup for backups of pre-030 servers
claude Nov 15, 2026
4eb4cbc
fix(gp-module): guard the uint64 conversion and match the aligned pre…
claude Nov 15, 2026
82c9505
fix(chart): no security settings objects on standalone panels
claude Nov 15, 2026
b7fb4f0
fix(api): name the missing settings message server.cluster.security_s…
claude Nov 15, 2026
c0ecc73
test(e2e): close every response in the security override API test
claude Nov 15, 2026
d8e80da
test(e2e): drop the unused body of the switch-off call
claude Nov 15, 2026
f02003d
test(api): build security settings requests with a context
claude Nov 15, 2026
a922023
fix(operator): lint fixes for security source docs and the patch call
claude Nov 15, 2026
d050c39
fix(api): record the clone security row with the 200 the clone returns
claude Nov 15, 2026
b2974bf
fix(operator): keep only the run-as identity on a running workload
claude Nov 16, 2026
f948e48
fix(operator): take desired security values when the workload profile…
claude Nov 16, 2026
a5d6502
test(e2e): name the game container for id checks and send resourceVer…
claude Nov 16, 2026
d0acd35
docs(specs): spec 030 corrections for standalone panels and the missi…
claude Nov 16, 2026
84e57ee
chore: bump modules for spec 030
claude Nov 17, 2026
9c2c440
Merge origin/master into feat/030-security-context-overrides
claude Nov 22, 2026
c37b910
design: spec 030 security overrides in design.fig
claude Nov 22, 2026
12d94b2
docs: changelog entry for spec 030 security overrides
claude Nov 22, 2026
9d4946c
docs(specs): tick T003 design for spec 030
claude Nov 22, 2026
1c11055
feat(web): security overrides in wizard, server settings and cluster …
claude Nov 22, 2026
5dfe125
fix(web): block the wizard on invalid security input and omit the def…
claude Nov 22, 2026
033af08
test(web): cover security overrides, cluster security panel and names…
claude Nov 22, 2026
95e7673
docs(specs): tick spec 030 web tasks
claude Nov 22, 2026
9ca5a70
Merge remote-tracking branch 'origin/master' into feat/030-security-c…
claude Nov 22, 2026
6255af2
docs: spec 030 behaviour in specs.md files and the agent task map
claude Nov 22, 2026
4b22881
Merge remote-tracking branch 'origin/master' into feat/030-security-c…
claude Nov 23, 2026
9ec820d
design: re-apply spec 030 security frames on master's design.fig
claude Nov 23, 2026
aaac587
test(operator): widen the envtest Service IP range to a /16
claude Nov 23, 2026
b4d7cc2
Merge remote-tracking branch 'origin/master' into feat/030-security-c…
claude Nov 23, 2026
4c5a3b2
fix(operator): keep pending fsGroup overrides out of pre-030 backups
claude Nov 23, 2026
1c0271d
fix(api): audit risky marks from the pinned template revision
claude Nov 23, 2026
47831ca
fix(web): drop wizard security overrides when the template changes
claude Nov 23, 2026
77fff9f
fix(i18n): add French cluster security and control-plane strings
claude Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions api/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ func main() {
logger.Warn("oidc disabled", "err", err)
}
credentialsNS, moduleConfigMapNS := cfg.managementNamespaces()
// The security settings ConfigMap of the home cluster lives here (the
// operator's control-plane namespace). Remote clusters use their own.
reg.SetControlPlaneNamespace(moduleConfigMapNS)
authRegistry := auth.NewRegistry(store,
auth.NewK8sSecretReader(k8s, credentialsNS), oidcAuth, cfg.oidcDisplayName, helmPolicy)

Expand Down Expand Up @@ -406,12 +409,12 @@ func main() {
p.Use(sessions.RevalidateStreams(isStreamingRequest, 5*time.Second, rbac.StreamGrantValidator(reg)))
}

handlers.MountResources(p, reg, store)
handlers.MountResources(p, reg, store, auditor)
handlers.MountFleet(p, reg, store)
handlers.MountNamespaces(p, reg)
handlers.MountPodEvents(p, reg)
handlers.MountPods(p, reg, cfg.namespace)
handlers.MountLifecycle(p, reg)
handlers.MountLifecycle(p, reg, auditor)
handlers.MountShareLinks(p, reg, store)
handlers.MountOwnership(p, reg, store)
handlers.MountUsers(p, store, sessions, reg)
Expand All @@ -420,6 +423,7 @@ func main() {
telemetrySettings := handlers.TelemetrySettings{Dest: telemetryDest, Interval: cfg.telemetryInterval, Deps: telemetryDeps}
handlers.MountConfigWithTelemetry(p, store, auditor, oidcAuth != nil, cfg.gameDataStorageClass, helmPolicy, telemetrySettings)
handlers.MountTelemetry(p, store, telemetrySettings)
handlers.MountSecuritySettings(p, reg, auditor)
handlers.MountNotifications(p, notifier, k8s, credentialsNS)
handlers.MountAuthProviderSecrets(p, k8s, credentialsNS)
handlers.MountCluster(p, reg, store, Version, cfg.clusterOps, cfg.updateChannel)
Expand Down
44 changes: 38 additions & 6 deletions api/internal/handlers/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,22 @@ type clusterRegistryView struct {
Message string `json:"message,omitempty"`
ServerVersion string `json:"serverVersion,omitempty"`
LastCheckTime string `json:"lastCheckTime,omitempty"`
// ControlPlaneNamespace is the operator control-plane namespace of the
// remote install, where its security settings ConfigMap lives (spec 030, OD-10 A).
ControlPlaneNamespace string `json:"controlPlaneNamespace,omitempty"`
}

type clusterCreateReq struct {
Name string `json:"name"`
DisplayName string `json:"displayName"`
Kubeconfig string `json:"kubeconfig"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Kubeconfig string `json:"kubeconfig"`
ControlPlaneNamespace string `json:"controlPlaneNamespace,omitempty"`
}

// defaultClusterControlPlaneNamespace is recorded when a registration names no
// control-plane namespace.
const defaultClusterControlPlaneNamespace = "gameplane"

type clustersListResp struct {
Items []clusterRegistryView `json:"items"`
}
Expand Down Expand Up @@ -153,6 +161,10 @@ func (h clustersHandler) list(w http.ResponseWriter, req *http.Request) {
}
item := clusterRegistryView{Name: id, CanViewInventory: u.Can("cluster:read", true, id, "")}
item.DisplayName, _, _ = unstructured.NestedString(registration.Object, "spec", "displayName")
item.ControlPlaneNamespace, _, _ = unstructured.NestedString(registration.Object, "spec", "controlPlaneNamespace")
if item.ControlPlaneNamespace == "" {
item.ControlPlaneNamespace = defaultClusterControlPlaneNamespace
}
item.Phase, _, _ = unstructured.NestedString(registration.Object, "status", "phase")
if item.CanViewInventory {
item.Message, _, _ = unstructured.NestedString(registration.Object, "status", "message")
Expand Down Expand Up @@ -188,6 +200,18 @@ func (h clustersHandler) create(w http.ResponseWriter, req *http.Request) {
return
}

// The control-plane namespace is a Kubernetes namespace name, so it must be
// a DNS label. Empty means the default install namespace.
controlPlaneNS := in.ControlPlaneNamespace
if controlPlaneNS == "" {
controlPlaneNS = defaultClusterControlPlaneNamespace
}
if !dnsLabelRE.MatchString(controlPlaneNS) {
httperr.WriteCode(w, req, http.StatusBadRequest,
errors.New("controlPlaneNamespace must be a DNS label (lowercase, digits, hyphens)"))
return
}

// Validate kubeconfig.
if in.Kubeconfig == "" {
httperr.WriteCode(w, req, http.StatusBadRequest,
Expand Down Expand Up @@ -235,6 +259,13 @@ func (h clustersHandler) create(w http.ResponseWriter, req *http.Request) {
},
},
}
// Only an explicit value is written; the CRD default supplies "gameplane"
// otherwise, so a registration without the field keeps its old shape.
if in.ControlPlaneNamespace != "" {
if spec, ok := clusterCR.Object["spec"].(map[string]any); ok {
spec["controlPlaneNamespace"] = in.ControlPlaneNamespace
}
}
if h.k.RegisterCluster != nil {
_, err = h.k.RegisterCluster(req.Context(), h.namespace, secret, clusterCR)
} else if h.k.IsStandalone() {
Expand All @@ -252,9 +283,10 @@ func (h clustersHandler) create(w http.ResponseWriter, req *http.Request) {
}

writeJSONCreated(w, clusterRegistryView{
Name: in.Name,
DisplayName: in.DisplayName,
Phase: "", // Will be populated by the operator
Name: in.Name,
DisplayName: in.DisplayName,
Phase: "", // Will be populated by the operator
ControlPlaneNamespace: controlPlaneNS,
})
}

Expand Down
24 changes: 21 additions & 3 deletions api/internal/handlers/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"github.com/GameplanePanel/gameplane/api/internal/audit"
"github.com/GameplanePanel/gameplane/api/internal/httperr"
"github.com/GameplanePanel/gameplane/api/internal/kube"
"github.com/GameplanePanel/gameplane/api/internal/messages"
Expand All @@ -37,12 +38,15 @@ const idleWakeRequestedAnnotation = "gameplane.local/idle-wake-requested"
// reconciles the rest). Restart and wake are single stamped annotations the
// operator acks: it owns the whole transition, so the request can't be
// lost the way a client-issued suspend/resume patch pair can (rule 10).
func MountLifecycle(r chi.Router, reg *kube.Registry) {
//
// auditor is optional: clone writes the security row of a copied spec.security
// when it is set (contracts/audit-events.md).
func MountLifecycle(r chi.Router, reg *kube.Registry, auditor ...*audit.Auditor) {
r.Post("/servers/{name}:start", patchSuspend(reg, false))
r.Post("/servers/{name}:stop", patchSuspend(reg, true))
r.Post("/servers/{name}:restart", restartHandler(reg))
r.Post("/servers/{name}:wake", wakeHandler(reg))
r.Post("/servers/{name}:clone", cloneHandler(reg))
r.Post("/servers/{name}:clone", cloneHandler(reg, firstAuditor(auditor)))
r.Post("/servers/{name}:wipe-data", wipeDataHandler(reg))
}

Expand Down Expand Up @@ -193,7 +197,7 @@ type cloneReq struct {
NewName string `json:"newName"`
}

func cloneHandler(reg *kube.Registry) http.HandlerFunc {
func cloneHandler(reg *kube.Registry, auditor *audit.Auditor) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
k, ok := resolveCluster(w, req, reg)
if !ok {
Expand Down Expand Up @@ -245,14 +249,28 @@ func cloneHandler(reg *kube.Registry) http.HandlerFunc {

cl := scope.RequestedCluster(req)
if err := validateAndProtectGameServer(req.Context(), k, cl, ns, body.NewName, clone, nil); err != nil {
writeSecurityRefusal(req, auditor, body.NewName, err)
writeServerValidationError(w, req, err)
return
}
if err := validateSecurityRootRule(req.Context(), reg, cl, clone, nil); err != nil {
writeSecurityRefusal(req, auditor, body.NewName, err)
writeServerValidationError(w, req, err)
return
}
// A clone reads as a create: its security row has an empty before.
changeReason := securityChangeReason(req.Context(), k, clone, nil)
if !writeSecurityChange(w, req, auditor, body.NewName, changeReason, http.StatusOK) {
return
}

created, err := k.Dynamic.Resource(kube.GVRs["servers"]).
Namespace(ns).
Create(req.Context(), clone, metav1.CreateOptions{})
if err != nil {
if changeReason != "" {
writeSecuritySaveFailed(req, auditor, body.NewName, err)
}
httperr.Write(w, req, err)
return
}
Expand Down
52 changes: 45 additions & 7 deletions api/internal/handlers/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"

"github.com/GameplanePanel/gameplane/api/internal/audit"
"github.com/GameplanePanel/gameplane/api/internal/auth"
"github.com/GameplanePanel/gameplane/api/internal/db"
"github.com/GameplanePanel/gameplane/api/internal/httperr"
Expand All @@ -48,21 +49,25 @@ const heartbeatStaleTTL = 60 * time.Second
// handler resolves its target cluster per request from reg via the
// `?cluster=` selector (resolveCluster) — a request with no selector
// resolves to scope.DefaultCluster, preserving single-cluster behavior.
func MountResources(r chi.Router, reg *kube.Registry, store *db.Store) {
//
// auditor is optional: when set, saves that change spec.security write their
// security rows (contracts/audit-events.md). A nil or absent auditor writes none.
func MountResources(r chi.Router, reg *kube.Registry, store *db.Store, auditor ...*audit.Auditor) {
a := firstAuditor(auditor)
for path, gvr := range kube.GVRs {
mountOne(r, reg, store, path, gvr)
mountOne(r, reg, store, a, path, gvr)
}
}

func mountOne(r chi.Router, reg *kube.Registry, store *db.Store, path string, gvr schema.GroupVersionResource) {
func mountOne(r chi.Router, reg *kube.Registry, store *db.Store, auditor *audit.Auditor, path string, gvr schema.GroupVersionResource) {
r.Route("/"+path, func(r chi.Router) {
r.Get("/", listHandler(reg, gvr))
r.Post("/", createHandler(reg, gvr))
r.Post("/", createHandler(reg, gvr, auditor))
r.Get("/{name}", getHandler(reg, gvr))
if path == "servers" {
r.Get("/{name}/template", effectiveTemplateHandler(reg))
}
r.Put("/{name}", updateHandler(reg, gvr))
r.Put("/{name}", updateHandler(reg, gvr, auditor))
r.Delete("/{name}", deleteHandler(reg, store, gvr))
})
}
Expand Down Expand Up @@ -219,7 +224,7 @@ func getHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.Handle
}
}

func createHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.HandlerFunc {
func createHandler(reg *kube.Registry, gvr schema.GroupVersionResource, auditor *audit.Auditor) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
k, ok := resolveCluster(w, req, reg)
if !ok {
Expand Down Expand Up @@ -249,18 +254,32 @@ func createHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.Han
return
}
obj.SetNamespace(ns)
var changeReason string
if gvr.Resource == "gameservers" {
cl := scope.RequestedCluster(req)
if err := validateAndProtectGameServer(req.Context(), k, cl, ns, obj.GetName(), obj, nil); err != nil {
writeSecurityRefusal(req, auditor, obj.GetName(), err)
writeServerValidationError(w, req, err)
return
}
if err := validateSecurityRootRule(req.Context(), reg, cl, obj, nil); err != nil {
writeSecurityRefusal(req, auditor, obj.GetName(), err)
writeServerValidationError(w, req, err)
return
}
if err := newConfigRuleCache(k).protectUnpinnedConfig(req.Context(), obj, nil); err != nil {
writeServerValidationError(w, req, err)
return
}
changeReason = securityChangeReason(req.Context(), k, obj, nil)
}
if !writeSecurityChange(w, req, auditor, obj.GetName(), changeReason, http.StatusCreated) {
return
}
created, err = k.Dynamic.Resource(gvr).Namespace(ns).Create(req.Context(), obj, metav1.CreateOptions{})
if err != nil && changeReason != "" {
writeSecuritySaveFailed(req, auditor, obj.GetName(), err)
}
}
if err != nil {
httperr.Write(w, req, err)
Expand All @@ -276,7 +295,7 @@ func createHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.Han
}
}

func updateHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.HandlerFunc {
func updateHandler(reg *kube.Registry, gvr schema.GroupVersionResource, auditor *audit.Auditor) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
k, ok := resolveCluster(w, req, reg)
if !ok {
Expand Down Expand Up @@ -305,6 +324,7 @@ func updateHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.Han
// provider's credential — so it is declared outside this block.
var live *unstructured.Unstructured
var cfgRules *configRuleCache
var changeReason string
if gvr.Resource == "gameservers" {
ns, ok := resolveNS(w, req)
if !ok {
Expand All @@ -324,13 +344,20 @@ func updateHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.Han
writeRules := restoreRedactedConfig(req.Context(), cfgRules, obj, live)
cl := scope.RequestedCluster(req)
if err := validateAndProtectGameServer(req.Context(), k, cl, ns, name, obj, live); err != nil {
writeSecurityRefusal(req, auditor, name, err)
writeServerValidationError(w, req, err)
return
}
if err := validateSecurityRootRule(req.Context(), reg, cl, obj, live); err != nil {
writeSecurityRefusal(req, auditor, name, err)
writeServerValidationError(w, req, err)
return
}
if err := cfgRules.protectUnpinnedConfig(req.Context(), obj, &writeRules); err != nil {
writeServerValidationError(w, req, err)
return
}
changeReason = securityChangeReason(req.Context(), k, obj, live)
}
var updated *unstructured.Unstructured
if cluster(gvr) {
Expand All @@ -341,7 +368,13 @@ func updateHandler(reg *kube.Registry, gvr schema.GroupVersionResource) http.Han
return
}
obj.SetNamespace(ns)
if !writeSecurityChange(w, req, auditor, name, changeReason, http.StatusOK) {
return
}
updated, err = k.Dynamic.Resource(gvr).Namespace(ns).Update(req.Context(), obj, metav1.UpdateOptions{})
if err != nil && changeReason != "" {
writeSecuritySaveFailed(req, auditor, name, err)
}
if err == nil && gvr.Resource == "gameservers" {
pruneTunnelProviderOnSpecChange(req.Context(), k, ns, name, live, updated)
updated = updated.DeepCopy()
Expand Down Expand Up @@ -629,6 +662,11 @@ func validateAndProtectGameServer(
}
}

// 1b. Validate spec.security field by field (see security_overrides.go).
if err := validateSecurityOverride(ctx, cl, ns, desired, live); err != nil {
return err
}

// 2. Validate spec.serviceAccountName
// A host-capable diagnostic exception must be a separate, synchronously
// audited administrator action. Generic edits may preserve an existing
Expand Down
8 changes: 8 additions & 0 deletions api/internal/handlers/resources_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ var volumeSnapshotGVR = schema.GroupVersionResource{Group: "snapshot.storage.k8s
var errSnapshotSourceUnavailable = errors.New("snapshot data source verification unavailable")

func writeServerValidationError(w http.ResponseWriter, req *http.Request, err error) {
// A localizable message carries its own status (for example 403 for
// server.security.forbidden or 422 for server.security.invalid), so it is
// written as is. Plain errors keep the code chosen below.
var m *httperr.Message
if errors.As(err, &m) {
httperr.WriteMessage(w, req, m)
return
}
code := http.StatusForbidden
if errors.Is(err, errTemplateRefImmutable) {
code = http.StatusConflict
Expand Down
Loading
Loading