-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Kafka SASL_SSL authentication #177
Conversation
Same as #173 but it updates the existing kafka event source instead. Not tested with SCRAM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jouir thank you very much for your contribution. I have some concerns about how you are managing the options.
- The security_protocol should not be overridden to "SSL" if its value is "SASL_SSL." It requires a different set of options (including those defined in the sasl_mechanism). Additionally, it seems to be missing an option: "SASL_PLAINTEXT."
- The ssl_context is required for SSL and SASL_SSL options. Therefore, for our arguments, cafile is mandatory in such cases and should be enforced. Otherwise, the error returned by aiokafka could be confusing for users.
- It would be beneficial to check all the matrices of required options on our side or capture "ValueError" exceptions from the Kafka client to provide nice and meaningful messages to the users, rather than relying on the default traceback output.
The pull request would be merged more quickly if it includes tests that deploy the required Kafka with Docker Compose, as we already do in the integration tests. Otherwise, we will have to test it manually, which will take more time.
Hello @Alex-Izquierdo, thank you for the review. I appreciate!
The
Good point. I will add it, thanks.
The
Same with ssl:
Which is the case by default here. We use such setup to use very basic encryption without error from aiokafka nor ssl.
As of today, I have not encountered any
Sure. I will try to provide a Kafka broker with SASL auth matching my own case using docker-compose and associated tests. Have a nice day |
Hello again @jouir Thanks for your quickly response! :) |
I have pushed a new commit including tests for SASL_PLAINTEXT and SASL_SSL authentications, with self-signed certificates. The condition to enable the SSLContext has been changed to check for security_protocol ending with SSL. But if you prefer the old condition based on an explicit list of security protocols (like Integration tests were testing the |
My new revision fixes the following issues:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @jouir
There is an error raised by flake, other than that it looks great to me.
Add `security_protocol`, `sasl_mechanism`, `sasl_plain_username` and `sasl_plain_password` arguments like aiokafka.AIOKafkaConsumer client. Support SASL_PLAINTEXT and SASL_SSL security protocol. Support and test SASL PLAIN mechanism with both PLAINTEXT and SSL connections. A self-signed certificate is used for SSL connections. Add `verify_mode` like ssl.SSLContext.verify_mode to enable or disable SSL certificate verification at connection to Kafka brokers using SSL seucurity protocols. Signed-off-by: Julien Riou <[email protected]>
An unused line was left over. It's now removed. |
Add
security_protocol
,sasl_mechanism
,sasl_plain_username
andsasl_plain_password
arguments like aiokafka.AIOKafkaConsumer client.https://aiokafka.readthedocs.io/en/stable/consumer.html