Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/webhooks/regularuser/common/regularuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ var (
"system:serviceaccount:openshift-cluster-node-tuning-operator:cluster-node-tuning-operator",
"system:serviceaccount:openshift-machine-config-operator:machine-config-controller",
"system:admin",
// The OpenShift Sandboxed Containers operator creates/modifies MachineConfig
// resources when a KataConfig is reconciled. Its CSV currently runs the
// controller as the `default` ServiceAccount in the fixed
// `openshift-sandboxed-containers-operator` namespace, so this entry matches
// the complete Kubernetes identity (namespace + ServiceAccount) and does not
// wildcard other namespaces or service accounts. A future dedicated OSC
// ServiceAccount may coexist with this entry; remove it only once no
// supported OSC version still relies on this identity.
"system:serviceaccount:openshift-sandboxed-containers-operator:default",
}
ceeGroup = "system:serviceaccounts:openshift-backplane-cee"

Expand Down
38 changes: 38 additions & 0 deletions pkg/webhooks/regularuser/common/regularuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,44 @@ func TestMachineConfig(t *testing.T) {
operation: admissionv1.Create,
shouldBeAllowed: false,
},
{
// OSC operator uses the `default` SA in the fixed
// openshift-sandboxed-containers-operator namespace (ROSAENG-61186).
testID: "machineconfig-osc-serviceaccount",
targetResource: "machineconfigs",
targetKind: "MachineConfig",
targetVersion: "v1",
targetGroup: "machineconfiguration.openshift.io",
username: "system:serviceaccount:openshift-sandboxed-containers-operator:default",
userGroups: []string{"system:authenticated", "system:serviceaccounts", "system:serviceaccounts:openshift-sandboxed-containers-operator"},
operation: admissionv1.Create,
shouldBeAllowed: true,
},
{
// The exception is scoped to the exact identity: the same `default` SA
// in a different namespace must remain denied.
testID: "machineconfig-osc-serviceaccount-wrong-namespace",
targetResource: "machineconfigs",
targetKind: "MachineConfig",
targetVersion: "v1",
targetGroup: "machineconfiguration.openshift.io",
username: "system:serviceaccount:some-other-namespace:default",
userGroups: []string{"system:authenticated", "system:serviceaccounts", "system:serviceaccounts:some-other-namespace"},
operation: admissionv1.Create,
shouldBeAllowed: false,
},
{
// A different SA within the OSC namespace must remain denied.
testID: "machineconfig-osc-serviceaccount-wrong-sa",
targetResource: "machineconfigs",
targetKind: "MachineConfig",
targetVersion: "v1",
targetGroup: "machineconfiguration.openshift.io",
username: "system:serviceaccount:openshift-sandboxed-containers-operator:some-other-sa",
userGroups: []string{"system:authenticated", "system:serviceaccounts", "system:serviceaccounts:openshift-sandboxed-containers-operator"},
operation: admissionv1.Create,
shouldBeAllowed: false,
},
}
runRegularuserTests(t, tests)
}
Expand Down