@@ -15,6 +15,7 @@ import (
1515 x509request "k8s.io/apiserver/pkg/authentication/request/x509"
1616 tokencache "k8s.io/apiserver/pkg/authentication/token/cache"
1717 tokenunion "k8s.io/apiserver/pkg/authentication/token/union"
18+ genericapiserver "k8s.io/apiserver/pkg/server"
1819 kclientsetexternal "k8s.io/client-go/kubernetes"
1920 "k8s.io/client-go/util/cert"
2021 sacontroller "k8s.io/kubernetes/pkg/controller/serviceaccount"
@@ -37,26 +38,26 @@ func NewAuthenticator(
3738 options configapi.MasterConfig ,
3839 privilegedLoopbackConfig * rest.Config ,
3940 informers InformerAccess ,
40- ) (authenticator.Request , error ) {
41+ ) (authenticator.Request , map [ string ]genericapiserver. PostStartHookFunc , error ) {
4142 kubeExternalClient , err := kclientsetexternal .NewForConfig (privilegedLoopbackConfig )
4243 if err != nil {
43- return nil , err
44+ return nil , nil , err
4445 }
4546 oauthClient , err := oauthclient .NewForConfig (privilegedLoopbackConfig )
4647 if err != nil {
47- return nil , err
48+ return nil , nil , err
4849 }
4950 userClient , err := userclient .NewForConfig (privilegedLoopbackConfig )
5051 if err != nil {
51- return nil , err
52+ return nil , nil , err
5253 }
5354
5455 // this is safe because the server does a quorum read and we're hitting a "magic" authorizer to get permissions based on system:masters
5556 // once the cache is added, we won't be paying a double hop cost to etcd on each request, so the simplification will help.
5657 serviceAccountTokenGetter := sacontroller .NewGetterFromClient (kubeExternalClient )
5758 apiClientCAs , err := configapi .GetAPIClientCertCAPool (options )
5859 if err != nil {
59- return nil , err
60+ return nil , nil , err
6061 }
6162
6263 return newAuthenticator (
@@ -69,7 +70,8 @@ func NewAuthenticator(
6970 )
7071}
7172
72- func newAuthenticator (config configapi.MasterConfig , accessTokenGetter oauthclient.OAuthAccessTokenInterface , tokenGetter serviceaccount.ServiceAccountTokenGetter , userGetter usertypedclient.UserResourceInterface , apiClientCAs * x509.CertPool , groupMapper identitymapper.UserToGroupMapper ) (authenticator.Request , error ) {
73+ func newAuthenticator (config configapi.MasterConfig , accessTokenGetter oauthclient.OAuthAccessTokenInterface , tokenGetter serviceaccount.ServiceAccountTokenGetter , userGetter usertypedclient.UserResourceInterface , apiClientCAs * x509.CertPool , groupMapper identitymapper.UserToGroupMapper ) (authenticator.Request , map [string ]genericapiserver.PostStartHookFunc , error ) {
74+ postStartHooks := map [string ]genericapiserver.PostStartHookFunc {}
7375 authenticators := []authenticator.Request {}
7476 tokenAuthenticators := []authenticator.Token {}
7577
@@ -79,7 +81,7 @@ func newAuthenticator(config configapi.MasterConfig, accessTokenGetter oauthclie
7981 for _ , keyFile := range config .ServiceAccountConfig .PublicKeyFiles {
8082 readPublicKeys , err := cert .PublicKeysFromFile (keyFile )
8183 if err != nil {
82- return nil , fmt .Errorf ("Error reading service account key file %s: %v" , keyFile , err )
84+ return nil , nil , fmt .Errorf ("Error reading service account key file %s: %v" , keyFile , err )
8385 }
8486 publicKeys = append (publicKeys , readPublicKeys ... )
8587 }
@@ -134,7 +136,7 @@ func newAuthenticator(config configapi.MasterConfig, accessTokenGetter oauthclie
134136 config .AuthConfig .RequestHeader .ExtraHeaderPrefixes ,
135137 )
136138 if err != nil {
137- return nil , fmt .Errorf ("Error building front proxy auth config: %v" , err )
139+ return nil , nil , fmt .Errorf ("Error building front proxy auth config: %v" , err )
138140 }
139141 topLevelAuthenticators = append (topLevelAuthenticators , union .New (requestHeaderAuthenticator , resultingAuthenticator ))
140142
@@ -144,5 +146,5 @@ func newAuthenticator(config configapi.MasterConfig, accessTokenGetter oauthclie
144146 }
145147 topLevelAuthenticators = append (topLevelAuthenticators , anonymous .NewAuthenticator ())
146148
147- return group .NewAuthenticatedGroupAdder (union .NewFailOnError (topLevelAuthenticators ... )), nil
149+ return group .NewAuthenticatedGroupAdder (union .NewFailOnError (topLevelAuthenticators ... )), postStartHooks , nil
148150}
0 commit comments