wbarnha / kafka-python-ng

Fork for Python client for Apache Kafka
https://wbarnha.github.io/kafka-python-ng/
Apache License 2.0
42 stars 4 forks source link

Support AWS_MSK_IAM authentication #147

Closed wbarnha closed 3 months ago

wbarnha commented 3 months ago

This pull request addresses issue #2232 by adding an AWS_MSK_IAM authentication mechanism. A detailed description of the authentication scheme is available here:

I understand that kafka-python may not be the appropriate place to put a vendor-specific authentication mechanism. If that's the case maybe it's better suited as a plug-in? The library doesn't support auth extensions at the moment but it doesn't look like a huge lift to get there.

To use the mechanism pass the following keyword arguments when initializing a class:

security_protocol='SASL_SSL',
sasl_mechanism='AWS_MSK_IAM',
bootstrap_servers=[
    'b-1.cluster.x.y.kafka.region.amazonaws.com:9098',
    ...
],

The credentials and region will be pulled using botocore.session.Session. Using the mechanism requires the botocore library which can be installed with:

pip install botocore

TODO:


This change is Reviewable

wbarnha commented 3 months ago

Resuming in #170.