Kafka ScramAuth#

pydantic model onetl.connection.db_connection.kafka.kafka_scram_auth.KafkaScramAuth#

Connect to Kafka using sasl.mechanism="SCRAM-SHA-*".

For more details see Kafka Documentation.

Examples

Auth in Kafka with SCRAM-SHA-256 mechanism:

from onetl.connection import Kafka

auth = Kafka.ScramAuth(
    user="me",
    password="abc",
    digest="SHA-256",
)

Auth in Kafka with SCRAM-SHA-512 mechanism and some custom SASL options passed to Kafka client config:

from onetl.connection import Kafka

auth = Kafka.ScramAuth.parse(
    {
        "user": "me",
        "password": "abc",
        "digest": "SHA-512",
        # options with sasl.login. prefix are passed to Kafka client config
        "sasl.login.class": "com.example.CustomScramLogin",
    }
)
field user: str [Required] (alias 'username')#
field password: SecretStr [Required]#
field digest: Literal['SHA-256', 'SHA-512'] [Required]#
get_jaas_conf() str#
get_options(kafka: Kafka) dict#

Get options for Kafka connection

Parameters:
kafkaKafka

Connection instance

Returns:
dict:

Kafka client options

cleanup(kafka: Kafka) None#

This method is called while closing Kafka connection.

Implement it to cleanup resources like temporary files.

Parameters:
kafkaKafka

Connection instance