Skip to content

Commit

Permalink
required groups authorizer: allow external-logical-cluster-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Hardy committed Mar 24, 2023
1 parent c901627 commit 36aa88c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/authorization/requiredgroups_authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func (a *requiredGroupsAuthorizer) Authorize(ctx context.Context, attr authorize
return authorizer.DecisionNoOpinion, "", err
}

// always let external-logical-cluster-admins through
if sets.NewString(attr.GetUser().GetGroups()...).Has(bootstrap.SystemExternalLogicalClusterAdmin) {
return DelegateAuthorization("external logical cluster admin access", a.delegate).Authorize(ctx, attr)
}

// check required groups
value, found := logicalCluster.Annotations[RequiredGroupsAnnotationKey]
if !found {
Expand Down
6 changes: 6 additions & 0 deletions pkg/authorization/requiredgroups_authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func TestRequiredGroupsAuthorizer(t *testing.T) {
wantDecision: authorizer.DecisionAllow,
wantReason: "delegating due to logical cluster admin access",
},
"system:kcp:external-logical-cluster-admin can always pass": {
requestedWorkspace: "root:ready",
requestingUser: newUser("external-lcluster-admin", "system:kcp:external-logical-cluster-admin"),
wantDecision: authorizer.DecisionAllow,
wantReason: "delegating due to external logical cluster admin access",
},
"service account from other cluster is granted access": {
requestedWorkspace: "root:ready",
requestingUser: newServiceAccountWithCluster("sa", "anotherws"),
Expand Down

0 comments on commit 36aa88c

Please sign in to comment.