Skip to content

Commit eeb63e7

Browse files
authored
Merge pull request #17 from sjje/master
add sasl authorization
2 parents 03baedf + 17006df commit eeb63e7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

config/kafka.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,24 @@
3636
* Sleep when a deadlock is detected
3737
*/
3838
'sleep_on_deadlock' => env('KAFKA_DEADLOCK_SLEEP', 2),
39+
40+
/*
41+
* sasl authorization
42+
*/
43+
'sasl_enable' => false,
44+
45+
/*
46+
* File or directory path to CA certificate(s) for verifying the broker's key. example: storage_path('kafka.client.truststore.jks')
47+
*/
48+
'ssl_ca_location' => '',
49+
50+
/*
51+
* SASL username for use with the PLAIN and SASL-SCRAM-.. mechanisms
52+
*/
53+
'sasl_plain_username' => env('KAFKA_SASL_PLAIN_USERNAME'),
54+
55+
/*
56+
* SASL password for use with the PLAIN and SASL-SCRAM-.. mechanism
57+
*/
58+
'sasl_plain_password' => env('KAFKA_SASL_PLAIN_PASSWORD'),
3959
];

src/Queue/Connectors/KafkaConnector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public function connect(array $config)
4646

4747
/** @var Conf $conf */
4848
$conf = $this->container->makeWith('queue.kafka.conf', []);
49+
if (true === $config['sasl_enable']) {
50+
$conf->set('sasl.mechanisms', 'PLAIN');
51+
$conf->set('sasl.username', $config['sasl_plain_username']);
52+
$conf->set('sasl.password', $config['sasl_plain_password']);
53+
$conf->set('ssl.ca.location', $config['ssl_ca_location']);
54+
}
4955
$conf->set('group.id', array_get($config, 'consumer_group_id', 'php-pubsub'));
5056
$conf->set('metadata.broker.list', $config['brokers']);
5157
$conf->set('enable.auto.commit', 'false');

0 commit comments

Comments
 (0)