Skip to content

Add MSK IAM authentication via SASL/OAUTHBEARER - #24

Merged
jghoman merged 3 commits into
mainfrom
add-msk-iam-auth
Mar 30, 2026
Merged

jghoman merged 3 commits into
mainfrom
add-msk-iam-auth

Conversation

@jghoman

@jghoman jghoman commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Test plan

  • 134 unit tests pass (6 new for OAUTHBEARER callback wiring)
  • 15 integration tests pass (no regressions)
  • Lint + format clean
  • Deploy to dev with KAFKA_CONSUMER_SASL_MECHANISMS=OAUTHBEARER and KAFKA_CONSUMER_SECURITY_PROTOCOL=SASL_SSL

When KAFKA_CONSUMER_SASL_MECHANISMS=OAUTHBEARER is set, automatically
registers an oauth_cb that generates MSK IAM tokens via
aws-msk-iam-sasl-signer-python. Both AdminClient and Consumer get
the callback through _base_kafka_config.

- Lazy import of signer (clear error if not installed)
- Warns if singular sasl.mechanism is set (librdkafka ignores it)
- Logs token generation failures for prod debugging
- Optional dep: pip install millpond[msk-iam] (always in Docker image)
- Documents credential isolation (IRSA for Kafka, static for DuckDB S3)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds MSK IAM authentication support to Millpond’s Kafka clients by wiring a SASL/OAUTHBEARER token callback into the shared Kafka client configuration, plus packaging/docs updates to keep AWS credentials isolated between Kafka (IRSA) and DuckDB S3 (static keys).

Changes:

  • Introduces _maybe_attach_oauth_cb() and hooks it into _base_kafka_config() so both AdminClient and Consumer receive the OAUTHBEARER callback.
  • Adds an optional dependency extra (msk-iam) and installs it in the Docker image by default.
  • Updates unit tests and documentation around SASL config naming (sasl.mechanisms) and AWS credential isolation.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
millpond/consumer.py Adds MSK IAM OAUTHBEARER callback wiring via shared Kafka config helper.
pyproject.toml Defines msk-iam optional dependency extra.
uv.lock Locks aws-msk-iam-sasl-signer-python and its dependency set.
Dockerfile Installs the msk-iam extra in image builds via uv sync --extra msk-iam.
tests/unit/test_consumer.py Adds unit tests for OAUTHBEARER callback behavior and config-key warning.
tests/unit/test_config.py Updates env var usage to KAFKA_CONSUMER_SASL_MECHANISMS → sasl.mechanisms.
README.md Documents Kafka vs DuckDB S3 credential isolation rationale.
AGENT.md Captures credential-isolation design decision and optional-dep rationale.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread millpond/consumer.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jghoman
jghoman merged commit cbc1218 into main Mar 30, 2026
19 checks passed
@jghoman
jghoman deleted the add-msk-iam-auth branch March 30, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants