SASL Authentication
Support Laravel Kafka by sponsoring me!
Do you find Laravel Kafka valuable and wanna support its development?
Laravel Kafka is free and Open Source software, built to empower developers like you. Your support helps maintain and enhance the project. If you find it valuable, please consider sponsoring me on GitHub. Every contribution makes a difference and keeps the development going strong! Thank you!
SASL allows your producers and your consumers to authenticate to your Kafka cluster, which verifies their identity.
It's also a secure way to enable your clients to endorse an identity. To provide SASL configuration, you can use the withSasl
method,
passing a Junges\Kafka\Config\Sasl
instance as the argument:
$consumer = \Junges\Kafka\Facades\Kafka::consumer() ->withSasl( password: 'password', username: 'username', mechanisms: 'authentication mechanism' );
You can also set the security protocol used with sasl. It's optional and by default SASL_PLAINTEXT
is used, but you can set it to SASL_SSL
:
$consumer = \Junges\Kafka\Facades\Kafka::consumer() ->withSasl( password: 'password', username: 'username', mechanisms: 'authentication mechanism', securityProtocol: 'SASL_SSL', );
Hot tip!
TLS Authentication
For using TLS authentication with Laravel Kafka you can configure your client using the following options:
$consumer = \Junges\Kafka\Facades\Kafka::consumer() ->withOptions([ 'ssl.ca.location' => '/some/location/kafka.crt', 'ssl.certificate.location' => '/some/location/client.crt', 'ssl.key.location' => '/some/location/client.key', 'ssl.endpoint.identification.algorithm' => 'none' ]);