Skip to content

Commit fb25437

Browse files
committed
Prevent AuthorizationFilter from filtering all dispatch types
1 parent f0109ea commit fb25437

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/main/java/smoketest/security/method/SampleMethodSecurityApplication.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ protected static class ApplicationSecurity {
6969
@Bean
7070
SecurityFilterChain configure(HttpSecurity http) throws Exception {
7171
http.csrf().disable();
72-
http.authorizeHttpRequests((requests) -> requests.anyRequest().fullyAuthenticated());
72+
http.authorizeHttpRequests(
73+
(requests) -> requests.anyRequest().fullyAuthenticated().shouldFilterAllDispatcherTypes(false));
7374
http.formLogin((form) -> form.loginPage("/login").permitAll());
7475
http.exceptionHandling((exceptions) -> exceptions.accessDeniedPage("/access"));
7576
return http.build();
@@ -85,7 +86,8 @@ protected static class ActuatorSecurity {
8586
SecurityFilterChain actuatorSecurity(HttpSecurity http) throws Exception {
8687
http.csrf().disable();
8788
http.requestMatcher(EndpointRequest.toAnyEndpoint());
88-
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
89+
http.authorizeHttpRequests(
90+
(requests) -> requests.anyRequest().authenticated().shouldFilterAllDispatcherTypes(false));
8991
http.httpBasic();
9092
return http.build();
9193
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractErrorPageTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected AbstractErrorPageTests(String pathPrefix) {
5050
@Test
5151
void testBadCredentials() {
5252
final ResponseEntity<JsonNode> response = this.testRestTemplate.withBasicAuth("username", "wrongpassword")
53-
.exchange("/test", HttpMethod.GET, null, JsonNode.class);
53+
.exchange(this.pathPrefix + "/test", HttpMethod.GET, null, JsonNode.class);
5454
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
5555
JsonNode jsonResponse = response.getBody();
5656
assertThat(jsonResponse).isNull();

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathErrorPageTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SecurityFilterChain configure(HttpSecurity http) throws Exception {
4747
http.authorizeHttpRequests((requests) -> {
4848
requests.antMatchers("/custom/servlet/path/public/**").permitAll();
4949
requests.anyRequest().fullyAuthenticated();
50+
requests.shouldFilterAllDispatcherTypes(false);
5051
});
5152
http.httpBasic();
5253
http.formLogin((form) -> form.loginPage("/custom/servlet/path/login").permitAll());

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/ErrorPageTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SecurityFilterChain configure(HttpSecurity http) throws Exception {
4646
http.authorizeHttpRequests((requests) -> {
4747
requests.antMatchers("/public/**").permitAll();
4848
requests.anyRequest().fullyAuthenticated();
49+
requests.shouldFilterAllDispatcherTypes(false);
4950
});
5051
http.httpBasic();
5152
http.formLogin((form) -> form.loginPage("/login").permitAll());

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/NoSessionErrorPageTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Excepti
4848
.authorizeHttpRequests((requests) -> {
4949
requests.antMatchers("/public/**").permitAll();
5050
requests.anyRequest().authenticated();
51+
requests.shouldFilterAllDispatcherTypes(false);
5152
});
5253
http.httpBasic();
5354
return http.build();

0 commit comments

Comments
 (0)