diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index fc0c4715953..68b62ca5e21 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -55,6 +55,9 @@ public class CassandraAutoConfiguration { Cluster.Builder builder = Cluster.builder() .withClusterName(properties.getClusterName()) .withPort(properties.getPort()); + if (properties.getUsername() != null) { + builder.withCredentials(properties.getUsername(), properties.getPassword()); + } if (properties.getCompression() != null) { builder.withCompression(properties.getCompression()); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index c4cc2bf6f14..a2d04ec74bf 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -57,6 +57,16 @@ public class CassandraProperties { */ private int port = ProtocolOptions.DEFAULT_PORT; + /** + * Login user of the server. + */ + private String username; + + /** + * Login password of the server. + */ + private String password; + /** * Compression supported by the Cassandra binary protocol. */ @@ -139,6 +149,22 @@ public class CassandraProperties { this.port = port; } + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } + public Compression getCompression() { return this.compression; } diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 26f24745df9..2553f666403 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -476,11 +476,13 @@ content into your application; rather pick only the properties that you need. spring.data.cassandra.keyspace-name= # Keyspace name to use. spring.data.cassandra.load-balancing-policy= # Class name of the load balancing policy. spring.data.cassandra.port= # Port of the Cassandra server. + spring.data.cassandra.password= # Login password of the server. spring.data.cassandra.read-timeout-millis= # Socket option: read time out. spring.data.cassandra.reconnection-policy= # Reconnection policy class. spring.data.cassandra.retry-policy= # Class name of the retry policy. spring.data.cassandra.serial-consistency-level= # Queries serial consistency level. spring.data.cassandra.ssl=false # Enable SSL support. + spring.data.cassandra.username= # Login user of the server. # ELASTICSEARCH ({sc-spring-boot-autoconfigure}/elasticsearch/ElasticsearchProperties.{sc-ext}[ElasticsearchProperties]) spring.data.elasticsearch.cluster-name=elasticsearch # Elasticsearch cluster name.