NIFI-10991 Add AWS MSK IAM support to Kafka processors#6846
NIFI-10991 Add AWS MSK IAM support to Kafka processors#6846nandorsoma wants to merge 5 commits intoapache:mainfrom
Conversation
...-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/component/KafkaClientComponent.java
Outdated
Show resolved
Hide resolved
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for implementing this feature @nandorsoma, the implementation and integration approach with the shared Kafka library looks good.
I agree with @turcsanyip that the AWS Debug Credentials property seems unnecessary and should be removed. Other than that, I noted several minor naming and wording recommendations.
...-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/component/KafkaClientComponent.java
Outdated
Show resolved
Hide resolved
...-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/component/KafkaClientComponent.java
Outdated
Show resolved
Hide resolved
...fi-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/login/IAMLoginConfigProvider.java
Outdated
Show resolved
Hide resolved
...fi-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/login/IAMLoginConfigProvider.java
Outdated
Show resolved
Hide resolved
...fi-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/login/IAMLoginConfigProvider.java
Outdated
Show resolved
Hide resolved
...dle/nifi-kafka-shared/src/main/java/org/apache/nifi/kafka/shared/property/SaslMechanism.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/nifi/kafka/shared/property/provider/StandardKafkaPropertyProvider.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/nifi/kafka/shared/property/provider/StandardKafkaPropertyProvider.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/nifi/kafka/shared/property/provider/StandardKafkaPropertyProvider.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/apache/nifi/kafka/shared/validation/KafkaClientCustomValidationFunction.java
Outdated
Show resolved
Hide resolved
|
Thank you for the review @turcsanyip and @exceptionfactory! I've changed the code based on your advice. |
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for making the adjustments @nandorsoma, the current version looks good from a code perspective.
Do you have any additional feedback @turcsanyip?
|
@nandorsoma There seems to be regression in the kerberos login. |
|
Thanks for noticing it @turcsanyip! I've changed the code, tested it with the 3 different Kerberos config methods. |
turcsanyip
left a comment
There was a problem hiding this comment.
Thanks for the kerberos fix @nandorsoma!
I tested the kerberos cases too, and also SCRAM and the new AWS IAM. All work properly.
While I was configuring the different authentication mechanisms, I felt quite confusing that the kerberos properties are always shown on the processor, even when they are not relevant, and it is not clear which properties belong to the given authentication type that should be filled in (in case of PLAINTEXT or SCRAM, and also the new AWS IAM). Not sure why dependsOn() has not been applied here so far. I would suggest implementing it either in this PR or in a follow-up one.
| (ASLv2) aws-msk-iam-auth | ||
| The following NOTICE information applies: | ||
| aws-msk-iam-auth | ||
| Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
There was a problem hiding this comment.
aws-msk-iam-auth pulls in a couple of other dependencies transitively (e.g. further aws libraries, netty).
The NOTICE file needs to be updated with those as well.
There was a problem hiding this comment.
Thanks for noticing it! Will update soon.
| } | ||
| } | ||
|
|
||
| private void validateAWSIAMMechanism(final ValidationContext validationContext, final Collection<ValidationResult> results) { |
There was a problem hiding this comment.
Minor:
| private void validateAWSIAMMechanism(final ValidationContext validationContext, final Collection<ValidationResult> results) { | |
| private void validateAwsMskIamMechanism(final ValidationContext validationContext, final Collection<ValidationResult> results) { |
| final String saslMechanism = validationContext.getProperty(SASL_MECHANISM).getValue(); | ||
|
|
||
| if (SaslMechanism.AWS_MSK_IAM.getValue().equals(saslMechanism) && !StandardKafkaPropertyProvider.isAwsMskIamCallbackHandlerFound()) { |
There was a problem hiding this comment.
Minor: SaslMechanism.getSaslMechanism() could be used instead of the String comparison.
| final String saslMechanism = validationContext.getProperty(SASL_MECHANISM).getValue(); | |
| if (SaslMechanism.AWS_MSK_IAM.getValue().equals(saslMechanism) && !StandardKafkaPropertyProvider.isAwsMskIamCallbackHandlerFound()) { | |
| final SaslMechanism saslMechanism = SaslMechanism.getSaslMechanism(validationContext.getProperty(SASL_MECHANISM).getValue()); | |
| if (SaslMechanism.AWS_MSK_IAM == saslMechanism && !StandardKafkaPropertyProvider.isAwsMskIamCallbackHandlerFound()) { |
@turcsanyip Due to changes over time, there are multiple ways to configure Kerberos credentials, so that is part of the reason that some Kerberos properties are always shown. It might be possible to improve this in some scenarios, and that could be a useful improvement in a separate effort. |
|
Thank you @turcsanyip for your review! I've changed what you have asked except the dependsOn part. I'll do that in a separate PR as @exceptionfactory suggested. |
turcsanyip
left a comment
There was a problem hiding this comment.
Thanks @nandorsoma and @exceptionfactory!
Let's investigate the improvements around the kerberos properties in a separate jira. Actually, the issue is two-fold:
- hide all kerberos properties when kerberos is not relevant (and the SSL service similarly): I believe it can be solved with
dependsOn()easily and would be a useful improvement in this processor - better handling of the different kerberos configuration methods maintained due to historical reasons (the same issue affects other processors / services too, like SSL and Proxy config): the solution is not trivial here but worth investigating
+1 LGTM
Merging to main.
Summary
NIFI-10991
This PR adds AWS IAM for authentication and authorization functionality against Amazon MSK clusters that have AWS IAM enabled as an authentication mechanism. You need to enable
include-kafka-awsprofile to include the required module. A previous PR (#5291) tried to tackle this problem. In this PR, though, we decided not to includeawsRoleArn, awsRoleSessionName, awsStsRegionas properties because they just add extra complexity with minimal value. When NiFi runs in EC2, and no profile is specified, the processor will use the role assigned to the EC2 instance. When NiFi runs locally, we can define a profile name that will reference a profile in~/.aws/credentials(depends on os) file. In this file, you can specify the above properties along with the access key id and secret.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation