Skip to content

Commit 6d961d6

Browse files
author
OpenShift Bot
authored
Merge pull request #14634 from jim-minter/issue14627
Merged by openshift-bot
2 parents a3e6820 + 32bda49 commit 6d961d6

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed

pkg/cmd/server/bootstrappolicy/controller_policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func init() {
121121

122122
// template-instance-controller
123123
controllerRoleBindings = append(controllerRoleBindings,
124-
rbac.NewClusterBinding(EditRoleName).SAs(DefaultOpenShiftInfraNamespace, InfraTemplateInstanceControllerServiceAccountName).BindingOrDie())
124+
rbac.NewClusterBinding(AdminRoleName).SAs(DefaultOpenShiftInfraNamespace, InfraTemplateInstanceControllerServiceAccountName).BindingOrDie())
125125

126126
// origin-namespace-controller
127127
addControllerRole(rbac.ClusterRole{

pkg/template/servicebroker/catalog.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import (
1515
)
1616

1717
const (
18-
namespaceTitle = "Template service broker: namespace"
19-
namespaceDescription = "OpenShift namespace in which to provision service"
20-
2118
// the following should go away with catalog<->broker support for passing
2219
// identity information.
2320
requesterUsernameTitle = "Template service broker: requester username"

pkg/template/servicebroker/test-scripts/provision.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ req="{
1414
\"parameters\": {
1515
\"MYSQL_USER\": \"username\",
1616
\"template.openshift.io/requester-username\": \"$requesterUsername\"
17-
},
18-
\"accepts_incomplete\": true
17+
}
1918
}"
2019

2120
curl \
@@ -25,4 +24,4 @@ curl \
2524
-d "$req" \
2625
-v \
2726
$curlargs \
28-
$endpoint/v2/service_instances/$instanceUUID
27+
$endpoint/v2/service_instances/$instanceUUID'?accepts_incomplete=true'

test/extended/templates/templateinstance_security.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import (
99
kerrors "k8s.io/apimachinery/pkg/api/errors"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
"k8s.io/apimachinery/pkg/runtime"
12+
"k8s.io/apimachinery/pkg/runtime/schema"
1213
"k8s.io/apimachinery/pkg/util/wait"
1314
kapi "k8s.io/kubernetes/pkg/api"
1415
kapiv1 "k8s.io/kubernetes/pkg/api/v1"
16+
"k8s.io/kubernetes/pkg/apis/storage"
17+
storagev1 "k8s.io/kubernetes/pkg/apis/storage/v1"
1518

1619
"github.com/openshift/origin/pkg/api/latest"
1720
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
@@ -54,6 +57,13 @@ var _ = g.Describe("[templates] templateinstance security tests", func() {
5457
Name: bootstrappolicy.AdminRoleName,
5558
},
5659
}
60+
61+
storageclass = &storage.StorageClass{
62+
ObjectMeta: metav1.ObjectMeta{
63+
Name: "storageclass",
64+
},
65+
Provisioner: "no-provisioning",
66+
}
5767
)
5868

5969
g.BeforeEach(func() {
@@ -98,7 +108,7 @@ var _ = g.Describe("[templates] templateinstance security tests", func() {
98108
},
99109
},
100110
{
101-
by: "checking edituser can't create a privileged object",
111+
by: "checking edituser can't create an object that requires admin",
102112
user: edituser,
103113
namespace: cli.Namespace(),
104114
objects: []runtime.Object{dummyrolebinding},
@@ -109,21 +119,32 @@ var _ = g.Describe("[templates] templateinstance security tests", func() {
109119
},
110120
},
111121
{
112-
// at the moment, an admin cannot create a privileged object
113-
// via the template instance controller as the latter only has
114-
// global edit permissions.
115-
by: "checking adminuser can't create a privileged object",
122+
by: "checking adminuser can't create an object that requires admin",
116123
user: adminuser,
117124
namespace: cli.Namespace(),
118125
objects: []runtime.Object{dummyrolebinding},
119-
expectCondition: templateapi.TemplateInstanceInstantiateFailure,
126+
expectCondition: templateapi.TemplateInstanceReady,
120127
checkOK: func(namespace string) bool {
121128
_, err := cli.AdminClient().RoleBindings(namespace).Get(dummyrolebinding.Name, metav1.GetOptions{})
129+
return err == nil
130+
},
131+
},
132+
{
133+
by: "checking adminuser can't create an object that requires more than admin",
134+
user: adminuser,
135+
namespace: cli.Namespace(),
136+
objects: []runtime.Object{storageclass},
137+
expectCondition: templateapi.TemplateInstanceInstantiateFailure,
138+
checkOK: func(namespace string) bool {
139+
_, err := cli.AdminKubeClient().StorageV1().StorageClasses().Get(storageclass.Name, metav1.GetOptions{})
122140
return err != nil && kerrors.IsNotFound(err)
123141
},
124142
},
125143
}
126144

145+
targetVersions := []schema.GroupVersion{storagev1.SchemeGroupVersion}
146+
targetVersions = append(targetVersions, latest.Versions...)
147+
127148
for _, test := range tests {
128149
g.By(test.by)
129150
cli.ChangeUser(test.user.Name)
@@ -161,7 +182,7 @@ var _ = g.Describe("[templates] templateinstance security tests", func() {
161182
},
162183
}
163184

164-
err = templateapi.AddObjectsToTemplate(&templateinstance.Spec.Template, test.objects, latest.Versions...)
185+
err = templateapi.AddObjectsToTemplate(&templateinstance.Spec.Template, test.objects, targetVersions...)
165186
o.Expect(err).NotTo(o.HaveOccurred())
166187

167188
templateinstance, err = cli.TemplateClient().Template().TemplateInstances(cli.Namespace()).Create(templateinstance)

test/integration/authorization_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,12 @@ func TestAuthorizationResourceAccessReview(t *testing.T) {
635635
Users: sets.NewString("edgar"),
636636
Groups: sets.NewString(),
637637
Namespace: "mallet-project",
638-
EvaluationError: `role.authorization.openshift.io "admin" not found`,
638+
EvaluationError: `[role.authorization.openshift.io "admin" not found, role.authorization.openshift.io "admin" not found]`,
639639
},
640640
}
641641
test.response.Users.Insert(globalClusterReaderUsers.List()...)
642642
test.response.Users.Insert(globalDeploymentConfigGetterUsers.List()...)
643+
test.response.Users.Delete("system:serviceaccount:openshift-infra:template-instance-controller")
643644
test.response.Groups.Insert(globalClusterReaderGroups.List()...)
644645
test.run(t)
645646
}

test/testdata/bootstrappolicy/bootstrap_cluster_role_bindings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ items:
727727
kind: ClusterRoleBinding
728728
metadata:
729729
creationTimestamp: null
730-
name: edit
730+
name: admin
731731
roleRef:
732-
name: edit
732+
name: admin
733733
subjects:
734734
- kind: ServiceAccount
735735
name: template-instance-controller

0 commit comments

Comments
 (0)