Skip to content
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

Support connecting to Kerberos secured Kafka #7990, updated to Kafka 0.10.1.2 #8394

Closed
wants to merge 12 commits into from

Conversation

madhurkumar
Copy link

Fix for #7990

@facebook-github-bot
Copy link
Collaborator

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@electrum
Copy link
Contributor

@cawallin could someone on your team review this?

pom.xml Outdated
@@ -56,6 +56,7 @@
<dep.testng.version>6.10</dep.testng.version>
<dep.nifty.version>0.15.1</dep.nifty.version>
<dep.swift.version>0.15.2</dep.swift.version>
<dep.kafka-clients.version>0.10.2.1</dep.kafka-clients.version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't add a property for a version that is only used in one place. We use properties for related artifacts that need to be versioned together.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, modified as per suggestion.

<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>

<!--
Copy link
Contributor

Choose a reason for hiding this comment

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

Please delete rather than commenting out. The old version is available in the Git history. Commenting out code quickly clutters the code base.

Copy link
Author

Choose a reason for hiding this comment

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

Done. Thanks

@@ -68,14 +68,20 @@
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${dep.kafka-clients.version}</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Add this to the dependencyManagement section in the root POM, then remove the version here. In almost all cases, versions should only be in the root POM, ensuring versions are consistent.

(Technically, this is not necessary here, because this dependency is only used in this one module, and different plugins can actually have different versions of the same library due to class loader isolation. But we follow the rule as much as possible so it's easy for everyone to understand and not wonder why there are exceptions.)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, changes made per suggestion.

@facebook-github-bot
Copy link
Collaborator

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@madhurkumar
Copy link
Author

Thanks for review comments, changes made as per suggestion.

@cawallin
Copy link
Member

@electrum sure

@cawallin cawallin self-requested a review June 29, 2017 17:22
@gaohao
Copy link

gaohao commented Jul 8, 2017

@madhurkumar after all these changes, will it still work with kafka 0.8?

@madhurkumar
Copy link
Author

No, Kafka client versions are forward compatible not fully backward compatible. In my tests, message consumption from 0.8.2.2 broker did not work.

Copy link
Member

@cawallin cawallin left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! And sorry for the delay.

A few questions: how does this patch get the Kerberos credentials? Is it as in here http://kafka.apache.org/documentation.html#security_client_staticjaas? For Presto, we avoid setting JAAS config files; instead, we handle the security stuff using Java code. The Hive connector does this (see https://github.com/prestodb/presto/blob/master/presto-hive/src/main/java/com/facebook/presto/hive/authentication/KerberosAuthentication.java that allows you to get a Subject; you should use that Subject and wrap all calls to Kafka with doAs -- see https://github.com/airlift/airlift/blob/be20a24b5bba2c5d674a4a7280e80cf61cf3e1cc/http-client/src/main/java/io/airlift/http/client/spnego/SpnegoAuthentication.java#L111). Also, the Kafka service name should be configurable; it isn't necessarily always going to be kafka (which I'm assuming is the default).

Lastly, since you're going to update the minimum supported version of Kafka, please send an email to presto-users@googlegroups.com to see if anyone is using Presto to connect to Kafka below the new minimum supported version.

@@ -168,4 +175,28 @@ private static HostAddress toHostAddress(String value)
{
return HostAddress.fromString(value).withDefaultPort(KAFKA_DEFAULT_PORT);
}

@Config("kafka.security-protocol")
public KafkaConnectorConfig setSecurityProtocol(String securityProtocol)
Copy link
Member

Choose a reason for hiding this comment

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

This should be an enum, so that the possible values can be validated

kafka.table-names=test
kafka.hide-internal-columns=false
kafka.security-protocol=PLAINTEXT
kafka.auto-commit=false
Copy link
Member

Choose a reason for hiding this comment

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

add a newline, please

Copy link
Author

Choose a reason for hiding this comment

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

done

@gaohao
Copy link

gaohao commented Jul 29, 2017

I am using kafka 0.8 & 0.10
The current kafka plugin works well on 0.10. So Is that possible to just keep two kafka plugins.

@cawallin
Copy link
Member

@gaohao It is possible to have two Kafka plugins (the Hive plugin was similar until recently), though it does add an additional maintenance cost. The more code that can be shared, the better.

@ironchefpython
Copy link

@cawallin It would be possible to support multiple versions with the same plugin, however the plugin would need to dynamically create a classloader for the requested kafka client version.

Is there another plugin that does this as an example?

@electrum
Copy link
Contributor

electrum commented Sep 9, 2017 via email

@madhurkumar
Copy link
Author

@cawallin sorry for the delay, I checked Kafka client but it doesn't support Kerberos without JAAS file please see https://github.com/apache/kafka/blob/0.10.0/clients/src/main/java/org/apache/kafka/common/security/authenticator/AbstractLogin.java
This PR will allow users to have an option to run presto against secured Kafka using JAAS file until Kafka client is modified to support alternatives.
I have fixed other review comments, please let me know if this can be merged now.

@ashinohara
Copy link

Hello @madhurkumar - I stumbled across this PR as I am attempting to use presto against a kafka cluster with SASL enabled. It looks like the most recent version of the KafkaConsumer allows use of a property sasl.jaas.config where you can pass in the jaas configuration as text. This would allow usage without a jaas file. I would be happy to help contribute in order to get this PR moving again.

@madhurkumar
Copy link
Author

Hello @madhurkumar - I stumbled across this PR as I am attempting to use presto against a kafka cluster with SASL enabled. It looks like the most recent version of the KafkaConsumer allows use of a property sasl.jaas.config where you can pass in the jaas configuration as text. This would allow usage without a jaas file. I would be happy to help contribute in order to get this PR moving again.

Sure, make sense to remove jaas file and allow configurations through property map.

@nitenA
Copy link

nitenA commented Nov 15, 2018

Hello @madhurkumar,

I was trying connecting presto to my secured Kafka which uses Sasl protocol instead plaintext. Seems I am on old version so it didn’t find all such properties mentioned in Kafka.properties

Just FYI, I am currently using both jaas config and direct properties map to established secured connection. Let me know if you need example using Kafka client code.

Btw, Is there any presto version for now which I can use immediate to connect secure Kafka and I won’t mind providing jaas config for temporary purpose.

@nitenA
Copy link

nitenA commented Nov 16, 2018

pls let me know

@nitenA
Copy link

nitenA commented Nov 16, 2018

Please let me know

@madhurkumar
Copy link
Author

Please let me know

@nitenA you can use my fork

https://github.com/madhurkumar/presto

Conflicts:
	pom.xml
	presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaInternalFieldDescription.java
	presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaRecordSet.java
	presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaRecordSetProvider.java
	presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaSimpleConsumerManager.java
	presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaSplitManager.java
@rja1
Copy link

rja1 commented Jan 22, 2019

@madhurkumar,

Thanks for all your work on this. Do you have an ETA on when these changes will be merged to master?

@sopel39
Copy link
Contributor

sopel39 commented Feb 12, 2019

@madhurkumar Can you also create a PR to https://github.com/prestosql/presto? We’re interested in this.

@stale
Copy link

stale bot commented Aug 11, 2019

This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the task, make sure you've addressed reviewer comments, and rebase on the latest master. Thank you for your contributions!

@stale stale bot added the stale label Aug 11, 2019
@stale stale bot closed this Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants