Skip to content

AWS IAM authentication #178

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

Merged
merged 11 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 11.6.1
- Expose the SASL client callback class setting to the Logstash configuration [#177](https://github.com/logstash-plugins/logstash-integration-kafka/pull/177)
- Adds a mechanism to load AWS IAM authentication as SASL client libraries at startup [#178](https://github.com/logstash-plugins/logstash-integration-kafka/pull/178)

## 11.6.0
- Support additional `oauth` and `sasl` configuration options for configuring kafka client [#189](https://github.com/logstash-plugins/logstash-integration-kafka/pull/189)

Expand Down
27 changes: 27 additions & 0 deletions docs/input-kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ For more information see https://kafka.apache.org/{kafka_client_doc}/documentati

Kafka consumer configuration: https://kafka.apache.org/{kafka_client_doc}/documentation.html#consumerconfigs

[id="plugins-{type}s-{plugin}-aws_msk_iam_auth"]
==== AWS MSK IAM authentication
If you use AWS MSK, the AWS MSK IAM access control enables you to handle both authentication and authorization for your MSK cluster with AWS IAM.
For more information on this AWS MSK feature see the https://docs.aws.amazon.com/msk/latest/developerguide/iam-access-control.html[AWS documentation].

To use this Kafka input with AWS MSK IAM authentication, download the uber jar which contains the client library for
this specific cloud vendor and all the transitive dependencies from this https://github.com/elastic/logstash-kafka-iams-packages/releases[repository].
Configure the following setting:
```
security_protocol => "SASL_SSL"
sasl_mechanism => "AWS_MSK_IAM"
sasl_iam_jar_paths => ["/path/to/aws_iam_uber.jar"]
sasl_jaas_config => "software.amazon.msk.auth.iam.IAMLoginModule required;"
sasl_client_callback_handler_class => "software.amazon.msk.auth.iam.IAMClientCallbackHandler"
```
For more IAM authentication configurations, see the https://github.com/aws/aws-msk-iam-auth[AWS MSK IAM authentication library documentation].

==== Metadata fields

The following metadata from Kafka broker are added under the `[@metadata]` field:
Expand Down Expand Up @@ -133,6 +150,7 @@ See the https://kafka.apache.org/{kafka_client_doc}/documentation for more detai
| <<plugins-{type}s-{plugin}-sasl_client_callback_handler_class>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_oauthbearer_token_endpoint_url>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_oauthbearer_scope_claim_name>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_iam_jar_paths>> |<<array,array>>|No
Copy link
Member

Choose a reason for hiding this comment

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

not ordered alphabetically :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sasl_iam_jar_paths should stay before sasl_login_callback_handler_class, or we also fix sasl_oauthbearer* sasl_jaas_config and sasl_kerberos_service_name ordering. Maybe sorting the whole settings section should be done in another PR.

| <<plugins-{type}s-{plugin}-sasl_login_callback_handler_class>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_login_connect_timeout_ms>> |<<number,number>>|No
| <<plugins-{type}s-{plugin}-sasl_login_read_timeout_ms>> |<<number,number>>|No
Expand Down Expand Up @@ -584,6 +602,14 @@ The URL for the OAuth 2.0 issuer token endpoint.

(optional) The override name of the scope claim.

[id="plugins-{type}s-{plugin}-sasl_iam_jar_paths"]
===== `sasl_iam_jar_paths`
* Value type is <<arrays,array>>
* There is no default value for this setting.

Contains the list of paths to jar libraries that contains cloud providers MSK IAM's clients.
There is one jar per provider and can be retrieved as described in <<"plugins-{type}s-{plugin}-aws_msk_iam_auth">>.

[id="plugins-{type}s-{plugin}-sasl_login_callback_handler_class"]
===== `sasl_login_callback_handler_class`
* Value type is <<string,string>>
Expand Down Expand Up @@ -654,6 +680,7 @@ This can be defined either in Kafka's JAAS config or in Kafka's config.

http://kafka.apache.org/documentation.html#security_sasl[SASL mechanism] used for client connections.
This may be any mechanism for which a security provider is available.
For AWS MSK IAM authentication use `AWS_MSK_IAM`.
GSSAPI is the default mechanism.

[id="plugins-{type}s-{plugin}-schema_registry_key"]
Expand Down
27 changes: 27 additions & 0 deletions docs/output-kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ https://kafka.apache.org/{kafka_client_doc}/documentation.html#producerconfigs

NOTE: This plugin does not support using a proxy when communicating to the Kafka broker.

[id="plugins-{type}s-{plugin}-aws_msk_iam_auth"]
==== AWS MSK IAM authentication
If you use AWS MSK, the AWS MSK IAM access control enables you to handle both authentication and authorization for your MSK cluster with AWS IAM.
For more information on this AWS MSK feature see the https://docs.aws.amazon.com/msk/latest/developerguide/iam-access-control.html[AWS documentation].

To use this Kafka input with AWS MSK IAM authentication, download the uber jar which contains the client library for
this specific cloud vendor and all the transitive dependencies from this https://github.com/elastic/logstash-kafka-iams-packages/releases[repository].
Configure the following setting:
```
security_protocol => "SASL_SSL"
sasl_mechanism => "AWS_MSK_IAM"
sasl_iam_jar_paths => ["/path/to/aws_iam_uber.jar"]
sasl_jaas_config => "software.amazon.msk.auth.iam.IAMLoginModule required;"
sasl_client_callback_handler_class => "software.amazon.msk.auth.iam.IAMClientCallbackHandler"
```
For more IAM authentication configurations, see the https://github.com/aws/aws-msk-iam-auth[AWS MSK IAM authentication library documentation].

[id="plugins-{type}s-{plugin}-options"]
==== Kafka Output Configuration Options

Expand Down Expand Up @@ -104,6 +121,7 @@ See the https://kafka.apache.org/{kafka_client_doc}/documentation for more detai
| <<plugins-{type}s-{plugin}-sasl_client_callback_handler_class>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_oauthbearer_token_endpoint_url>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_oauthbearer_scope_claim_name>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_iam_jar_paths>> |<<array,array>>|No
| <<plugins-{type}s-{plugin}-sasl_login_callback_handler_class>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-sasl_login_connect_timeout_ms>> |<<number,number>>|No
| <<plugins-{type}s-{plugin}-sasl_login_read_timeout_ms>> |<<number,number>>|No
Expand Down Expand Up @@ -420,6 +438,14 @@ The URL for the OAuth 2.0 issuer token endpoint.

(optional) The override name of the scope claim.

[id="plugins-{type}s-{plugin}-sasl_iam_jar_paths"]
===== `sasl_iam_jar_paths`
* Value type is <<arrays,array>>
* There is no default value for this setting.

Contains the list of paths to jar libraries that contains cloud providers MSK IAM's clients.
There is one jar per provider and can be retrieved as described in <<"plugins-{type}s-{plugin}-aws_msk_iam_auth">>.

[id="plugins-{type}s-{plugin}-sasl_login_callback_handler_class"]
===== `sasl_login_callback_handler_class`
* Value type is <<string,string>>
Expand Down Expand Up @@ -490,6 +516,7 @@ This can be defined either in Kafka's JAAS config or in Kafka's config.

http://kafka.apache.org/documentation.html#security_sasl[SASL mechanism] used for client connections.
This may be any mechanism for which a security provider is available.
For AWS MSK IAM authentication use `AWS_MSK_IAM`.
GSSAPI is the default mechanism.

[id="plugins-{type}s-{plugin}-security_protocol"]
Expand Down
4 changes: 3 additions & 1 deletion lib/logstash/inputs/kafka.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
config :sasl_oauthbearer_scope_claim_name, :validate => :string, :default => 'scope' # Kafka default
# SASL login callback handler class
config :sasl_login_callback_handler_class, :validate => :string
# Path to the jar containing client and all dependencies for SASL IAM authentication of specific cloud vendor
config :sasl_iam_jar_paths, :validate => :array
# (optional) The duration, in milliseconds, for HTTPS connect timeout
config :sasl_login_connect_timeout_ms, :validate => :number
# (optional) The duration, in milliseconds, for HTTPS read timeout.
Expand All @@ -224,7 +226,7 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
config :sasl_login_retry_backoff_ms, :validate => :number, :default => 100 # Kafka default
# (optional) The maximum duration, in milliseconds, for HTTPS call attempts.
config :sasl_login_retry_backoff_max_ms, :validate => :number, :default => 10000 # Kafka default
# http://kafka.apache.org/documentation.html#security_sasl[SASL mechanism] used for client connections.
# http://kafka.apache.org/documentation.html#security_sasl[SASL mechanism] used for client connections.
# This may be any mechanism for which a security provider is available.
# GSSAPI is the default mechanism.
config :sasl_mechanism, :validate => :string, :default => "GSSAPI"
Expand Down
2 changes: 2 additions & 0 deletions lib/logstash/outputs/kafka.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class LogStash::Outputs::Kafka < LogStash::Outputs::Base
config :security_protocol, :validate => ["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"], :default => "PLAINTEXT"
# SASL client callback handler class
config :sasl_client_callback_handler_class, :validate => :string
# Path to the jar containing client and all dependencies for SASL IAM authentication of specific cloud vendor
config :sasl_iam_jar_paths, :validate => :array
# The URL for the OAuth 2.0 issuer token endpoint.
config :sasl_oauthbearer_token_endpoint_url, :validate => :string
# (optional) The override name of the scope claim.
Expand Down
1 change: 1 addition & 0 deletions lib/logstash/plugin_mixins/kafka/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def set_sasl_config(props)
props.put("sasl.login.read.timeout.ms", sasl_login_read_timeout_ms.to_s) unless sasl_login_read_timeout_ms.nil?
props.put("sasl.login.retry.backoff.ms", sasl_login_retry_backoff_ms.to_s) unless sasl_login_retry_backoff_ms.nil?
props.put("sasl.login.retry.backoff.max.ms", sasl_login_retry_backoff_max_ms.to_s) unless sasl_login_retry_backoff_max_ms.nil?
sasl_iam_jar_paths&.each {|jar_path| require jar_path }
end

def reassign_dns_lookup
Expand Down
2 changes: 1 addition & 1 deletion logstash-integration-kafka.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'logstash-integration-kafka'
s.version = '11.6.0'
s.version = '11.6.1'
s.licenses = ['Apache-2.0']
s.summary = "Integration with Kafka - input and output plugins"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline "+
Expand Down