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

Add support for basic auth in maven schema registry plugin #907

Merged
merged 3 commits into from
Oct 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig;

import org.apache.avro.Schema;
import org.apache.avro.SchemaParseException;
Expand All @@ -30,11 +31,14 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

public abstract class SchemaRegistryMojo extends AbstractMojo {

@Parameter(required = true)
List<String> schemaRegistryUrls;
@Parameter
String userInfoConfig;
private SchemaRegistryClient client;

void client(SchemaRegistryClient client) {
Expand All @@ -43,9 +47,15 @@ void client(SchemaRegistryClient client) {

protected SchemaRegistryClient client() {
if (null == this.client) {
this.client = new CachedSchemaRegistryClient(this.schemaRegistryUrls, 1000, null);
Map<String, String> config = new HashMap<>();
if (userInfoConfig != null) {
// Note that BASIC_AUTH_CREDENTIALS_SOURCE is not configurable as the plugin only supports
// a single schema registry URL, so there is no additional utility of the URL source.
config.put(SchemaRegistryClientConfig.BASIC_AUTH_CREDENTIALS_SOURCE, "USER_INFO");
config.put(SchemaRegistryClientConfig.USER_INFO_CONFIG, userInfoConfig);
}
this.client = new CachedSchemaRegistryClient(this.schemaRegistryUrls, 1000, config);
}

return this.client;
}

Expand Down