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

Kafka SaslOptions #8

Merged
merged 1 commit into from
May 5, 2023
Merged

Kafka SaslOptions #8

merged 1 commit into from
May 5, 2023

Conversation

tyt2y3
Copy link
Member

@tyt2y3 tyt2y3 commented Apr 28, 2023

Fixes #5

Comment on lines +328 to +343
#[test]
fn test_sasl_options() {
let mut options = KafkaConnectOptions::default();
options.set_security_protocol(SecurityProtocol::SaslSsl);
options.set_sasl_options(
SaslOptions::new(SaslMechanism::Plain)
.username("uu")
.password("pp"),
);
let mut client_config = ClientConfig::new();
options.make_client_config(&mut client_config);
assert_eq!(client_config.get("security.protocol"), Some("SASL_SSL"));
assert_eq!(client_config.get("sasl.mechanism"), Some("PLAIN"));
assert_eq!(client_config.get("sasl.username"), Some("uu"));
assert_eq!(client_config.get("sasl.password"), Some("pp"));
}
Copy link
Member Author

@tyt2y3 tyt2y3 Apr 28, 2023

Choose a reason for hiding this comment

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

Example

@tyt2y3
Copy link
Member Author

tyt2y3 commented Apr 28, 2023

Does this work for you? @hgzimmerman

@hgzimmerman
Copy link
Contributor

hgzimmerman commented May 3, 2023

As far as my limited understanding of SASL goes, it looks good.

My example had an additional bootstrap.servers option set, which I'm unsure if is needed for SASL authentication to work. (The bootstrap server(s) provides metadata used to route a client to a particular node(s) to connect to for a topic, among other things). I'm unsure how commonly used that option is or if it is worth making a special function for it.

I think if that proves to be necessary, its best followed up on separately with a set_bootstrap_server(&str) function.

@tyt2y3
Copy link
Member Author

tyt2y3 commented May 4, 2023

Thanks. Actually the "bootstrap.servers" key is set for every connection with the values coming from StreamerUri. May be your bootstrap.servers string is not compatible with Url?

client_config.set(BaseOptionKey::BootstrapServers, cluster_uri(streamer)?);

client_config.set(BaseOptionKey::BootstrapServers, cluster_uri(streamer)?);

@hgzimmerman
Copy link
Contributor

hgzimmerman commented May 4, 2023

No, my connection profile was just copied nearly verbatim from confluentinc/librdkafka#4119 (comment) and I wasn't aware that the config option was already set elsewhere in sea-streamer-kafka. I believe that the url I was using works anyways.

This is good news to me, in that I get to remove some redundant code and config values.

@tyt2y3 tyt2y3 merged commit 7503809 into main May 5, 2023
@tyt2y3
Copy link
Member Author

tyt2y3 commented May 5, 2023

Cool! I am going to make a patch release this week end, including this and your previous PR to redis.

@tyt2y3
Copy link
Member Author

tyt2y3 commented May 7, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Provide example for Kafka authentication
2 participants