-
Notifications
You must be signed in to change notification settings - Fork 859
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
Add support for AWS MSK IAM #513
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
<protobuf.version>3.22.3</protobuf.version> | ||
<testcontainers.version>1.18.0</testcontainers.version> | ||
<kafka-libs.version>7.3.3</kafka-libs.version> | ||
<msk.auth.version>1.0.0</msk.auth.version> | ||
<sts.sdk.version>1.11.704</sts.sdk.version> | ||
</properties> | ||
|
||
<scm> | ||
|
@@ -76,6 +78,11 @@ | |
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>software.amazon.msk</groupId> | ||
<artifactId>aws-msk-iam-auth</artifactId> | ||
<version>${msk.auth.version}</version> | ||
Comment on lines
+82
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davideicardi What's your view on this? I'd rather not become dependent on Amazon JARs. The code doesn't need them, but the dependency exists when I propose to resolve this by changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it seems to be a good idea to me. Loading extra classes could be a nice feature also for other cases. We just have to write a good documentation on this kind of stuff. |
||
</dependency> | ||
<dependency> | ||
<groupId>io.confluent</groupId> | ||
<artifactId>kafka-avro-serializer</artifactId> | ||
|
@@ -143,6 +150,12 @@ | |
<groupId>org.springframework.kafka</groupId> | ||
<artifactId>spring-kafka</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-sts</artifactId> | ||
<version>${sts.sdk.version}</version> | ||
</dependency> | ||
Comment on lines
+154
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-undertow</artifactId> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,15 +28,22 @@ public final class KafkaConfiguration { | |||||
private String truststoreFile; | ||||||
private String propertiesFile; | ||||||
private String keystoreFile; | ||||||
private String jaasConfig; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
private String clientCallback; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
private String iamEnabled; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this a |
||||||
|
||||||
public void applyCommon(Properties properties) { | ||||||
properties.setProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, brokerConnect); | ||||||
|
||||||
if (isSecured) { | ||||||
LOG.warn("The 'isSecured' property is deprecated; consult README.md on the preferred way to configure security"); | ||||||
properties.put(SaslConfigs.SASL_MECHANISM, saslMechanism); | ||||||
} | ||||||
|
||||||
if (isSecured || securityProtocol.equals("SSL")) { | ||||||
LOG.info("Setting sasl mechanism to {}", saslMechanism); | ||||||
properties.put(SaslConfigs.SASL_MECHANISM, saslMechanism); | ||||||
|
||||||
if (isSecured || securityProtocol.equals("SSL") || securityProtocol.equals("SASL_SSL")) { | ||||||
LOG.info("Setting security protocol to {}", securityProtocol); | ||||||
properties.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, securityProtocol); | ||||||
} | ||||||
|
||||||
|
@@ -45,6 +52,12 @@ public void applyCommon(Properties properties) { | |||||
LOG.info("Assigning truststore location to {}", truststoreFile); | ||||||
properties.put("ssl.truststore.location", truststoreFile); | ||||||
} | ||||||
LOG.info("Is iam enabled : {}", iamEnabled); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spell IAM in uppercase |
||||||
if (Boolean.parseBoolean(iamEnabled)) { | ||||||
LOG.info("Setting sasl.jaas.config {} and sasl and callback callback properties {}", jaasConfig, clientCallback); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
properties.put(SaslConfigs.SASL_CLIENT_CALLBACK_HANDLER_CLASS, clientCallback); | ||||||
properties.put(SaslConfigs.SASL_JAAS_CONFIG, jaasConfig); | ||||||
} | ||||||
|
||||||
LOG.info("Checking keystore file {}", keystoreFile); | ||||||
if (new File(keystoreFile).isFile()) { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,9 +38,12 @@ kafdrop.monitor: | |||||
|
||||||
kafka: | ||||||
brokerConnect: localhost:9092 | ||||||
isSecured: false | ||||||
saslMechanism: "PLAIN" | ||||||
securityProtocol: "SASL_PLAINTEXT" | ||||||
isSecured: "${KAFKA_IS_SECURED:false}" | ||||||
saslMechanism: "${KAFKA_SASL_MECHANISM:PLAIN}" | ||||||
securityProtocol: "${KAFKA_SECURITY_PROTOCOL:SASL_PLAINTEXT}" | ||||||
truststoreFile: "${KAFKA_TRUSTSTORE_FILE:kafka.truststore.jks}" | ||||||
propertiesFile : "${KAFKA_PROPERTIES_FILE:kafka.properties}" | ||||||
keystoreFile: "${KAFKA_KEYSTORE_FILE:kafka.keystore.jks}" | ||||||
iamEnabled: "${KAFKA_IAM_ENABLED:false}" | ||||||
jaasConfig: "${KAFKA_JAAS_CONFIG}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
clientCallback: "software.amazon.msk.auth.iam.IAMClientCallbackHandler" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
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.
If next comment is accepted, this can be removed.