Skip to content

Commit 31f9a96

Browse files
committed
Merge branch '2.1.x' into 2.2.x
Closes gh-21351
2 parents 55a1cd4 + 1a4f6df commit 31f9a96

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.
@@ -47,7 +47,7 @@ void contextSourceWithDefaultUrl() {
4747
this.contextRunner.run((context) -> {
4848
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
4949
assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
50-
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
50+
assertThat(contextSource.isAnonymousReadOnly()).isTrue();
5151
});
5252
}
5353

@@ -70,6 +70,15 @@ void contextSourceWithSeveralUrls() {
7070
});
7171
}
7272

73+
@Test
74+
void contextSourceWithUserDoesNotEnableAnonymousReadOnly() {
75+
this.contextRunner.withPropertyValues("spring.ldap.username:root").run((context) -> {
76+
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
77+
assertThat(contextSource.getUserDn()).isEqualTo("root");
78+
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
79+
});
80+
}
81+
7382
@Test
7483
void contextSourceWithExtraCustomization() {
7584
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:123", "spring.ldap.username:root",
@@ -93,7 +102,7 @@ void contextSourceWithNoCustomization() {
93102
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
94103
assertThat(contextSource.getUserDn()).isEqualTo("");
95104
assertThat(contextSource.getPassword()).isEqualTo("");
96-
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
105+
assertThat(contextSource.isAnonymousReadOnly()).isTrue();
97106
assertThat(contextSource.getBaseLdapPathAsString()).isEqualTo("");
98107
});
99108
}
@@ -109,7 +118,7 @@ void contextSourceWithUserProvidedPooledContextSource() {
109118
this.contextRunner.withUserConfiguration(PooledContextSourceConfig.class).run((context) -> {
110119
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
111120
assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
112-
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
121+
assertThat(contextSource.isAnonymousReadOnly()).isTrue();
113122
});
114123
}
115124

spring-boot-project/spring-boot-dependencies/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
<spring-hateoas.version>1.0.5.RELEASE</spring-hateoas.version>
195195
<spring-integration.version>5.2.6.RELEASE</spring-integration.version>
196196
<spring-kafka.version>2.3.8.RELEASE</spring-kafka.version>
197-
<spring-ldap.version>2.3.2.RELEASE</spring-ldap.version>
197+
<spring-ldap.version>2.3.3.RELEASE</spring-ldap.version>
198198
<spring-restdocs.version>2.0.4.RELEASE</spring-restdocs.version>
199199
<spring-retry.version>1.2.5.RELEASE</spring-retry.version>
200200
<spring-security.version>5.2.4.RELEASE</spring-security.version>

0 commit comments

Comments
 (0)