diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java
index db02437662..5dce6a99bd 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 the original author or authors.
+ * Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,9 +56,10 @@ public class LdapProperties {
private String password;
/**
- * Whether read-only operations should use an anonymous environment.
+ * Whether read-only operations should use an anonymous environment. Disabled by
+ * default unless a username is set.
*/
- private boolean anonymousReadOnly;
+ private Boolean anonymousReadOnly;
/**
* LDAP specification settings.
@@ -97,11 +98,11 @@ public class LdapProperties {
this.password = password;
}
- public boolean getAnonymousReadOnly() {
+ public Boolean getAnonymousReadOnly() {
return this.anonymousReadOnly;
}
- public void setAnonymousReadOnly(boolean anonymousReadOnly) {
+ public void setAnonymousReadOnly(Boolean anonymousReadOnly) {
this.anonymousReadOnly = anonymousReadOnly;
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
index 796b3a99f5..af2f8163a5 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 the original author or authors.
+ * Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ class LdapAutoConfigurationTests {
this.contextRunner.run((context) -> {
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
- assertThat(contextSource.isAnonymousReadOnly()).isFalse();
+ assertThat(contextSource.isAnonymousReadOnly()).isTrue();
});
}
@@ -70,6 +70,15 @@ class LdapAutoConfigurationTests {
});
}
+ @Test
+ void contextSourceWithUserDoesNotEnableAnonymousReadOnly() {
+ this.contextRunner.withPropertyValues("spring.ldap.username:root").run((context) -> {
+ LdapContextSource contextSource = context.getBean(LdapContextSource.class);
+ assertThat(contextSource.getUserDn()).isEqualTo("root");
+ assertThat(contextSource.isAnonymousReadOnly()).isFalse();
+ });
+ }
+
@Test
void contextSourceWithExtraCustomization() {
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:123", "spring.ldap.username:root",
@@ -93,7 +102,7 @@ class LdapAutoConfigurationTests {
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
assertThat(contextSource.getUserDn()).isEqualTo("");
assertThat(contextSource.getPassword()).isEqualTo("");
- assertThat(contextSource.isAnonymousReadOnly()).isFalse();
+ assertThat(contextSource.isAnonymousReadOnly()).isTrue();
assertThat(contextSource.getBaseLdapPathAsString()).isEqualTo("");
});
}
@@ -109,7 +118,7 @@ class LdapAutoConfigurationTests {
this.contextRunner.withUserConfiguration(PooledContextSourceConfig.class).run((context) -> {
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
- assertThat(contextSource.isAnonymousReadOnly()).isFalse();
+ assertThat(contextSource.isAnonymousReadOnly()).isTrue();
});
}
diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml
index 982d96f332..6af25c4faf 100644
--- a/spring-boot-project/spring-boot-dependencies/pom.xml
+++ b/spring-boot-project/spring-boot-dependencies/pom.xml
@@ -194,7 +194,7 @@
1.0.5.RELEASE
5.2.6.RELEASE
2.3.8.RELEASE
- 2.3.2.RELEASE
+ 2.3.3.RELEASE
2.0.4.RELEASE
1.2.5.RELEASE
5.2.4.RELEASE