Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export NewKerberosClientFunc to config for allow custom client #2773

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1295,8 +1295,8 @@ func (b *Broker) authenticateViaSASLv1() error {

func (b *Broker) sendAndReceiveKerberos() error {
b.kerberosAuthenticator.Config = &b.conf.Net.SASL.GSSAPI
if b.kerberosAuthenticator.NewKerberosClientFunc == nil {
b.kerberosAuthenticator.NewKerberosClientFunc = NewKerberosClient
if b.kerberosAuthenticator.Config.NewKerberosClientFunc == nil {
b.kerberosAuthenticator.Config.NewKerberosClientFunc = NewKerberosClient
}
return b.kerberosAuthenticator.Authorize(b)
}
Expand Down
4 changes: 2 additions & 2 deletions broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,14 +723,14 @@ func TestGSSAPIKerberosAuth_Authorize(t *testing.T) {
}
mockBroker.SetGSSAPIHandler(gssapiHandler.MockKafkaGSSAPI)
if test.mockKerberosClient {
broker.kerberosAuthenticator.NewKerberosClientFunc = func(config *GSSAPIConfig) (KerberosClient, error) {
conf.Net.SASL.GSSAPI.NewKerberosClientFunc = func(config *GSSAPIConfig) (KerberosClient, error) {
return &MockKerberosClient{
mockError: test.error,
errorStage: test.errorStage,
}, nil
}
} else {
broker.kerberosAuthenticator.NewKerberosClientFunc = nil
conf.Net.SASL.GSSAPI.NewKerberosClientFunc = nil
}

err := broker.Open(conf)
Expand Down
30 changes: 15 additions & 15 deletions gssapi_kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ const (
)

type GSSAPIConfig struct {
AuthType int
KeyTabPath string
CCachePath string
KerberosConfigPath string
ServiceName string
Username string
Password string
Realm string
DisablePAFXFAST bool
AuthType int
KeyTabPath string
CCachePath string
KerberosConfigPath string
ServiceName string
Username string
Password string
Realm string
DisablePAFXFAST bool
NewKerberosClientFunc func(config *GSSAPIConfig) (KerberosClient, error)
}

type GSSAPIKerberosAuth struct {
Config *GSSAPIConfig
ticket messages.Ticket
encKey types.EncryptionKey
NewKerberosClientFunc func(config *GSSAPIConfig) (KerberosClient, error)
step int
Config *GSSAPIConfig
ticket messages.Ticket
encKey types.EncryptionKey
step int
}

type KerberosClient interface {
Expand Down Expand Up @@ -199,7 +199,7 @@ func (krbAuth *GSSAPIKerberosAuth) initSecContext(bytes []byte, kerberosClient K

/* This does the handshake for authorization */
func (krbAuth *GSSAPIKerberosAuth) Authorize(broker *Broker) error {
kerberosClient, err := krbAuth.NewKerberosClientFunc(krbAuth.Config)
kerberosClient, err := krbAuth.Config.NewKerberosClientFunc(krbAuth.Config)
if err != nil {
Logger.Printf("Kerberos client error: %s", err)
return err
Expand Down
Loading