Skip to content

Commit a6677d6

Browse files
authored
Merge pull request kubernetes#73409 from yue9944882/bugfix/compatible-with-nil-authorizer
Fixes authz compatibility w/ nil authorizer in apiserver
2 parents 86f6279 + 2486174 commit a6677d6

File tree

1 file changed

+11
-2
lines changed
  • staging/src/k8s.io/apiserver/pkg/server

1 file changed

+11
-2
lines changed

staging/src/k8s.io/apiserver/pkg/server/config.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,18 @@ func (s *SecureServingInfo) HostPort() (string, int, error) {
614614
}
615615

616616
// AuthorizeClientBearerToken wraps the authenticator and authorizer in loopback authentication logic
617-
// if the loopback client config is specified AND it has a bearer token.
617+
// if the loopback client config is specified AND it has a bearer token. Note that if either authn or
618+
// authz is nil, this function won't add a token authenticator or authorizer.
618619
func AuthorizeClientBearerToken(loopback *restclient.Config, authn *AuthenticationInfo, authz *AuthorizationInfo) {
619-
if loopback == nil || authn == nil || authz == nil || authn.Authenticator == nil && authz.Authorizer == nil || len(loopback.BearerToken) == 0 {
620+
if loopback == nil || len(loopback.BearerToken) == 0 {
621+
return
622+
}
623+
if authn == nil || authz == nil {
624+
// prevent nil pointer panic
625+
}
626+
if authn.Authenticator == nil || authz.Authorizer == nil {
627+
// authenticator or authorizer might be nil if we want to bypass authz/authn
628+
// and we also do nothing in this case.
620629
return
621630
}
622631

0 commit comments

Comments
 (0)