Skip to content

Commit

Permalink
kafka: allow disabling FAST in sarama client (#6189)
Browse files Browse the repository at this point in the history
Our sarama client has kerberos FAST negotiation turned on by default,
but there are KDCs that can't handle FAST negotiation and will fail.
There is an option to configure this on the sarama client, but we didn't
expose it anywhere, so users couldn't get to it.

This just adds an additional auth parameter to AuthConfig to expose that
configuration option so users who need to shut off FAST are able to do
so.

Signed-off-by: John Kyros <[email protected]>
  • Loading branch information
jkyros authored Oct 18, 2024
1 parent 67358af commit 4fdf649
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Here is an overview of all new **experimental** features:
- **GCP Scalers**: Added custom time horizon in GCP scalers ([#5778](https://github.com/kedacore/keda/issues/5778))
- **GitHub Scaler**: Fixed pagination, fetching repository list ([#5738](https://github.com/kedacore/keda/issues/5738))
- **Grafana dashboard**: Fix dashboard to handle wildcard scaledObject variables ([#6214](https://github.com/kedacore/keda/issues/6214))
- **Kafka**: Allow disabling FAST negotation when using Kerberos ([#6188](https://github.com/kedacore/keda/issues/6188))
- **Kafka**: Fix logic to scale to zero on invalid offset even with earliest offsetResetPolicy ([#5689](https://github.com/kedacore/keda/issues/5689))
- **RabbitMQ Scaler**: Add connection name for AMQP ([#5958](https://github.com/kedacore/keda/issues/5958))
- **Selenium Scaler**: Add Support for Username and Password Authentication ([#6144](https://github.com/kedacore/keda/issues/6144))
Expand Down
15 changes: 15 additions & 0 deletions pkg/scalers/kafka_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type kafkaMetadata struct {
realm string
kerberosConfigPath string
kerberosServiceName string
kerberosDisableFAST bool

// OAUTHBEARER
tokenProvider kafkaSaslOAuthTokenProvider
Expand Down Expand Up @@ -409,6 +410,15 @@ func parseKerberosParams(config *scalersconfig.ScalerConfig, meta *kafkaMetadata
meta.kerberosServiceName = strings.TrimSpace(config.AuthParams["kerberosServiceName"])
}

meta.kerberosDisableFAST = false
if val, ok := config.AuthParams["kerberosDisableFAST"]; ok {
t, err := strconv.ParseBool(val)
if err != nil {
return fmt.Errorf("error parsing kerberosDisableFAST: %w", err)
}
meta.kerberosDisableFAST = t
}

meta.saslType = mode
return nil
}
Expand Down Expand Up @@ -688,7 +698,12 @@ func getKafkaClientConfig(ctx context.Context, metadata kafkaMetadata) (*sarama.
config.Net.SASL.GSSAPI.AuthType = sarama.KRB5_USER_AUTH
config.Net.SASL.GSSAPI.Password = metadata.password
}

if metadata.kerberosDisableFAST {
config.Net.SASL.GSSAPI.DisablePAFXFAST = true
}
}

return config, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/scalers/kafka_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ var parseKafkaAuthParamsTestDataset = []parseKafkaAuthParamsTestData{
{map[string]string{"sasl": "gssapi", "username": "admin", "password": "admin", "kerberosConfig": "<config>", "tls": "enable", "ca": "caaa", "cert": "ceert", "key": "keey"}, true, false},
// failure, SASL GSSAPI/keytab + TLS missing username
{map[string]string{"sasl": "gssapi", "keytab": "/path/to/keytab", "kerberosConfig": "<config>", "realm": "tst.com", "tls": "enable", "ca": "caaa", "cert": "ceert", "key": "keey"}, true, false},
// success, SASL GSSAPI/disableFast
{map[string]string{"sasl": "gssapi", "username": "admin", "keytab": "/path/to/keytab", "kerberosConfig": "<config>", "realm": "tst.com", "kerberosDisableFAST": "true"}, false, false},
// failure, SASL GSSAPI/disableFast incorrect
{map[string]string{"sasl": "gssapi", "username": "admin", "keytab": "/path/to/keytab", "kerberosConfig": "<config>", "realm": "tst.com", "kerberosDisableFAST": "notabool"}, true, false},
}
var parseAuthParamsTestDataset = []parseAuthParamsTestDataSecondAuthMethod{
// success, SASL plaintext
Expand Down

0 comments on commit 4fdf649

Please sign in to comment.