Skip to content

Commit 82fc732

Browse files
Merge pull request #10933 from liggitt/master-non-resource-permissions-1.3.1
Ensure system:master has full permissions on non-resource-urls
2 parents d451518 + 11c24ed commit 82fc732

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

pkg/cmd/server/bootstrappolicy/policy.go

+4
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
490490
},
491491
Rules: []authorizationapi.PolicyRule{
492492
authorizationapi.NewRule("*").Groups("*").Resources("*").RuleOrDie(),
493+
{
494+
Verbs: sets.NewString(authorizationapi.VerbAll),
495+
NonResourceURLs: sets.NewString(authorizationapi.NonResourceAll),
496+
},
493497
},
494498
},
495499
{

pkg/cmd/server/bootstrappolicy/policy_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func TestCovers(t *testing.T) {
103103
var registryAdmin *authorizationapi.ClusterRole
104104
var registryEditor *authorizationapi.ClusterRole
105105
var registryViewer *authorizationapi.ClusterRole
106+
var systemMaster *authorizationapi.ClusterRole
107+
var systemDiscovery *authorizationapi.ClusterRole
108+
var clusterAdmin *authorizationapi.ClusterRole
106109

107110
for i := range allRoles {
108111
role := allRoles[i]
@@ -119,6 +122,12 @@ func TestCovers(t *testing.T) {
119122
registryEditor = &role
120123
case bootstrappolicy.RegistryViewerRoleName:
121124
registryViewer = &role
125+
case bootstrappolicy.MasterRoleName:
126+
systemMaster = &role
127+
case bootstrappolicy.DiscoveryRoleName:
128+
systemDiscovery = &role
129+
case bootstrappolicy.ClusterAdminRoleName:
130+
clusterAdmin = &role
122131
}
123132
}
124133

@@ -140,4 +149,13 @@ func TestCovers(t *testing.T) {
140149
if covers, miss := rulevalidation.Covers(registryAdmin.Rules, registryViewer.Rules); !covers {
141150
t.Errorf("failed to cover: %#v", miss)
142151
}
152+
153+
// Make sure we can auto-reconcile discovery
154+
if covers, miss := rulevalidation.Covers(systemMaster.Rules, systemDiscovery.Rules); !covers {
155+
t.Errorf("failed to cover: %#v", miss)
156+
}
157+
// Make sure the master has full permissions
158+
if covers, miss := rulevalidation.Covers(systemMaster.Rules, clusterAdmin.Rules); !covers {
159+
t.Errorf("failed to cover: %#v", miss)
160+
}
143161
}

test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,13 @@ items:
16531653
- '*'
16541654
verbs:
16551655
- '*'
1656+
- apiGroups: null
1657+
attributeRestrictions: null
1658+
nonResourceURLs:
1659+
- '*'
1660+
resources: []
1661+
verbs:
1662+
- '*'
16561663
- apiVersion: v1
16571664
kind: ClusterRole
16581665
metadata:

0 commit comments

Comments
 (0)