@@ -14,6 +14,7 @@ limitations under the License.
1414package kafka
1515
1616import (
17+ "encoding/json"
1718 "errors"
1819 "fmt"
1920 "strconv"
@@ -42,31 +43,33 @@ const (
4243)
4344
4445type KafkaMetadata struct {
45- Brokers string `mapstructure:"brokers"`
46- internalBrokers []string `mapstructure:"-"`
47- ConsumerGroup string `mapstructure:"consumerGroup"`
48- ClientID string `mapstructure:"clientId"`
49- AuthType string `mapstructure:"authType"`
50- SaslUsername string `mapstructure:"saslUsername"`
51- SaslPassword string `mapstructure:"saslPassword"`
52- SaslMechanism string `mapstructure:"saslMechanism"`
53- InitialOffset string `mapstructure:"initialOffset"`
54- internalInitialOffset int64 `mapstructure:"-"`
55- MaxMessageBytes int `mapstructure:"maxMessageBytes"`
56- OidcTokenEndpoint string `mapstructure:"oidcTokenEndpoint"`
57- OidcClientID string `mapstructure:"oidcClientID"`
58- OidcClientSecret string `mapstructure:"oidcClientSecret"`
59- OidcScopes string `mapstructure:"oidcScopes"`
60- internalOidcScopes []string `mapstructure:"-"`
61- TLSDisable bool `mapstructure:"disableTls"`
62- TLSSkipVerify bool `mapstructure:"skipVerify"`
63- TLSCaCert string `mapstructure:"caCert"`
64- TLSClientCert string `mapstructure:"clientCert"`
65- TLSClientKey string `mapstructure:"clientKey"`
66- ConsumeRetryEnabled bool `mapstructure:"consumeRetryEnabled"`
67- ConsumeRetryInterval time.Duration `mapstructure:"consumeRetryInterval"`
68- Version string `mapstructure:"version"`
69- internalVersion sarama.KafkaVersion `mapstructure:"-"`
46+ Brokers string `mapstructure:"brokers"`
47+ internalBrokers []string `mapstructure:"-"`
48+ ConsumerGroup string `mapstructure:"consumerGroup"`
49+ ClientID string `mapstructure:"clientId"`
50+ AuthType string `mapstructure:"authType"`
51+ SaslUsername string `mapstructure:"saslUsername"`
52+ SaslPassword string `mapstructure:"saslPassword"`
53+ SaslMechanism string `mapstructure:"saslMechanism"`
54+ InitialOffset string `mapstructure:"initialOffset"`
55+ internalInitialOffset int64 `mapstructure:"-"`
56+ MaxMessageBytes int `mapstructure:"maxMessageBytes"`
57+ OidcTokenEndpoint string `mapstructure:"oidcTokenEndpoint"`
58+ OidcClientID string `mapstructure:"oidcClientID"`
59+ OidcClientSecret string `mapstructure:"oidcClientSecret"`
60+ OidcScopes string `mapstructure:"oidcScopes"`
61+ OidcExtensions string `mapstructure:"oidcExtensions"`
62+ internalOidcScopes []string `mapstructure:"-"`
63+ TLSDisable bool `mapstructure:"disableTls"`
64+ TLSSkipVerify bool `mapstructure:"skipVerify"`
65+ TLSCaCert string `mapstructure:"caCert"`
66+ TLSClientCert string `mapstructure:"clientCert"`
67+ TLSClientKey string `mapstructure:"clientKey"`
68+ ConsumeRetryEnabled bool `mapstructure:"consumeRetryEnabled"`
69+ ConsumeRetryInterval time.Duration `mapstructure:"consumeRetryInterval"`
70+ Version string `mapstructure:"version"`
71+ internalVersion sarama.KafkaVersion `mapstructure:"-"`
72+ internalOidcExtensions map [string ]string `mapstructure:"-"`
7073}
7174
7275// upgradeMetadata updates metadata properties based on deprecated usage.
@@ -180,6 +183,12 @@ func (k *Kafka) getKafkaMetadata(meta map[string]string) (*KafkaMetadata, error)
180183 k .logger .Warn ("Warning: no OIDC scopes specified, using default 'openid' scope only. This is a security risk for token reuse." )
181184 m .internalOidcScopes = []string {"openid" }
182185 }
186+ if m .OidcExtensions != "" {
187+ err = json .Unmarshal ([]byte (m .OidcExtensions ), & m .internalOidcExtensions )
188+ if err != nil || len (m .internalOidcExtensions ) < 1 {
189+ return nil , errors .New ("kafka error: improper OIDC Extensions format for authType 'oidc'" )
190+ }
191+ }
183192 k .logger .Debug ("Configuring SASL token authentication via OIDC." )
184193 case mtlsAuthType :
185194 if m .TLSClientCert != "" {
0 commit comments