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
Password-based authentication with Cassandra does not work with Spring Boot 2.3.0 #21487
Comments
I have the same issue. As workaround, you can specify auth provider class using @Configuration
class CassandraConfiguration {
@Bean
fun authProviderCustomizer() = DriverConfigLoaderBuilderCustomizer { builder ->
builder.withString(DefaultDriverOption.AUTH_PROVIDER_CLASS, "com.datastax.oss.driver.internal.core.auth.PlainTextAuthProvider")
}
} |
Thanks, @valeyko. Rather than settiing You can configure the auth credentials in Spring Boot with a @Bean
CqlSessionBuilderCustomizer authCustomizer(CassandraProperties properties) {
return (builder) -> builder.withAuthCredentials(properties.getUsername(), properties.getPassword());
} @valeyko @andyfromktm can you please try the above and let us know if it resolves your problem. If it does, we can update |
When we fix this, we should add an integration test that covers username and password authentication. With thanks to @bsideup for some guidance, we can create a Cassandra instance with its password authenticator configured using the following custom container: static final class PasswordAuthenticatorCassandraContainer
extends CassandraContainer<PasswordAuthenticatorCassandraContainer> {
@Override
protected void containerIsCreated(String containerId) {
String config = this.copyFileFromContainer("/etc/cassandra/cassandra.yaml",
(stream) -> StreamUtils.copyToString(stream, StandardCharsets.UTF_8));
String updatedConfig = config.replace("authenticator: AllowAllAuthenticator",
"authenticator: PasswordAuthenticator");
this.copyFileToContainer(Transferable.of(updatedConfig.getBytes(StandardCharsets.UTF_8)),
"/etc/cassandra/cassandra.yaml");
}
} |
Thank you, @wilkinsona, your solution works as well for me |
The test that was added for this seems to flaky fairly consistently. On the first attempt, authentication fails:
It then succeeds upon retry. |
@adutra do you have any insight as why it would be flaky? |
The previous command works when you connect from the internally (inside the container) but fails if you try from the outside - because the previous config was not removed! BTW, thanks for your contribution. I realised the problem after reading: spring-projects/spring-boot#21487
After upgrading to spring boot 2.3.0, the spring data cassandra reactive failed to work due to authentication issue. We are using plain text username & password authentication. The issue seems to be you need to set
advanced.auth-provider.class
here:The text was updated successfully, but these errors were encountered: