Skip to content

Commit 7b73a9e

Browse files
authored
Merge pull request #53 from yue9944882/feat/disable-authz-configurable
Feat: Make authz configurable via `--enable-authorization`
2 parents 2838c7c + 8619b14 commit 7b73a9e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go 1.x
1717
uses: actions/setup-go@v2
1818
with:
19-
go-version: ^1.16
19+
go-version: 1.16.6
2020
id: go
2121

2222
- run: go get github.com/golangci/golangci-lint/cmd/golangci-lint

pkg/builder/builder_auth.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ import (
66
"sigs.k8s.io/apiserver-runtime/internal/sample-apiserver/pkg/cmd/server"
77
)
88

9+
var enableAuthorization bool
10+
911
// DisableAuthorization disables delegated authentication and authorization
1012
func (a *Server) DisableAuthorization() *Server {
1113
server.ServerOptionsFns = append(server.ServerOptionsFns, func(o *ServerOptions) *ServerOptions {
12-
o.RecommendedOptions.Authorization = nil
14+
if !enableAuthorization {
15+
o.RecommendedOptions.Authorization = nil
16+
}
1317
return o
1418
})
19+
server.FlagsFns = append(server.FlagsFns, func(fs *pflag.FlagSet) *pflag.FlagSet {
20+
fs.BoolVar(&enableAuthorization, "enable-authorization", false,
21+
"Enabling authorization will check if the incoming authenticated requests "+
22+
"have sufficient permission for the requesting target. Deploying the apiserver "+
23+
"inside a kubernetes cluster will delegate the authorization to the hosting "+
24+
"kube-apiserver, otherwise specify `--authorization-kubeconfig` to explicitly "+
25+
"set a kube-apiserver to talk to.")
26+
return fs
27+
})
1528
return a
1629
}
1730

0 commit comments

Comments
 (0)