Skip to content

Commit 437fb75

Browse files
author
Dave Syer
committed
Add /error to ignored paths for security autoconfig
Protecting /error doesn't make a great deal of sense and if it is protected you don't get the ErrorPageFilter for the attempt at loading it, so Tomcat renders its own HTML error page (when deployed as WAR). Fixes gh-1548
1 parent bf0c8fc commit 437fb75

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testWebConfiguration() throws Exception {
7474
this.context.refresh();
7575
assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
7676
// 6 for static resources, one for management endpoints and one for the rest
77-
assertEquals(8, this.context.getBean(FilterChainProxy.class).getFilterChains()
77+
assertEquals(9, this.context.getBean(FilterChainProxy.class).getFilterChains()
7878
.size());
7979
}
8080

@@ -144,7 +144,7 @@ public void testDisableBasicAuthOnApplicationPaths() throws Exception {
144144
this.context.refresh();
145145
// Just the management endpoints (one filter) and ignores now plus the backup
146146
// filter on app endpoints
147-
assertEquals(8, this.context.getBean(FilterChainProxy.class).getFilterChains()
147+
assertEquals(9, this.context.getBean(FilterChainProxy.class).getFilterChains()
148148
.size());
149149
}
150150

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
public class SpringBootWebSecurityConfiguration {
8787

8888
private static List<String> DEFAULT_IGNORED = Arrays.asList("/css/**", "/js/**",
89-
"/images/**", "/**/favicon.ico");
89+
"/images/**", "/**/favicon.ico", "/error");
9090

9191
@Bean
9292
@ConditionalOnMissingBean({ IgnoredPathsWebSecurityConfigurerAdapter.class })

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ public void testWebConfiguration() throws Exception {
6868
PropertyPlaceholderAutoConfiguration.class);
6969
this.context.refresh();
7070
assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
71-
// 4 for static resources and one for the rest
71+
// 5 for static resources and one for the rest
7272
List<SecurityFilterChain> filterChains = this.context.getBean(
7373
FilterChainProxy.class).getFilterChains();
74-
assertEquals(5, filterChains.size());
74+
assertEquals(6, filterChains.size());
7575
}
7676

7777
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2012-2014 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.security;
18+
19+
import org.junit.Test;
20+
21+
import static org.junit.Assert.assertTrue;
22+
23+
/**
24+
* @author Dave Syer
25+
*/
26+
public class SpringBootWebSecurityConfigurationTests {
27+
28+
@Test
29+
public void testDefaultIgnores() {
30+
assertTrue(SpringBootWebSecurityConfiguration
31+
.getIgnored(new SecurityProperties()).contains("/error"));
32+
}
33+
34+
}

0 commit comments

Comments
 (0)