SASL and Kerberos Configuration Examples
PLAIN Authentication Example
UI Configuration:
SASL Mechanism: PLAIN
Security Protocol: SASL_PLAINTEXT or SASL_SSL
JAAS Configuration:
org.apache.kafka.common.security.plain.PlainLoginModule required username="kafkauser" password="kafkapass";
Complete JAAS String:
org.apache.kafka.common.security.plain.PlainLoginModule required username="kafkauser" password="kafkapass";
SCRAM-SHA-256 Authentication Example
UI Configuration:
SASL Mechanism: SCRAM-SHA-256
Security Protocol: SASL_PLAINTEXT or SASL_SSL
JAAS Configuration:
org.apache.kafka.common.security.scram.ScramLoginModule required username="kafkauser" password="kafkapass";
Complete JAAS String:
org.apache.kafka.common.security.scram.ScramLoginModule required username="kafkauser" password="kafkapass";
OAUTHBEARER Authentication Example
UI Configuration:
SASL Mechanism: OAUTHBEARER
Security Protocol: SASL_SSL
JAAS Configuration:
org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginPrincipalClaimName="sub" unsecuredLoginStringClaim_sub="kafkauser";
Additional Kafka SASL Properties
Property Key | Property Value |
|---|---|
| 0.8 |
| 0.05 |
| 60 |
| 300 |
Complete JAAS String:
org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginPrincipalClaimName="sub" unsecuredLoginStringClaim_sub="kafkauser";
Kerberos (GSSAPI) Authentication Example
UI Configuration:
SASL Mechanism: GSSAPI
Security Protocol: SASL_PLAINTEXT or SASL_SSL
JAAS Configuration:
com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab="/etc/security/keytabs/kafka.service.keytab" principal="kafka/mooghost.example.com@EXAMPLE.COM";
Kerberos Configuration:
Enable Kerberos Debug Logging:
true(for troubleshooting)Kerberos Service Name:
kafkaKerberos Configuration File Path:
/etc/krb5.conf
Example krb5.conf:
[libdefaults]
default_realm = EXAMPLE.COM
dns_lookup_realm = false
dns_lookup_kdc = true
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
EXAMPLE.COM = {
kdc = kdc1.example.com
kdc = kdc2.example.com
admin_server = kdc1.example.com
}
[domain_realm]
.example.com = EXAMPLE.COM
example.com = EXAMPLE.COMComplete JAAS String:
com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab="/etc/security/keytabs/kafka.service.keytab" principal="kafka/mooghost.example.com@EXAMPLE.COM";
SSL/TLS Configuration Example
UI Configuration:
Use SSL:
trueTruststore Location:
/path/to/kafka.client.truststore.jksTruststore Password:
truststorepasswordKeystore Location:
/path/to/kafka.client.keystore.jksKeystore Password:
keystorepasswordKey Password:
keypasswordSSL Endpoint Identification Algorithm:
HTTPS
Combined SSL and SASL Configuration Examples
PLAIN Authentication with SSL:
Security Protocol: SASL_SSL
SSL Settings: Configure as described in the SSL/TLS Configuration Example.
SASL Settings: Configure as described in the PLAIN Authentication Example.
Kerberos Authentication with SSL
Security Protocol: SASL_SSL
SSL Settings: Configure as described in the SSL/TLS Configuration Example.
SASL Settings: Configure as described in the Kerberos (GSSAPI) Authentication Example.
Advanced Configuration Examples
Custom JAAS Module
If you use a custom login module, configure the JAAS string as follows:
com.example.security.CustomLoginModule required customParam1="value1" customParam2="value2";
Multi-Realm Kerberos
For environments with multiple Kerberos realms:
com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab="/etc/security/keytabs/kafka.service.keytab" principal="kafka/mooghost.realm1.com@REALM1.COM";
OAuth with Token Refresh
For OAuth Bearer authentication with automatic token refresh:
org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginPrincipalClaimName="sub" unsecuredLoginStringClaim_sub="service-account" unsecuredLoginTokenClaim="access_token";
Additional Properties
Property Key | Property Value |
|---|---|
| 0.85 |
| 0.03 |
| 30 |
| 240 |