Skip to content

Commit 09815cc

Browse files
committed
Merge branch '2.2.x'
Closes gh-21352
2 parents 3ac38fd + 31f9a96 commit 09815cc

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,9 +56,10 @@ public class LdapProperties {
5656
private String password;
5757

5858
/**
59-
* Whether read-only operations should use an anonymous environment.
59+
* Whether read-only operations should use an anonymous environment. Disabled by
60+
* default unless a username is set.
6061
*/
61-
private boolean anonymousReadOnly;
62+
private Boolean anonymousReadOnly;
6263

6364
/**
6465
* LDAP specification settings.
@@ -97,11 +98,11 @@ public void setPassword(String password) {
9798
this.password = password;
9899
}
99100

100-
public boolean getAnonymousReadOnly() {
101+
public Boolean getAnonymousReadOnly() {
101102
return this.anonymousReadOnly;
102103
}
103104

104-
public void setAnonymousReadOnly(boolean anonymousReadOnly) {
105+
public void setAnonymousReadOnly(Boolean anonymousReadOnly) {
105106
this.anonymousReadOnly = anonymousReadOnly;
106107
}
107108

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ void contextSourceWithDefaultUrl() {
5050
this.contextRunner.run((context) -> {
5151
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
5252
assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
53-
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
53+
assertThat(contextSource.isAnonymousReadOnly()).isTrue();
5454
});
5555
}
5656

@@ -73,6 +73,15 @@ void contextSourceWithSeveralUrls() {
7373
});
7474
}
7575

76+
@Test
77+
void contextSourceWithUserDoesNotEnableAnonymousReadOnly() {
78+
this.contextRunner.withPropertyValues("spring.ldap.username:root").run((context) -> {
79+
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
80+
assertThat(contextSource.getUserDn()).isEqualTo("root");
81+
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
82+
});
83+
}
84+
7685
@Test
7786
void contextSourceWithExtraCustomization() {
7887
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:123", "spring.ldap.username:root",
@@ -96,7 +105,7 @@ void contextSourceWithNoCustomization() {
96105
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
97106
assertThat(contextSource.getUserDn()).isEqualTo("");
98107
assertThat(contextSource.getPassword()).isEqualTo("");
99-
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
108+
assertThat(contextSource.isAnonymousReadOnly()).isTrue();
100109
assertThat(contextSource.getBaseLdapPathAsString()).isEqualTo("");
101110
});
102111
}
@@ -112,7 +121,7 @@ void contextSourceWithUserProvidedPooledContextSource() {
112121
this.contextRunner.withUserConfiguration(PooledContextSourceConfig.class).run((context) -> {
113122
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
114123
assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
115-
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
124+
assertThat(contextSource.isAnonymousReadOnly()).isTrue();
116125
});
117126
}
118127

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ bom {
16621662
]
16631663
}
16641664
}
1665-
library("Spring LDAP", "2.3.2.RELEASE") {
1665+
library("Spring LDAP", "2.3.3.RELEASE") {
16661666
group("org.springframework.ldap") {
16671667
modules = [
16681668
"spring-ldap-core",

0 commit comments

Comments
 (0)