Skip to content

Commit f4e6656

Browse files
committed
Revert "router: assign system:auth-delegator role"
This reverts commit 5d7f483.
1 parent 5d7f483 commit f4e6656

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

pkg/cmd/server/bootstrappolicy/policy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ func GetOpenshiftBootstrapClusterRoles() []rbac.ClusterRole {
564564
rbac.NewRule("list", "watch").Groups(kapiGroup).Resources("endpoints").RuleOrDie(),
565565
rbac.NewRule("list", "watch").Groups(kapiGroup).Resources("services").RuleOrDie(),
566566

567+
rbac.NewRule("create").Groups(kAuthnGroup).Resources("tokenreviews").RuleOrDie(),
568+
rbac.NewRule("create").Groups(kAuthzGroup).Resources("subjectaccessreviews").RuleOrDie(),
569+
567570
rbac.NewRule("list", "watch").Groups(routeGroup, legacyRouteGroup).Resources("routes").RuleOrDie(),
568571
rbac.NewRule("update").Groups(routeGroup, legacyRouteGroup).Resources("routes/status").RuleOrDie(),
569572
},

pkg/oc/admin/router/router.go

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -759,20 +759,6 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
759759
Name: "system:router",
760760
},
761761
},
762-
&authapi.ClusterRoleBinding{
763-
ObjectMeta: metav1.ObjectMeta{Name: generateAuthRoleBindingName(cfg.Name)},
764-
Subjects: []kapi.ObjectReference{
765-
{
766-
Kind: "ServiceAccount",
767-
Name: cfg.ServiceAccount,
768-
Namespace: namespace,
769-
},
770-
},
771-
RoleRef: kapi.ObjectReference{
772-
Kind: "ClusterRole",
773-
Name: "system:auth-delegator",
774-
},
775-
},
776762
)
777763

778764
objects = append(objects, &appsapi.DeploymentConfig{
@@ -847,7 +833,7 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
847833

848834
levelPrefixFilter := func(e error) string {
849835
// Avoid failing when service accounts or role bindings already exist.
850-
if ignoreError(e, cfg.ServiceAccount, generateRoleBindingName(cfg.Name), generateAuthRoleBindingName(cfg.Name)) {
836+
if ignoreError(e, cfg.ServiceAccount, generateRoleBindingName(cfg.Name)) {
851837
return "warning"
852838
}
853839
return "error"
@@ -864,9 +850,9 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
864850
}
865851

866852
// ignoreError will return true if the error is an already exists status error and
867-
// 1. it is for a cluster role binding matching in roleBindingNames, or
868-
// 2. it is for a service account named saName
869-
func ignoreError(e error, saName string, roleBindingNames ...string) bool {
853+
// 1. it is for a cluster role binding named roleBindingName, or
854+
// 2. it is for a service account name saName
855+
func ignoreError(e error, saName string, roleBindingName string) bool {
870856
if !errors.IsAlreadyExists(e) {
871857
return false
872858
}
@@ -878,17 +864,9 @@ func ignoreError(e error, saName string, roleBindingNames ...string) bool {
878864
if details == nil {
879865
return false
880866
}
881-
if details.Kind == "serviceaccounts" {
882-
return details.Name == saName
883-
}
884-
if details.Kind == "clusterrolebinding" /*pre-3.7*/ || details.Kind == "clusterrolebindings" /*3.7+*/ {
885-
for _, name := range roleBindingNames {
886-
if details.Name == name {
887-
return true
888-
}
889-
}
890-
}
891-
return false
867+
return (details.Kind == "serviceaccounts" && details.Name == saName) ||
868+
(details.Kind == "clusterrolebinding" /*pre-3.7*/ && details.Name == roleBindingName) ||
869+
(details.Kind == "clusterrolebindings" /*3.7+*/ && details.Name == roleBindingName)
892870
}
893871

894872
// generateRoleBindingName generates a name for the rolebinding object if it is
@@ -897,10 +875,6 @@ func generateRoleBindingName(name string) string {
897875
return fmt.Sprintf("router-%s-role", name)
898876
}
899877

900-
func generateAuthRoleBindingName(name string) string {
901-
return fmt.Sprintf("router-%s-auth-role", name)
902-
}
903-
904878
// generateStatsPassword creates a random password.
905879
func generateStatsPassword() string {
906880
rand := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))

test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,18 @@ items:
17641764
verbs:
17651765
- list
17661766
- watch
1767+
- apiGroups:
1768+
- authentication.k8s.io
1769+
resources:
1770+
- tokenreviews
1771+
verbs:
1772+
- create
1773+
- apiGroups:
1774+
- authorization.k8s.io
1775+
resources:
1776+
- subjectaccessreviews
1777+
verbs:
1778+
- create
17671779
- apiGroups:
17681780
- ""
17691781
- route.openshift.io

test/testdata/bootstrappolicy/bootstrap_policy_file.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,20 @@ items:
19341934
verbs:
19351935
- list
19361936
- watch
1937+
- apiGroups:
1938+
- authentication.k8s.io
1939+
attributeRestrictions: null
1940+
resources:
1941+
- tokenreviews
1942+
verbs:
1943+
- create
1944+
- apiGroups:
1945+
- authorization.k8s.io
1946+
attributeRestrictions: null
1947+
resources:
1948+
- subjectaccessreviews
1949+
verbs:
1950+
- create
19371951
- apiGroups:
19381952
- ""
19391953
- route.openshift.io

0 commit comments

Comments
 (0)