diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java index dd4a08b71a..af024ee2d8 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java @@ -75,14 +75,11 @@ public final class DefaultLoginPageConfigurer> private DefaultLogoutPageGeneratingFilter logoutPageGeneratingFilter = new DefaultLogoutPageGeneratingFilter(); - private DefaultResourcesFilter defaultResourcesFilter = new DefaultResourcesFilter(); - @Override public void init(H http) { this.loginPageGeneratingFilter.setResolveHiddenInputs(DefaultLoginPageConfigurer.this::hiddenInputs); this.logoutPageGeneratingFilter.setResolveHiddenInputs(DefaultLoginPageConfigurer.this::hiddenInputs); http.setSharedObject(DefaultLoginPageGeneratingFilter.class, this.loginPageGeneratingFilter); - http.setSharedObject(DefaultResourcesFilter.class, this.defaultResourcesFilter); } private Map hiddenInputs(HttpServletRequest request) { @@ -102,7 +99,7 @@ public final class DefaultLoginPageConfigurer> if (this.loginPageGeneratingFilter.isEnabled() && authenticationEntryPoint == null) { this.loginPageGeneratingFilter = postProcess(this.loginPageGeneratingFilter); http.addFilter(this.loginPageGeneratingFilter); - http.addFilter(this.defaultResourcesFilter); + http.addFilter(DefaultResourcesFilter.css()); LogoutConfigurer logoutConfigurer = http.getConfigurer(LogoutConfigurer.class); if (logoutConfigurer != null) { http.addFilter(this.logoutPageGeneratingFilter); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurerTests.java index e6d7eeff00..7a68952945 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurerTests.java @@ -70,143 +70,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ExtendWith(SpringTestContextExtension.class) public class DefaultLoginPageConfigurerTests { - public static final String EXPECTED_HTML_HEAD = """ - - - - - - - - Please sign in - - - """; - public final SpringTestContext spring = new SpringTestContext(this); @Autowired @@ -227,9 +90,17 @@ public class DefaultLoginPageConfigurerTests { this.mvc.perform(get("/login").sessionAttr(csrfAttributeName, csrfToken)) .andExpect((result) -> { CsrfToken token = (CsrfToken) result.getRequest().getAttribute(CsrfToken.class.getName()); - assertThat(result.getResponse().getContentAsString()).isEqualTo( - EXPECTED_HTML_HEAD + - """ + assertThat(result.getResponse().getContentAsString()).isEqualTo(""" + + + + + + + + Please sign in + +