Skip to content

Commit

Permalink
Add *.kerberos.disable-fast-negotiation option to Kafka consumer (jae…
Browse files Browse the repository at this point in the history
…gertracing#4520)

## Which problem is this PR solving?
- Solves jaegertracing#2744

## Short description of the changes
- Added a variable in KerberosConfig struct and configured it
- Added flags and the configuration for the same

---------

Signed-off-by: bugslayer-332 <ayashwanth9503@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-authored-by: bugslayer-332 <ayashwanth9503@gmail.com>
Co-authored-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: KevinSchneider <kevin.schneider@target.com>
  • Loading branch information
3 people authored and kjschnei001 committed Jun 29, 2023
1 parent b6307df commit fee3166
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
1 change: 1 addition & 0 deletions pkg/kafka/auth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (config *AuthenticationConfig) InitFromViper(configPrefix string, v *viper.
config.Kerberos.Password = v.GetString(configPrefix + kerberosPrefix + suffixKerberosPassword)
config.Kerberos.ConfigPath = v.GetString(configPrefix + kerberosPrefix + suffixKerberosConfig)
config.Kerberos.KeyTabPath = v.GetString(configPrefix + kerberosPrefix + suffixKerberosKeyTab)
config.Kerberos.DisablePAFXFast = v.GetBool(configPrefix + kerberosPrefix + suffixKerberosDisablePAFXFAST)

tlsClientConfig := tlscfg.ClientFlagsConfig{
Prefix: configPrefix,
Expand Down
16 changes: 9 additions & 7 deletions pkg/kafka/auth/kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import (

// KerberosConfig describes the configuration properties needed for Kerberos authentication with kafka consumer
type KerberosConfig struct {
ServiceName string `mapstructure:"service_name"`
Realm string `mapstructure:"realm"`
UseKeyTab bool `mapstructure:"use_keytab"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password" json:"-"`
ConfigPath string `mapstructure:"config_file"`
KeyTabPath string `mapstructure:"keytab_file"`
ServiceName string `mapstructure:"service_name"`
Realm string `mapstructure:"realm"`
UseKeyTab bool `mapstructure:"use_keytab"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password" json:"-"`
ConfigPath string `mapstructure:"config_file"`
KeyTabPath string `mapstructure:"keytab_file"`
DisablePAFXFast bool `mapstructure:"disable_pa_fx_fast"`
}

func setKerberosConfiguration(config *KerberosConfig, saramaConfig *sarama.Config) {
Expand All @@ -43,4 +44,5 @@ func setKerberosConfiguration(config *KerberosConfig, saramaConfig *sarama.Confi
saramaConfig.Net.SASL.GSSAPI.Username = config.Username
saramaConfig.Net.SASL.GSSAPI.Realm = config.Realm
saramaConfig.Net.SASL.GSSAPI.ServiceName = config.ServiceName
saramaConfig.Net.SASL.GSSAPI.DisablePAFXFAST = config.DisablePAFXFast
}
36 changes: 21 additions & 15 deletions pkg/kafka/auth/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ const (
defaultAuthentication = none

// Kerberos configuration options
kerberosPrefix = ".kerberos"
suffixKerberosServiceName = ".service-name"
suffixKerberosRealm = ".realm"
suffixKerberosUseKeyTab = ".use-keytab"
suffixKerberosUsername = ".username"
suffixKerberosPassword = ".password"
suffixKerberosConfig = ".config-file"
suffixKerberosKeyTab = ".keytab-file"
kerberosPrefix = ".kerberos"
suffixKerberosServiceName = ".service-name"
suffixKerberosRealm = ".realm"
suffixKerberosUseKeyTab = ".use-keytab"
suffixKerberosUsername = ".username"
suffixKerberosPassword = ".password"
suffixKerberosConfig = ".config-file"
suffixKerberosKeyTab = ".keytab-file"
suffixKerberosDisablePAFXFAST = ".disable-fast-negotiation"

defaultKerberosConfig = "/etc/krb5.conf"
defaultKerberosUseKeyTab = false
defaultKerberosServiceName = "kafka"
defaultKerberosRealm = ""
defaultKerberosPassword = ""
defaultKerberosUsername = ""
defaultKerberosKeyTab = "/etc/security/kafka.keytab"
defaultKerberosConfig = "/etc/krb5.conf"
defaultKerberosUseKeyTab = false
defaultKerberosServiceName = "kafka"
defaultKerberosRealm = ""
defaultKerberosPassword = ""
defaultKerberosUsername = ""
defaultKerberosKeyTab = "/etc/security/kafka.keytab"
defaultKerberosDisablePAFXFast = false

plainTextPrefix = ".plaintext"
suffixPlainTextUsername = ".username"
Expand Down Expand Up @@ -82,6 +84,10 @@ func addKerberosFlags(configPrefix string, flagSet *flag.FlagSet) {
configPrefix+kerberosPrefix+suffixKerberosKeyTab,
defaultKerberosKeyTab,
"Path to keytab file. i.e /etc/security/kafka.keytab")
flagSet.Bool(
configPrefix+kerberosPrefix+suffixKerberosDisablePAFXFAST,
defaultKerberosDisablePAFXFast,
"Disable FAST negotiation when not supported by KDC's like Active Directory. See https://github.com/jcmturner/gokrb5/blob/master/USAGE.md#active-directory-kdc-and-fast-negotiation.")
}

func addPlainTextFlags(configPrefix string, flagSet *flag.FlagSet) {
Expand Down

0 comments on commit fee3166

Please sign in to comment.