Browse Source

RequestMatcherDelegatingAuthorizationManager defaults to deny

Closes gh-11958
Joe Grandja 2 years ago
parent
commit
753e113a13
51 changed files with 126 additions and 67 deletions
  1. 1 4
      config/src/main/java/org/springframework/security/config/http/AuthorizationFilterParser.java
  2. 2 2
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/AuthorizeHttpRequestsConfigurerTests.java
  3. 4 1
      config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java
  4. 1 1
      config/src/test/java/org/springframework/security/config/http/InterceptUrlConfigTests.java
  5. 3 1
      config/src/test/java/org/springframework/security/config/http/SessionManagementConfigServlet31Tests.java
  6. 2 2
      config/src/test/kotlin/org/springframework/security/config/annotation/web/AuthorizeHttpRequestsDslTests.kt
  7. 5 2
      config/src/test/resources/org/springframework/security/config/authentication/PasswordEncoderParserTests-bean.xml
  8. 4 1
      config/src/test/resources/org/springframework/security/config/authentication/PasswordEncoderParserTests-default.xml
  9. 4 2
      config/src/test/resources/org/springframework/security/config/debug/SecurityDebugBeanFactoryPostProcessorTests-context.xml
  10. 2 1
      config/src/test/resources/org/springframework/security/config/http/CsrfConfigTests-WithAccessDeniedHandler.xml
  11. 2 1
      config/src/test/resources/org/springframework/security/config/http/CsrfConfigTests-WithRequestAttrName.xml
  12. 2 1
      config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-AutoConfig.xml
  13. 2 1
      config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-Simple.xml
  14. 2 1
      config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-WithAuthenticationFailureForwardUrl.xml
  15. 2 1
      config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-WithAuthenticationSuccessForwardUrl.xml
  16. 2 1
      config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-WithCustomAttributes.xml
  17. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AuthenticationManagerEraseCredentials.xml
  18. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AuthenticationManagerRefKeepCredentials.xml
  19. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AuthenticationManagerRefNotProviderManager.xml
  20. 4 2
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AutoConfig.xml
  21. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-CustomAuthenticationDetailsSourceRef.xml
  22. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-CustomFilters.xml
  23. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-DeleteCookies.xml
  24. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-HttpBasic.xml
  25. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-HttpFirewall.xml
  26. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-Jaas.xml
  27. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-JeeFilter.xml
  28. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-LogoutSuccessHandlerRef.xml
  29. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-MinimalConfiguration.xml
  30. 4 2
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-MissingUserDetailsService.xml
  31. 2 1
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-NoInternalAuthenticationProviders.xml
  32. 4 2
      config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-Sec750.xml
  33. 2 0
      config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-DistinctHttpElements.xml
  34. 3 1
      config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-IdenticalHttpElements.xml
  35. 2 0
      config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-IdenticallyPatternedHttpElements.xml
  36. 3 1
      config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-Sec1937.xml
  37. 2 1
      config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-AuthorizedClientArgumentResolver.xml
  38. 1 0
      config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomAuthorizationRedirectStrategy.xml
  39. 2 1
      config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomAuthorizedClientService.xml
  40. 2 1
      config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomClientRegistrationRepository.xml
  41. 2 1
      config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomConfiguration.xml
  42. 2 1
      config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-Minimal.xml
  43. 2 1
      config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTests-ConcurrencyControlMaxSessions.xml
  44. 2 1
      config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTests-ConcurrencyControlMaxSessionsPlaceHolder.xml
  45. 2 1
      config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTests-ConcurrencyControlSessionRegistryRef.xml
  46. 2 1
      config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTransientAuthenticationTests-CreateSessionAlwaysWithTransientAuthentication.xml
  47. 2 1
      config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTransientAuthenticationTests-WithTransientAuthentication.xml
  48. 2 1
      config/src/test/resources/org/springframework/security/config/http/WellKnownChangePasswordBeanDefinitionParserTests-CustomChangePasswordPage.xml
  49. 2 1
      config/src/test/resources/org/springframework/security/config/http/WellKnownChangePasswordBeanDefinitionParserTests-DefaultChangePasswordPage.xml
  50. 7 3
      web/src/main/java/org/springframework/security/web/access/intercept/RequestMatcherDelegatingAuthorizationManager.java
  51. 6 8
      web/src/test/java/org/springframework/security/web/access/intercept/RequestMatcherDelegatingAuthorizationManagerTests.java

+ 1 - 4
config/src/main/java/org/springframework/security/config/http/AuthorizationFilterParser.java

@@ -34,7 +34,6 @@ import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
 import org.springframework.beans.factory.xml.BeanDefinitionParser;
 import org.springframework.beans.factory.xml.BeanDefinitionParser;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.beans.factory.xml.XmlReaderContext;
 import org.springframework.beans.factory.xml.XmlReaderContext;
-import org.springframework.security.authorization.AuthenticatedAuthorizationManager;
 import org.springframework.security.authorization.AuthorizationManager;
 import org.springframework.security.authorization.AuthorizationManager;
 import org.springframework.security.authorization.ObservationAuthorizationManager;
 import org.springframework.security.authorization.ObservationAuthorizationManager;
 import org.springframework.security.config.Elements;
 import org.springframework.security.config.Elements;
@@ -43,7 +42,6 @@ import org.springframework.security.web.access.expression.WebExpressionAuthoriza
 import org.springframework.security.web.access.intercept.AuthorizationFilter;
 import org.springframework.security.web.access.intercept.AuthorizationFilter;
 import org.springframework.security.web.access.intercept.RequestAuthorizationContext;
 import org.springframework.security.web.access.intercept.RequestAuthorizationContext;
 import org.springframework.security.web.access.intercept.RequestMatcherDelegatingAuthorizationManager;
 import org.springframework.security.web.access.intercept.RequestMatcherDelegatingAuthorizationManager;
-import org.springframework.security.web.util.matcher.AnyRequestMatcher;
 import org.springframework.security.web.util.matcher.RequestMatcher;
 import org.springframework.security.web.util.matcher.RequestMatcher;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.util.xml.DomUtils;
 import org.springframework.util.xml.DomUtils;
@@ -197,8 +195,7 @@ class AuthorizationFilterParser implements BeanDefinitionParser {
 					.entrySet()) {
 					.entrySet()) {
 				builder.add(entry.getKey(), entry.getValue());
 				builder.add(entry.getKey(), entry.getValue());
 			}
 			}
-			AuthorizationManager<HttpServletRequest> manager = builder
-					.add(AnyRequestMatcher.INSTANCE, AuthenticatedAuthorizationManager.authenticated()).build();
+			AuthorizationManager<HttpServletRequest> manager = builder.build();
 			if (!this.observationRegistry.isNoop()) {
 			if (!this.observationRegistry.isNoop()) {
 				return new ObservationAuthorizationManager<>(this.observationRegistry, manager);
 				return new ObservationAuthorizationManager<>(this.observationRegistry, manager);
 			}
 			}

+ 2 - 2
config/src/test/java/org/springframework/security/config/annotation/web/configurers/AuthorizeHttpRequestsConfigurerTests.java

@@ -358,7 +358,7 @@ public class AuthorizeHttpRequestsConfigurerTests {
 	}
 	}
 
 
 	@Test
 	@Test
-	public void getWhenServletPathRoleAdminConfiguredAndRoleIsUserAndWithoutServletPathThenRespondsWithOk()
+	public void getWhenServletPathRoleAdminConfiguredAndRoleIsUserAndWithoutServletPathThenRespondsWithForbidden()
 			throws Exception {
 			throws Exception {
 		this.spring.register(ServletPathConfig.class, BasicController.class).autowire();
 		this.spring.register(ServletPathConfig.class, BasicController.class).autowire();
 		// @formatter:off
 		// @formatter:off
@@ -366,7 +366,7 @@ public class AuthorizeHttpRequestsConfigurerTests {
 				.with(user("user")
 				.with(user("user")
 				.roles("USER"));
 				.roles("USER"));
 		// @formatter:on
 		// @formatter:on
-		this.mvc.perform(requestWithUser).andExpect(status().isOk());
+		this.mvc.perform(requestWithUser).andExpect(status().isForbidden());
 	}
 	}
 
 
 	@Test
 	@Test

+ 4 - 1
config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java

@@ -139,7 +139,10 @@ public class AuthenticationManagerBeanDefinitionParserTests {
 				+ "<user-service>"
 				+ "<user-service>"
 				+ "  <user name='user' password='password' authorities='ROLE_A,ROLE_B' />"
 				+ "  <user name='user' password='password' authorities='ROLE_A,ROLE_B' />"
 				+ "</user-service>"
 				+ "</user-service>"
-				+ "<http/>")
+				+ "<http>"
+				+ "  <intercept-url pattern=\"/**\" access=\"authenticated\"/>"
+				+ "  <http-basic />"
+				+ "</http>")
 				.mockMvcAfterSpringSecurityOk()
 				.mockMvcAfterSpringSecurityOk()
 				.autowire();
 				.autowire();
 		this.mockMvc.perform(get("/").with(httpBasic("user", "password")))
 		this.mockMvc.perform(get("/").with(httpBasic("user", "password")))

+ 1 - 1
config/src/test/java/org/springframework/security/config/http/InterceptUrlConfigTests.java

@@ -120,7 +120,7 @@ public class InterceptUrlConfigTests {
 		this.spring.configLocations(this.xml("PatchMethodAuthorizationManager")).autowire();
 		this.spring.configLocations(this.xml("PatchMethodAuthorizationManager")).autowire();
 		// @formatter:off
 		// @formatter:off
 		this.mvc.perform(get("/path").with(userCredentials()))
 		this.mvc.perform(get("/path").with(userCredentials()))
-				.andExpect(status().isOk());
+				.andExpect(status().isForbidden());
 		this.mvc.perform(patch("/path").with(userCredentials()))
 		this.mvc.perform(patch("/path").with(userCredentials()))
 				.andExpect(status().isForbidden());
 				.andExpect(status().isForbidden());
 		this.mvc.perform(patch("/path").with(adminCredentials()))
 		this.mvc.perform(patch("/path").with(adminCredentials()))

+ 3 - 1
config/src/test/java/org/springframework/security/config/http/SessionManagementConfigServlet31Tests.java

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2022 the original author or authors.
  *
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * you may not use this file except in compliance with the License.
@@ -85,6 +85,7 @@ public class SessionManagementConfigServlet31Tests {
 		String id = request.getSession().getId();
 		String id = request.getSession().getId();
 		// @formatter:off
 		// @formatter:off
 		loadContext("<http>\n"
 		loadContext("<http>\n"
+				+ "        <intercept-url pattern=\"/**\" access=\"authenticated\"/>\n"
 				+ "        <form-login/>\n"
 				+ "        <form-login/>\n"
 				+ "        <session-management/>\n"
 				+ "        <session-management/>\n"
 				+ "        <csrf disabled='true'/>\n"
 				+ "        <csrf disabled='true'/>\n"
@@ -107,6 +108,7 @@ public class SessionManagementConfigServlet31Tests {
 		String id = request.getSession().getId();
 		String id = request.getSession().getId();
 		// @formatter:off
 		// @formatter:off
 		loadContext("<http>\n"
 		loadContext("<http>\n"
+				+ "        <intercept-url pattern=\"/**\" access=\"authenticated\"/>\n"
 				+ "        <form-login/>\n"
 				+ "        <form-login/>\n"
 				+ "        <session-management session-fixation-protection='changeSessionId'/>\n"
 				+ "        <session-management session-fixation-protection='changeSessionId'/>\n"
 				+ "        <csrf disabled='true'/>\n"
 				+ "        <csrf disabled='true'/>\n"

+ 2 - 2
config/src/test/kotlin/org/springframework/security/config/annotation/web/AuthorizeHttpRequestsDslTests.kt

@@ -512,7 +512,7 @@ class AuthorizeHttpRequestsDslTests {
                 request.servletPath = "/other"
                 request.servletPath = "/other"
                 request
                 request
             })
             })
-            .andExpect(status().isOk)
+            .andExpect(status().isForbidden)
     }
     }
 
 
     @Configuration
     @Configuration
@@ -602,7 +602,7 @@ class AuthorizeHttpRequestsDslTests {
                     servletPath = "/other"
                     servletPath = "/other"
                 }
                 }
             })
             })
-            .andExpect(status().isOk)
+            .andExpect(status().isForbidden)
     }
     }
 
 
     @Configuration
     @Configuration

+ 5 - 2
config/src/test/resources/org/springframework/security/config/authentication/PasswordEncoderParserTests-bean.xml

@@ -1,5 +1,5 @@
 <!--
 <!--
-  ~ Copyright 2002-2017 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -22,7 +22,10 @@
 
 
 	<b:bean id="passwordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method="getInstance"/>
 	<b:bean id="passwordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method="getInstance"/>
 
 
-	<http />
+	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
+		<http-basic />
+	</http>
 
 
 	<authentication-manager>
 	<authentication-manager>
 		<authentication-provider>
 		<authentication-provider>

+ 4 - 1
config/src/test/resources/org/springframework/security/config/authentication/PasswordEncoderParserTests-default.xml

@@ -3,7 +3,10 @@
 		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 		 xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
 		 xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
 						http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">
 						http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">
-	<http />
+	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
+		<http-basic />
+	</http>
 
 
 	<authentication-manager>
 	<authentication-manager>
 		<authentication-provider>
 		<authentication-provider>

+ 4 - 2
config/src/test/resources/org/springframework/security/config/debug/SecurityDebugBeanFactoryPostProcessorTests-context.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,7 +25,9 @@
 
 
 	<debug/>
 	<debug/>
 
 
-	<http/>
+	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
+	</http>
 
 
 	<authentication-manager>
 	<authentication-manager>
 		<authentication-provider ref="authProvider"/>
 		<authentication-provider ref="authProvider"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/CsrfConfigTests-WithAccessDeniedHandler.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 	<http auto-config="true">
 	<http auto-config="true">
 		<access-denied-handler ref="accessDeniedHandler"/>
 		<access-denied-handler ref="accessDeniedHandler"/>
 		<csrf/>
 		<csrf/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:import resource="CsrfConfigTests-shared-userservice.xml"/>
 	<b:import resource="CsrfConfigTests-shared-userservice.xml"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/CsrfConfigTests-WithRequestAttrName.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 
 
 	<http auto-config="true">
 	<http auto-config="true">
 		<csrf request-handler-ref="requestHandler"/>
 		<csrf request-handler-ref="requestHandler"/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:bean id="requestHandler" class="org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler"
 	<b:bean id="requestHandler" class="org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler"

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-AutoConfig.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:import resource="userservice.xml"/>
 	<b:import resource="userservice.xml"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-Simple.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 
 
 	<http auto-config="true">
 	<http auto-config="true">
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:import resource="userservice.xml"/>
 	<b:import resource="userservice.xml"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-WithAuthenticationFailureForwardUrl.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 				authentication-failure-forward-url="/failure_forward_url"/>
 				authentication-failure-forward-url="/failure_forward_url"/>
 
 
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:import resource="userservice.xml"/>
 	<b:import resource="userservice.xml"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-WithAuthenticationSuccessForwardUrl.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 				authentication-success-forward-url="/success_forward_url"/>
 				authentication-success-forward-url="/success_forward_url"/>
 
 
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:import resource="userservice.xml"/>
 	<b:import resource="userservice.xml"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests-WithCustomAttributes.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 				password-parameter="custom_pass"/>
 				password-parameter="custom_pass"/>
 
 
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:import resource="userservice.xml"/>
 	<b:import resource="userservice.xml"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AuthenticationManagerEraseCredentials.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AuthenticationManagerRefKeepCredentials.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http authentication-manager-ref="authMgr">
 	<http authentication-manager-ref="authMgr">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AuthenticationManagerRefNotProviderManager.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http authentication-manager-ref="authMgr">
 	<http authentication-manager-ref="authMgr">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 

+ 4 - 2
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-AutoConfig.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -24,7 +24,9 @@
 			http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
-	<http auto-config="true"/>
+	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
+	</http>
 
 
 	<b:import resource="userservice.xml"/>
 	<b:import resource="userservice.xml"/>
 </b:beans>
 </b:beans>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-CustomAuthenticationDetailsSourceRef.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic authentication-details-source-ref="authenticationDetailsSource"/>
 		<http-basic authentication-details-source-ref="authenticationDetailsSource"/>
 		<form-login authentication-details-source-ref="authenticationDetailsSource"/>
 		<form-login authentication-details-source-ref="authenticationDetailsSource"/>
 		<x509 subject-principal-regex="OU=(.*?)(?:,|$)" authentication-details-source-ref="authenticationDetailsSource"/>
 		<x509 subject-principal-regex="OU=(.*?)(?:,|$)" authentication-details-source-ref="authenticationDetailsSource"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-CustomFilters.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<custom-filter ref="${customFilterRef}" position="FIRST"/>
 		<custom-filter ref="${customFilterRef}" position="FIRST"/>
 		<custom-filter ref="userFilter" before="SECURITY_CONTEXT_FILTER"/>
 		<custom-filter ref="userFilter" before="SECURITY_CONTEXT_FILTER"/>
 		<custom-filter ref="userFilter" after="LOGOUT_FILTER"/>
 		<custom-filter ref="userFilter" after="LOGOUT_FILTER"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-DeleteCookies.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<logout delete-cookies="JSESSIONID, mycookie"/>
 		<logout delete-cookies="JSESSIONID, mycookie"/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-HttpBasic.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-HttpFirewall.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 	<http-firewall ref="firewall"/>
 	<http-firewall ref="firewall"/>
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-Jaas.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true" jaas-api-provision="true">
 	<http auto-config="true" jaas-api-provision="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:bean class="org.springframework.security.config.http.MiscHttpConfigTests.JaasController"/>
 	<b:bean class="org.springframework.security.config.http.MiscHttpConfigTests.JaasController"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-JeeFilter.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<jee mappable-roles="admin,user"/>
 		<jee mappable-roles="admin,user"/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-LogoutSuccessHandlerRef.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<logout success-handler-ref="logoutSuccessEndpoint"/>
 		<logout success-handler-ref="logoutSuccessEndpoint"/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-MinimalConfiguration.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 

+ 4 - 2
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-MissingUserDetailsService.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -24,5 +24,7 @@
 			http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
-	<http auto-config="true"/>
+	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
+	</http>
 </b:beans>
 </b:beans>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-NoInternalAuthenticationProviders.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<form-login/>
 		<form-login/>
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
 		<anonymous enabled="false"/>
 		<anonymous enabled="false"/>

+ 4 - 2
config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-Sec750.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -24,7 +24,9 @@
 			http://www.springframework.org/schema/beans
 			http://www.springframework.org/schema/beans
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
-	<http auto-config="true"/>
+	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
+	</http>
 
 
 	<authentication-manager>
 	<authentication-manager>
 		<authentication-provider user-service-ref="userService"/>
 		<authentication-provider user-service-ref="userService"/>

+ 2 - 0
config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-DistinctHttpElements.xml

@@ -23,10 +23,12 @@
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http pattern="/first/**" create-session="stateless">
 	<http pattern="/first/**" create-session="stateless">
+		<intercept-url pattern="/first/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 
 	<http pattern="/second/**">
 	<http pattern="/second/**">
+		<intercept-url pattern="/second/**" access="authenticated"/>
 		<form-login login-processing-url="/second/login"/>
 		<form-login login-processing-url="/second/login"/>
 	</http>
 	</http>
 
 

+ 3 - 1
config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-IdenticalHttpElements.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -23,10 +23,12 @@
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http create-session="stateless">
 	<http create-session="stateless">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 
 	<http>
 	<http>
+		<intercept-url pattern="/**" access="authenticated"/>
 		<form-login/>
 		<form-login/>
 	</http>
 	</http>
 
 

+ 2 - 0
config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-IdenticallyPatternedHttpElements.xml

@@ -23,10 +23,12 @@
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http pattern="/first/**" create-session="stateless">
 	<http pattern="/first/**" create-session="stateless">
+		<intercept-url pattern="/first/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 
 	<http pattern="/first/**">
 	<http pattern="/first/**">
+		<intercept-url pattern="/first/**" access="authenticated"/>
 		<form-login/>
 		<form-login/>
 	</http>
 	</http>
 
 

+ 3 - 1
config/src/test/resources/org/springframework/security/config/http/MultiHttpBlockConfigTests-Sec1937.xml

@@ -23,10 +23,12 @@
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 				http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http authentication-manager-ref="firstAuthenticationManager" pattern="/first/**" create-session="stateless">
 	<http authentication-manager-ref="firstAuthenticationManager" pattern="/first/**" create-session="stateless">
+		<intercept-url pattern="/first/**" access="authenticated"/>
 		<http-basic/>
 		<http-basic/>
 	</http>
 	</http>
 
 
 	<http authentication-manager-ref="secondAuthenticationManager" pattern="/second/**">
 	<http authentication-manager-ref="secondAuthenticationManager" pattern="/second/**">
+		<intercept-url pattern="/second/**" access="authenticated"/>
 		<form-login login-processing-url="/second/login"/>
 		<form-login login-processing-url="/second/login"/>
 	</http>
 	</http>
 
 
@@ -47,6 +49,6 @@
 			</user-service>
 			</user-service>
 		</authentication-provider>
 		</authentication-provider>
 	</authentication-manager>
 	</authentication-manager>
-	
+
 	<b:import resource="handlermappingintrospector.xml"/>
 	<b:import resource="handlermappingintrospector.xml"/>
 </b:beans>
 </b:beans>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-AuthorizedClientArgumentResolver.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2020 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 
 
 	<http auto-config="true">
 	<http auto-config="true">
 		<oauth2-client authorized-client-repository-ref="authorizedClientRepository" />
 		<oauth2-client authorized-client-repository-ref="authorizedClientRepository" />
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<mvc:annotation-driven />
 	<mvc:annotation-driven />

+ 1 - 0
config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomAuthorizationRedirectStrategy.xml

@@ -29,6 +29,7 @@
 			<authorization-code-grant
 			<authorization-code-grant
 					authorization-redirect-strategy-ref="authorizationRedirectStrategy"/>
 					authorization-redirect-strategy-ref="authorizationRedirectStrategy"/>
 		</oauth2-client>
 		</oauth2-client>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:bean id="authorizationRedirectStrategy" class="org.mockito.Mockito" factory-method="mock">
 	<b:bean id="authorizationRedirectStrategy" class="org.mockito.Mockito" factory-method="mock">

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomAuthorizedClientService.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2020 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
 					authorization-request-resolver-ref="authorizationRequestResolver"
 					authorization-request-resolver-ref="authorizationRequestResolver"
 					access-token-response-client-ref="accessTokenResponseClient"/>
 					access-token-response-client-ref="accessTokenResponseClient"/>
 		</oauth2-client>
 		</oauth2-client>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<client-registrations>
 	<client-registrations>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomClientRegistrationRepository.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2020 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 
 
 	<http auto-config="true">
 	<http auto-config="true">
 		<oauth2-client client-registration-repository-ref="clientRegistrationRepository"/>
 		<oauth2-client client-registration-repository-ref="clientRegistrationRepository"/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<b:bean id="clientRegistrationRepository" class="org.mockito.Mockito" factory-method="mock">
 	<b:bean id="clientRegistrationRepository" class="org.mockito.Mockito" factory-method="mock">

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-CustomConfiguration.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2020 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
 					authorization-request-resolver-ref="authorizationRequestResolver"
 					authorization-request-resolver-ref="authorizationRequestResolver"
 					access-token-response-client-ref="accessTokenResponseClient"/>
 					access-token-response-client-ref="accessTokenResponseClient"/>
 		</oauth2-client>
 		</oauth2-client>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<client-registrations>
 	<client-registrations>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParserTests-Minimal.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2020 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 
 
 	<http auto-config="true">
 	<http auto-config="true">
 		<oauth2-client/>
 		<oauth2-client/>
+		<intercept-url pattern="/**" access="authenticated"/>
 	</http>
 	</http>
 
 
 	<client-registrations>
 	<client-registrations>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTests-ConcurrencyControlMaxSessions.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<session-management session-authentication-error-url="/max-exceeded">
 		<session-management session-authentication-error-url="/max-exceeded">
 			<concurrency-control max-sessions="2" error-if-maximum-exceeded="true"/>
 			<concurrency-control max-sessions="2" error-if-maximum-exceeded="true"/>
 		</session-management>
 		</session-management>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTests-ConcurrencyControlMaxSessionsPlaceHolder.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2021 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<session-management
 		<session-management
 			session-authentication-error-url="/max-exceeded">
 			session-authentication-error-url="/max-exceeded">
 			<concurrency-control
 			<concurrency-control

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTests-ConcurrencyControlSessionRegistryRef.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<session-management
 		<session-management
 			authentication-strategy-explicit-invocation="false">
 			authentication-strategy-explicit-invocation="false">
 			<concurrency-control session-registry-ref="sessionRegistry"/>
 			<concurrency-control session-registry-ref="sessionRegistry"/>

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTransientAuthenticationTests-CreateSessionAlwaysWithTransientAuthentication.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true" create-session="always">
 	<http auto-config="true" create-session="always">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/SessionManagementConfigTransientAuthenticationTests-WithTransientAuthentication.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2018 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<csrf disabled="true"/>
 		<csrf disabled="true"/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/WellKnownChangePasswordBeanDefinitionParserTests-CustomChangePasswordPage.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2021 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<password-management change-password-page="/custom-change-password-page"/>
 		<password-management change-password-page="/custom-change-password-page"/>
 	</http>
 	</http>
 
 

+ 2 - 1
config/src/test/resources/org/springframework/security/config/http/WellKnownChangePasswordBeanDefinitionParserTests-DefaultChangePasswordPage.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 <!--
-  ~ Copyright 2002-2021 the original author or authors.
+  ~ Copyright 2002-2022 the original author or authors.
   ~
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
   ~ you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 			https://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
 	<http auto-config="true">
 	<http auto-config="true">
+		<intercept-url pattern="/**" access="authenticated"/>
 		<password-management/>
 		<password-management/>
 	</http>
 	</http>
 
 

+ 7 - 3
web/src/main/java/org/springframework/security/web/access/intercept/RequestMatcherDelegatingAuthorizationManager.java

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2002-2021 the original author or authors.
+ * Copyright 2002-2022 the original author or authors.
  *
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * you may not use this file except in compliance with the License.
@@ -44,6 +44,8 @@ import org.springframework.util.Assert;
  */
  */
 public final class RequestMatcherDelegatingAuthorizationManager implements AuthorizationManager<HttpServletRequest> {
 public final class RequestMatcherDelegatingAuthorizationManager implements AuthorizationManager<HttpServletRequest> {
 
 
+	private static final AuthorizationDecision DENY = new AuthorizationDecision(false);
+
 	private final Log logger = LogFactory.getLog(getClass());
 	private final Log logger = LogFactory.getLog(getClass());
 
 
 	private final List<RequestMatcherEntry<AuthorizationManager<RequestAuthorizationContext>>> mappings;
 	private final List<RequestMatcherEntry<AuthorizationManager<RequestAuthorizationContext>>> mappings;
@@ -81,8 +83,10 @@ public final class RequestMatcherDelegatingAuthorizationManager implements Autho
 						new RequestAuthorizationContext(request, matchResult.getVariables()));
 						new RequestAuthorizationContext(request, matchResult.getVariables()));
 			}
 			}
 		}
 		}
-		this.logger.trace("Abstaining since did not find matching RequestMatcher");
-		return null;
+		if (this.logger.isTraceEnabled()) {
+			this.logger.trace(LogMessage.of(() -> "Denying request since did not find matching RequestMatcher"));
+		}
+		return DENY;
 	}
 	}
 
 
 	/**
 	/**

+ 6 - 8
web/src/test/java/org/springframework/security/web/access/intercept/RequestMatcherDelegatingAuthorizationManagerTests.java

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2002-2021 the original author or authors.
+ * Copyright 2002-2022 the original author or authors.
  *
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * you may not use this file except in compliance with the License.
@@ -67,8 +67,7 @@ public class RequestMatcherDelegatingAuthorizationManagerTests {
 	public void checkWhenMultipleMappingsConfiguredThenDelegatesMatchingManager() {
 	public void checkWhenMultipleMappingsConfiguredThenDelegatesMatchingManager() {
 		RequestMatcherDelegatingAuthorizationManager manager = RequestMatcherDelegatingAuthorizationManager.builder()
 		RequestMatcherDelegatingAuthorizationManager manager = RequestMatcherDelegatingAuthorizationManager.builder()
 				.add(new MvcRequestMatcher(null, "/grant"), (a, o) -> new AuthorizationDecision(true))
 				.add(new MvcRequestMatcher(null, "/grant"), (a, o) -> new AuthorizationDecision(true))
-				.add(new MvcRequestMatcher(null, "/deny"), (a, o) -> new AuthorizationDecision(false))
-				.add(new MvcRequestMatcher(null, "/neutral"), (a, o) -> null).build();
+				.add(new MvcRequestMatcher(null, "/deny"), (a, o) -> new AuthorizationDecision(false)).build();
 
 
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
 
 
@@ -80,11 +79,10 @@ public class RequestMatcherDelegatingAuthorizationManagerTests {
 		assertThat(deny).isNotNull();
 		assertThat(deny).isNotNull();
 		assertThat(deny.isGranted()).isFalse();
 		assertThat(deny.isGranted()).isFalse();
 
 
-		AuthorizationDecision neutral = manager.check(authentication, new MockHttpServletRequest(null, "/neutral"));
-		assertThat(neutral).isNull();
-
-		AuthorizationDecision abstain = manager.check(authentication, new MockHttpServletRequest(null, "/abstain"));
-		assertThat(abstain).isNull();
+		AuthorizationDecision defaultDeny = manager.check(authentication,
+				new MockHttpServletRequest(null, "/unmapped"));
+		assertThat(defaultDeny).isNotNull();
+		assertThat(defaultDeny.isGranted()).isFalse();
 	}
 	}
 
 
 	@Test
 	@Test