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

Add sasl plain auth kafka plugin #1855

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions pkg/kafka/auth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var authTypes = []string{
// AuthenticationConfig describes the configuration properties needed authenticate with kafka cluster
type AuthenticationConfig struct {
Authentication string
TlsEnabled bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not need this once #1838 is finished

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. Reverted the change. I looked at the PR #1838 looks good. However, will take a closer look over the weekend.

Kerberos KerberosConfig
TLS TLSConfig
SASLPlain SASLPlainConfig
Expand All @@ -50,6 +51,7 @@ func (config *AuthenticationConfig) SetConfiguration(saramaConfig *sarama.Config
if strings.Trim(authentication, " ") == "" {
authentication = none
}
saramaConfig.Net.TLS.Enable = config.TlsEnabled
switch authentication {
case none:
return nil
Expand All @@ -68,6 +70,7 @@ func (config *AuthenticationConfig) SetConfiguration(saramaConfig *sarama.Config
// InitFromViper loads authentication configuration from viper flags.
func (config *AuthenticationConfig) InitFromViper(configPrefix string, v *viper.Viper) {
config.Authentication = v.GetString(configPrefix + suffixAuthentication)
config.TlsEnabled = v.GetBool(configPrefix+suffixTlsTransportEnabled)
config.Kerberos.ServiceName = v.GetString(configPrefix + kerberosPrefix + suffixKerberosServiceName)
config.Kerberos.Realm = v.GetString(configPrefix + kerberosPrefix + suffixKerberosRealm)
config.Kerberos.UseKeyTab = v.GetBool(configPrefix + kerberosPrefix + suffixKerberosUseKeyTab)
Expand Down
10 changes: 8 additions & 2 deletions pkg/kafka/auth/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (
)

const (
suffixAuthentication = ".authentication"
defaultAuthentication = none
suffixAuthentication = ".authentication"
defaultAuthentication = none
suffixTlsTransportEnabled = ".tls.enabled"
defaultTlsEnabled = false

// Kerberos configuration options
kerberosPrefix = ".kerberos"
Expand Down Expand Up @@ -125,6 +127,10 @@ func AddFlags(configPrefix string, flagSet *flag.FlagSet) {
defaultAuthentication,
"Authentication type used to authenticate with kafka cluster. e.g. "+strings.Join(authTypes, ", "),
)
flagSet.Bool(
configPrefix+suffixTlsTransportEnabled,
defaultTlsEnabled,
"TLS enabled or disabled for communication")
addKerberosFlags(configPrefix, flagSet)
addTLSFlags(configPrefix, flagSet)
addSASLPlainFlags(configPrefix, flagSet)
Expand Down