-
-
Notifications
You must be signed in to change notification settings - Fork 154
BE: SR: Add compatibility w/ GCP SR #1153
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
e9d5a7d
5392e77
0726114
aaa04b6
6ba0bc8
f2e8a53
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 |
---|---|---|
|
@@ -43,8 +43,6 @@ public class SchemaRegistrySerde implements BuiltInSerde { | |
private static final byte SR_PAYLOAD_MAGIC_BYTE = 0x0; | ||
private static final int SR_PAYLOAD_PREFIX_LENGTH = 5; | ||
private static final String CUSTOM_BEARER_AUTH_CREDENTIALS_SOURCE = "CUSTOM"; | ||
private static final String GCP_BEARER_AUTH_CUSTOM_PROVIDER_CLASS = | ||
"com.google.cloud.hosted.kafka.auth.GcpBearerAuthCredentialProvider"; | ||
|
||
public static String name() { | ||
return "SchemaRegistry"; | ||
|
@@ -80,13 +78,15 @@ public void autoConfigure(PropertyResolver kafkaClusterProperties, | |
urls, | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.username", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.password", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistrySsl.keystoreLocation", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistrySsl.keystorePassword", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststoreLocation", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststorePassword", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("gcpSchemaRegistry", Boolean.class).orElse(false) | ||
kafkaClusterProperties.getProperty("ssl.truststorePassword", String.class).orElse(null) | ||
), | ||
kafkaClusterProperties.getProperty("gcpSchemaRegistry", Boolean.class).orElse(false), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryKeySchemaNameTemplate", String.class).orElse("%s-key"), | ||
kafkaClusterProperties.getProperty("schemaRegistrySchemaNameTemplate", String.class).orElse("%s-value"), | ||
kafkaClusterProperties.getProperty("schemaRegistryCheckSchemaExistenceForDeserialize", Boolean.class) | ||
|
@@ -108,13 +108,15 @@ public void configure(PropertyResolver serdeProperties, | |
urls, | ||
serdeProperties.getProperty("username", String.class).orElse(null), | ||
serdeProperties.getProperty("password", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
serdeProperties.getProperty("keystoreLocation", String.class).orElse(null), | ||
serdeProperties.getProperty("keystorePassword", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststoreLocation", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststorePassword", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("gcpSchemaRegistry", Boolean.class).orElse(false) | ||
kafkaClusterProperties.getProperty("ssl.truststorePassword", String.class).orElse(null) | ||
), | ||
kafkaClusterProperties.getProperty("gcpSchemaRegistry", Boolean.class).orElse(false), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
serdeProperties.getProperty("keySchemaNameTemplate", String.class).orElse("%s-key"), | ||
serdeProperties.getProperty("schemaNameTemplate", String.class).orElse("%s-value"), | ||
serdeProperties.getProperty("checkSchemaExistenceForDeserialize", Boolean.class) | ||
|
@@ -126,26 +128,27 @@ public void configure(PropertyResolver serdeProperties, | |
void configure( | ||
List<String> schemaRegistryUrls, | ||
SchemaRegistryClient schemaRegistryClient, | ||
boolean gcpSchemaRegistry, | ||
String bearerAuthCustomProviderClass, | ||
String keySchemaNameTemplate, | ||
String valueSchemaNameTemplate, | ||
boolean checkTopicSchemaExistenceForDeserialize) { | ||
this.schemaRegistryUrls = schemaRegistryUrls; | ||
this.schemaRegistryClient = schemaRegistryClient; | ||
this.keySchemaNameTemplate = keySchemaNameTemplate; | ||
this.valueSchemaNameTemplate = valueSchemaNameTemplate; | ||
this.schemaRegistryFormatters = MessageFormatter.createMap(schemaRegistryClient, gcpSchemaRegistry); | ||
this.schemaRegistryFormatters = MessageFormatter.createMap(schemaRegistryClient, bearerAuthCustomProviderClass); | ||
this.checkSchemaExistenceForDeserialize = checkTopicSchemaExistenceForDeserialize; | ||
} | ||
|
||
private static SchemaRegistryClient createSchemaRegistryClient(List<String> urls, | ||
@Nullable String username, | ||
@Nullable String password, | ||
@Nullable String bearerAuthCustomProviderClass, | ||
@Nullable String keyStoreLocation, | ||
@Nullable String keyStorePassword, | ||
@Nullable String trustStoreLocation, | ||
@Nullable String trustStorePassword, | ||
boolean gcpSchemaRegistry) { | ||
@Nullable String trustStorePassword | ||
) { | ||
Map<String, String> configs = new HashMap<>(); | ||
if (username != null && password != null) { | ||
configs.put(BASIC_AUTH_CREDENTIALS_SOURCE, "USER_INFO"); | ||
|
@@ -175,9 +178,9 @@ private static SchemaRegistryClient createSchemaRegistryClient(List<String> urls | |
keyStorePassword); | ||
} | ||
|
||
if (gcpSchemaRegistry) { | ||
if (bearerAuthCustomProviderClass != null) { | ||
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. Why is this called a 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. I use this to reference this class. And I changed the bearer token implementation for the WebClient using this class too. Sorry 🙏 . |
||
configs.put(SchemaRegistryClientConfig.BEARER_AUTH_CREDENTIALS_SOURCE, CUSTOM_BEARER_AUTH_CREDENTIALS_SOURCE); | ||
configs.put(SchemaRegistryClientConfig.BEARER_AUTH_CUSTOM_PROVIDER_CLASS, GCP_BEARER_AUTH_CUSTOM_PROVIDER_CLASS); | ||
configs.put(SchemaRegistryClientConfig.BEARER_AUTH_CUSTOM_PROVIDER_CLASS, bearerAuthCustomProviderClass); | ||
} | ||
|
||
return new CachedSchemaRegistryClient( | ||
|
Uh oh!
There was an error while loading. Please reload this page.