pykafka icon indicating copy to clipboard operation
pykafka copied to clipboard

SASL Support

Open webe3 opened this issue 8 years ago • 11 comments

I would like to use pykafka to connect to IBM Bluemix Message Hub with is a Kafka implementation. There is a kafka-python example in this thread. https://stackoverflow.com/questions/35294949/can-i-call-the-bluemix-message-hub-service-from-python/40325181#40325181

I also found this for confluent-kafka:

A new Python client

Confluent, the company founded by the creators of Kafka, has released a Python client (https://github.com/confluentinc/confluent-kafka-python). It is built as a thin bindings layer on top of librdkafka and works for both Python 2 and 3.

To use with Message Hub, simply pass these properties in when creating a Producer/Consumer:

'ssl.ca.location': '/etc/ssl/certs/',
'sasl.mechanisms': 'PLAIN',
'sasl.username': '<USER>',
'sasl.password': '<PASSWORD>',
'security.protocol': 'sasl_ssl'

Note: The value of ‘ssl.ca.location depends’ on your operating system. For example:

Ubuntu: /etc/ssl/certs/
RedHat: /etc/pki/tls/cert.pem
OS X: select system root certificates from Keychain Access and export as .pem on the filesystem.

Is there a way to connect using pykafka? If so, how would I do it?

webe3 avatar Jan 27 '17 20:01 webe3

Hi @webe3, thanks for reaching out. Sounds like you're looking for pykafka's SSL support, which is based on constructing an SslConfig object and passing it to a newly created KafkaClient.

emmettbutler avatar Jan 31 '17 19:01 emmettbutler

Yes, I saw that but it is not clear to me how to do it given what I have to work with.

webe3 avatar Jan 31 '17 21:01 webe3

It doesn't look to me like pykafka has the mechanism for sasl plain like kafka-python and confluent_kafka do. For example in kafka-python I would pass in the following configurations to create a consumer or producer.

configs = { 'bootstrap_servers': credentials['kafka_brokers_sasl'], 'sasl_mechanism': 'PLAIN', 'sasl_plain_username': credentials['api_key'][0:16], 'sasl_plain_password': credentials['api_key'][16:48], 'security_protocol': 'SASL_SSL', 'ssl_context': ssl.create_default_context(), }

These parameters are described here: https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html

I don't see any similar parameters for sasl for pykafka.

webe3 avatar Feb 09 '17 21:02 webe3

Thanks for clarifying, @webe3. Pykafka indeed doesn't have SASL support, only TLS/SSL support at the moment. I've changed the title of this bug to indicate the need for SASL support. If you're interested in contributing a pull request for this feature, I'd be happy to review it. Otherwise, it will go into the issue backlog.

emmettbutler avatar Feb 14 '17 17:02 emmettbutler

SASL support would be great. We're having to rewrite an internal project to use kafka-python for the time being due to the lack of SASL support.

Battleroid avatar Jan 04 '18 14:01 Battleroid

Do we have SASL support enabled for PyKafka?

jayanra avatar May 08 '18 15:05 jayanra

No, SASL support is still pending a pull request that adds it.

emmettbutler avatar May 08 '18 15:05 emmettbutler

Our kafka prod server is moving to GSSAPI SASL (kerberos) authentication, so I would like to know are there any news regarding SASL support by pykafka?

ZamElek avatar Aug 09 '19 15:08 ZamElek

我们的产品将更换抛弃pykafka,因为支持SASK,求支持~

zhangjiahaol avatar May 09 '20 13:05 zhangjiahaol

in our products we use kafka and give up pykafka due to the lack of sasl support. it will be great if pykafka support sasl

colin404 avatar Jul 14 '20 07:07 colin404

SASL is required in our project. pykafka is not support.

ares2233 avatar Sep 08 '20 02:09 ares2233