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

CSP-768: Change the SR Client auth properties name #652

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/schema-registry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,26 @@ Kafka Producer Integration with SchemaRegistry
config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName());


.. code:: java

config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
config.put(SchemaRegistryClient.Configuration.SCHEMA_REGISTRY_URL.name(), props.get(SCHEMA_REGISTRY_URL));
config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName());
config.put(SchemaRegistryClient.Configuration.AUTH_USERNAME, "user1");
config.put(SchemaRegistryClient.Configuration.AUTH_PASSWORD, "password");

Important settings from the above are
**schema.registry.url**:
This should be set to where the registry server is running ex: http://localhost:9090/api/v1

**schema.registry.auth.username**:
If the schema registry service is behind a proxy that supports Basic Authentication, the user name part of the credentials can be provided here.

**schema.registry.auth.password**:
If the schema registry service is behind a proxy that supports Basic Authentication, the password part of the credentials can be provided here.

**key.serializer**:
*StringSerializer* is used in the above example.

Expand Down Expand Up @@ -191,11 +207,26 @@ Kafka Consumer Integration with SchemaRegistry
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, KafkaAvroDeserializer.class.getName());

.. code:: java

config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
config.put(SchemaRegistryClient.Configuration.SCHEMA_REGISTRY_URL.name(), props.get(SCHEMA_REGISTRY_URL));
config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName());
config.put(SchemaRegistryClient.Configuration.AUTH_USERNAME, "user1");
config.put(SchemaRegistryClient.Configuration.AUTH_PASSWORD, "password");

Important settings from the above are

**schema.registry.url**:
This should be set to where the registry server is running ex: http://localhost:9090/api/v1

**schema.registry.auth.username**:
If the schema registry service is behind a proxy that supports Basic Authentication, the user name part of the credentials can be provided here.

**schema.registry.auth.password**:
If the schema registry service is behind a proxy that supports Basic Authentication, the password part of the credentials can be provided here.

**key.deserializer**:
*StringDeserializer* is used in the above example.

Expand Down
4 changes: 2 additions & 2 deletions schema-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ sslMap.put("trustStoreType", "JKS");
sslMap.put("trustStorePath", "/path/to/truststore/file");
sslMap.put("trustStorePassword", "truststorepassword");
config.put("schema.registry.client.ssl", sslMap);
config.put(SchemaRegistryClient.Configuration.BASIC_AUTH_USERNAME, "knoxproxyusername");
config.put(SchemaRegistryClient.Configuration.BASIC_AUTH_PASSWORD, "knoxproxypassword");
config.put(SchemaRegistryClient.Configuration.AUTH_USERNAME, "knoxproxyusername");
config.put(SchemaRegistryClient.Configuration.AUTH_PASSWORD, "knoxproxypassword");
SchemaRegistryClient schemaRegistryClient = new SchemaRegistryClient(config);
```
## Using schema related APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ public SchemaRegistryClient(Map<String, ?> conf) {
}
client = clientBuilder.build();
client.register(MultiPartFeature.class);
String userName = configuration.getValue(Configuration.BASIC_AUTH_USERNAME.name());
String password = configuration.getValue(Configuration.BASIC_AUTH_PASSWORD.name());
String userName = configuration.getValue(Configuration.AUTH_USERNAME.name());
String password = configuration.getValue(Configuration.AUTH_PASSWORD.name());
if (StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(password)){
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(userName, password);
client.register(feature);
Expand Down Expand Up @@ -1419,21 +1419,23 @@ public static final class Configuration {
/**
* Username for basic authentication.
*/
public static final ConfigEntry<String> BASIC_AUTH_USERNAME =
public static final ConfigEntry<String> AUTH_USERNAME =
ConfigEntry.optional("schema.registry.auth.username",
String.class,
"Username for basic authentication",
null,
ConfigEntry.StringConverter.get(),
ConfigEntry.NonEmptyStringValidator.get());

/**
* Password for basic authentication.
*/
public static final ConfigEntry<String> BASIC_AUTH_PASSWORD =
public static final ConfigEntry<String> AUTH_PASSWORD =
ConfigEntry.optional("schema.registry.auth.password",
String.class,
"Password for basic authentication",
null,
ConfigEntry.StringConverter.get(),
ConfigEntry.NonEmptyStringValidator.get());

private final Map<String, ?> config;
Expand Down