options/authentication: revert extra serviceaccount TokenGetter function silently enabling serviceaccounts

Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
This commit is contained in:
Dr. Stefan Schimanski 2024-07-21 22:02:52 +02:00
parent 0caeba5cbe
commit dc0bcd62e3
No known key found for this signature in database
GPG Key ID: 4C68E0F19F95EC33
2 changed files with 2 additions and 14 deletions

View File

@ -218,15 +218,6 @@ func (o *BuiltInAuthenticationOptions) WithServiceAccounts() *BuiltInAuthenticat
return o
}
// WithTokenGetterFunction set optional service account token getter function
func (o *BuiltInAuthenticationOptions) WithTokenGetterFunction(f func(factory informers.SharedInformerFactory) serviceaccount.ServiceAccountTokenGetter) *BuiltInAuthenticationOptions {
if o.ServiceAccounts == nil {
o.ServiceAccounts = &ServiceAccountAuthenticationOptions{}
}
o.ServiceAccounts.OptionalTokenGetter = f
return o
}
// WithTokenFile set default value for token file authentication
func (o *BuiltInAuthenticationOptions) WithTokenFile() *BuiltInAuthenticationOptions {
o.TokenFile = &TokenFileAuthenticationOptions{}

View File

@ -494,16 +494,13 @@ func TestWithTokenGetterFunction(t *testing.T) {
called = true
return nil
}
opts := NewBuiltInAuthenticationOptions().WithTokenGetterFunction(f)
opts := NewBuiltInAuthenticationOptions().WithServiceAccounts()
opts.ServiceAccounts.OptionalTokenGetter = f
err := opts.ApplyTo(context.Background(), &genericapiserver.AuthenticationInfo{}, nil, nil, &openapicommon.Config{}, nil, fakeClientset, versionedInformer, "")
if err != nil {
t.Fatal(err)
}
if opts.ServiceAccounts.OptionalTokenGetter == nil {
t.Fatal("expected token getter function to be set")
}
if !called {
t.Fatal("expected token getter function to be called")
}