You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
At our workplace, we are looking to use this lib to connect some of our Kafka instances to ingest data from deployments on GCP via PubSub. We use a custom timed authentication mechanism for GCP based on Hashicorp Vault and as far as we can see we cannot use a custom piece of code/plugin which would support this. As this is something quite critical and useful at my place and there are more ways of auth which people might use later, we have a proposal for this and are happy to implement and contribute if deemed useful.
Describe the solution you'd like
As this depends on com.google.api.gax which provides the interface com.google.api.gax.core.CredentialsProvider of which we can see the various kinds of uses in here, we propose the following:
Add a new config public static final String GCP_CREDENTIALS_CLASS_CONFIG to this class. This would be the fully qualified name of the class which contains the custom implementation of the the CredentialsProvider.
publicstaticConnectorCredentialsProviderfromClass(StringcredentialsClass) {
try {
finalClass<?> klass = Class.forName(credentialsClass);
finalvarobj = klass.getDeclaredConstructor().newInstance();
if (!(objinstanceofCredentialsProvider)) {
thrownewIllegalArgumentException("Supplied class %s is not a CredentialsProvider".formatted(credentialsClass));
}
returnnewConnectorCredentialsProvider(() -> ((CredentialsProvider) obj).getCredentials());
} catch (Exceptione) {
thrownewRuntimeException("Error loading class: " + e);
}
}
Implement the class for Hashicorp Vault:
importcom.google.auth.oauth2.GoogleCredentials;
importcom.google.api.gax.core.CredentialsProvider;
classHashicorpVaultCredentialsProviderimplementsCredentialsProvider {
@OverridepublicGoogleCredentialsgetCredentials() {
// do the custom calls to get the token herefinalvartoken = "this is from Hashicorp Vault";
returnnewGoogleCredentials(token);
}
}
We think that this should be generic enough for not only our use case but for others too. If there is interest, we are happy to also implement the Hashicorp Vault implementation in the contribution as that's something quite ubiquitous.
Caveats and questions:
This relies on the interface com.google.api.gax.core.CredentialsProvider which is a transitive dependency of the lib. We are not sure if that's something to be considered as a stable thing to expose to users or should a new interface be created?
Describe alternatives you've considered
None as this lib is something we use and would like to keep using with these added features!
Additional context
None as of now.
Hopefully this is useful and looking forward to collaborating!
The text was updated successfully, but these errors were encountered:
lispyclouds
added a commit
to Citi/java-pubsub-group-kafka-connector
that referenced
this issue
Nov 3, 2024
Is your feature request related to a problem? Please describe.
At our workplace, we are looking to use this lib to connect some of our Kafka instances to ingest data from deployments on GCP via PubSub. We use a custom timed authentication mechanism for GCP based on Hashicorp Vault and as far as we can see we cannot use a custom piece of code/plugin which would support this. As this is something quite critical and useful at my place and there are more ways of auth which people might use later, we have a proposal for this and are happy to implement and contribute if deemed useful.
Describe the solution you'd like
As this depends on
com.google.api.gax
which provides the interfacecom.google.api.gax.core.CredentialsProvider
of which we can see the various kinds of uses in here, we propose the following:public static final String GCP_CREDENTIALS_CLASS_CONFIG
to this class. This would be the fully qualified name of the class which contains the custom implementation of the the CredentialsProvider.fromClass()
to this class.We think that this should be generic enough for not only our use case but for others too. If there is interest, we are happy to also implement the Hashicorp Vault implementation in the contribution as that's something quite ubiquitous.
Caveats and questions:
com.google.api.gax.core.CredentialsProvider
which is a transitive dependency of the lib. We are not sure if that's something to be considered as a stable thing to expose to users or should a new interface be created?Describe alternatives you've considered
None as this lib is something we use and would like to keep using with these added features!
Additional context
None as of now.
Hopefully this is useful and looking forward to collaborating!
The text was updated successfully, but these errors were encountered: