Skip to content

Commit c35454e

Browse files
committed
Merge branch '1.5.x'
2 parents da4f851 + e9acc7f commit c35454e

File tree

40 files changed

+1928
-11
lines changed

40 files changed

+1928
-11
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfiguration.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.
@@ -257,10 +257,11 @@ private AuthenticationEntryPoint entryPoint() {
257257

258258
private void configurePermittedRequests(
259259
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) {
260+
requests.requestMatchers(new LazyEndpointPathRequestMatcher(
261+
this.contextResolver, EndpointPaths.SENSITIVE)).authenticated();
260262
// Permit access to the non-sensitive endpoints
261263
requests.requestMatchers(new LazyEndpointPathRequestMatcher(
262264
this.contextResolver, EndpointPaths.NON_SENSITIVE)).permitAll();
263-
requests.anyRequest().authenticated();
264265
}
265266

266267
}
@@ -276,6 +277,15 @@ protected boolean isIncluded(MvcEndpoint endpoint) {
276277
return !endpoint.isSensitive();
277278
}
278279

280+
},
281+
282+
SENSITIVE {
283+
284+
@Override
285+
protected boolean isIncluded(MvcEndpoint endpoint) {
286+
return endpoint.isSensitive();
287+
}
288+
279289
};
280290

281291
public String[] getPaths(EndpointHandlerMapping endpointHandlerMapping) {
@@ -289,12 +299,9 @@ public String[] getPaths(EndpointHandlerMapping endpointHandlerMapping) {
289299
String path = endpointHandlerMapping.getPath(endpoint.getPath());
290300
paths.add(path);
291301
if (!path.equals("")) {
292-
if (endpoint.isSensitive()) {
293-
// Ensure that nested paths are secured
294-
paths.add(path + "/**");
295-
// Add Spring MVC-generated additional paths
296-
paths.add(path + ".*");
297-
}
302+
paths.add(path + "/**");
303+
// Add Spring MVC-generated additional paths
304+
paths.add(path + ".*");
298305
}
299306
paths.add(path + "/");
300307
}

spring-boot-autoconfigure/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@
234234
<artifactId>sendgrid-java</artifactId>
235235
<optional>true</optional>
236236
</dependency>
237+
<dependency>
238+
<groupId>com.unboundid</groupId>
239+
<artifactId>unboundid-ldapsdk</artifactId>
240+
<optional>true</optional>
241+
</dependency>
237242
<dependency>
238243
<groupId>com.zaxxer</groupId>
239244
<artifactId>HikariCP-java6</artifactId>
@@ -382,6 +387,11 @@
382387
<artifactId>spring-data-cassandra</artifactId>
383388
<optional>true</optional>
384389
</dependency>
390+
<dependency>
391+
<groupId>org.springframework.data</groupId>
392+
<artifactId>spring-data-ldap</artifactId>
393+
<optional>true</optional>
394+
</dependency>
385395
<dependency>
386396
<groupId>org.springframework.data</groupId>
387397
<artifactId>spring-data-mongodb</artifactId>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.ldap;
18+
19+
import javax.naming.ldap.LdapContext;
20+
21+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
22+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
25+
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
26+
import org.springframework.context.annotation.Bean;
27+
import org.springframework.context.annotation.Configuration;
28+
import org.springframework.data.ldap.repository.LdapRepository;
29+
import org.springframework.ldap.core.ContextSource;
30+
import org.springframework.ldap.core.LdapOperations;
31+
import org.springframework.ldap.core.LdapTemplate;
32+
33+
/**
34+
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's LDAP support.
35+
*
36+
* @author Eddú Meléndez
37+
* @since 1.5.0
38+
*/
39+
@Configuration
40+
@ConditionalOnClass({ LdapContext.class, LdapRepository.class })
41+
@AutoConfigureAfter(LdapAutoConfiguration.class)
42+
public class LdapDataAutoConfiguration {
43+
44+
@Bean
45+
@ConditionalOnMissingBean(LdapOperations.class)
46+
public LdapTemplate ldapTemplate(ContextSource contextSource) {
47+
return new LdapTemplate(contextSource);
48+
}
49+
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.ldap;
18+
19+
import javax.naming.ldap.LdapContext;
20+
21+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
25+
import org.springframework.context.annotation.Configuration;
26+
import org.springframework.context.annotation.Import;
27+
import org.springframework.data.ldap.repository.LdapRepository;
28+
import org.springframework.data.ldap.repository.support.LdapRepositoryFactoryBean;
29+
30+
/**
31+
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Couchbase
32+
* Repositories.
33+
*
34+
* @author Eddú Meléndez
35+
* @since 1.5.0
36+
*/
37+
@Configuration
38+
@ConditionalOnClass({ LdapContext.class, LdapRepository.class })
39+
@ConditionalOnProperty(prefix = "spring.data.ldap.repositories", name = "enabled", havingValue = "true", matchIfMissing = true)
40+
@ConditionalOnMissingBean(LdapRepositoryFactoryBean.class)
41+
@Import(LdapRepositoriesRegistrar.class)
42+
public class LdapRepositoriesAutoConfiguration {
43+
44+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.ldap;
18+
19+
import java.lang.annotation.Annotation;
20+
21+
import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport;
22+
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
23+
import org.springframework.data.ldap.repository.config.EnableLdapRepositories;
24+
import org.springframework.data.ldap.repository.config.LdapRepositoryConfigurationExtension;
25+
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
26+
27+
/**
28+
* {@link ImportBeanDefinitionRegistrar} used to auto-configure Spring Data LDAP
29+
* Repositories.
30+
*
31+
* @author Eddú Meléndez
32+
* @since 1.5.0
33+
*/
34+
class LdapRepositoriesRegistrar extends AbstractRepositoryConfigurationSourceSupport {
35+
36+
@Override
37+
protected Class<? extends Annotation> getAnnotation() {
38+
return EnableLdapRepositories.class;
39+
}
40+
41+
@Override
42+
protected Class<?> getConfiguration() {
43+
return EnableLdapRepositoriesConfiguration.class;
44+
}
45+
46+
@Override
47+
protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() {
48+
return new LdapRepositoryConfigurationExtension();
49+
}
50+
51+
@EnableLdapRepositories
52+
private static class EnableLdapRepositoriesConfiguration {
53+
54+
}
55+
56+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Auto-configuration for Spring Data LDAP.
19+
*/
20+
package org.springframework.boot.autoconfigure.data.ldap;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.ldap;
18+
19+
import java.util.Collections;
20+
21+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
24+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
25+
import org.springframework.context.annotation.Bean;
26+
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.core.env.Environment;
28+
import org.springframework.ldap.core.ContextSource;
29+
import org.springframework.ldap.core.support.LdapContextSource;
30+
31+
/**
32+
* {@link EnableAutoConfiguration Auto-configuration} for LDAP.
33+
*
34+
* @author Eddú Meléndez
35+
* @since 1.5.0
36+
*/
37+
@Configuration
38+
@ConditionalOnClass(ContextSource.class)
39+
@EnableConfigurationProperties(LdapProperties.class)
40+
public class LdapAutoConfiguration {
41+
42+
private final LdapProperties properties;
43+
44+
private final Environment environment;
45+
46+
public LdapAutoConfiguration(LdapProperties properties, Environment environment) {
47+
this.properties = properties;
48+
this.environment = environment;
49+
}
50+
51+
@Bean
52+
@ConditionalOnMissingBean
53+
public ContextSource ldapContextSource() {
54+
LdapContextSource source = new LdapContextSource();
55+
source.setUserDn(this.properties.getUsername());
56+
source.setPassword(this.properties.getPassword());
57+
source.setBase(this.properties.getBase());
58+
source.setUrls(this.properties.determineUrls(this.environment));
59+
source.setBaseEnvironmentProperties(Collections
60+
.<String, Object>unmodifiableMap(this.properties.getBaseEnvironment()));
61+
return source;
62+
}
63+
64+
}

0 commit comments

Comments
 (0)