Merge branch '6.3.x' into 6.4.x
	
		
			
	
		
	
	
		
			
				
	
				CI / Build (17, ubuntu-latest) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build (17, windows-latest) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Test Against Snapshots (17, 17) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Test Against Snapshots (21-ea, 21) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Check Samples (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Deploy Docs / build (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Trigger Dependabot Auto Merge Forward / Trigger Workflow (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Deploy Artifacts (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Deploy Docs (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Deploy Schema (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Perform Release (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Send Notification (push) Has been cancelled
				
					Details
				
			
		
	
				
					
				
			
				
	
				CI / Build (17, ubuntu-latest) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build (17, windows-latest) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Test Against Snapshots (17, 17) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Test Against Snapshots (21-ea, 21) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Check Samples (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Deploy Docs / build (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Trigger Dependabot Auto Merge Forward / Trigger Workflow (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Deploy Artifacts (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Deploy Docs (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Deploy Schema (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Perform Release (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Send Notification (push) Has been cancelled
				
					Details
				
			
		
	Closes gh-16844
This commit is contained in:
		
						commit
						26c63aeb01
					
				|  | @ -183,6 +183,9 @@ public class CsrfBeanDefinitionParser implements BeanDefinitionParser { | ||||||
| 		BeanDefinitionBuilder csrfAuthenticationStrategy = BeanDefinitionBuilder | 		BeanDefinitionBuilder csrfAuthenticationStrategy = BeanDefinitionBuilder | ||||||
| 			.rootBeanDefinition(CsrfAuthenticationStrategy.class); | 			.rootBeanDefinition(CsrfAuthenticationStrategy.class); | ||||||
| 		csrfAuthenticationStrategy.addConstructorArgReference(this.csrfRepositoryRef); | 		csrfAuthenticationStrategy.addConstructorArgReference(this.csrfRepositoryRef); | ||||||
|  | 		if (StringUtils.hasText(this.requestHandlerRef)) { | ||||||
|  | 			csrfAuthenticationStrategy.addPropertyReference("requestHandler", this.requestHandlerRef); | ||||||
|  | 		} | ||||||
| 		return csrfAuthenticationStrategy.getBeanDefinition(); | 		return csrfAuthenticationStrategy.getBeanDefinition(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -336,6 +336,43 @@ public class CsrfConfigTests { | ||||||
| 		// @formatter:on | 		// @formatter:on | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	@Test | ||||||
|  | 	public void postWhenUsingCsrfAndXorCsrfTokenRequestAttributeHandlerThenCsrfAuthenticationStrategyUses() | ||||||
|  | 			throws Exception { | ||||||
|  | 		this.spring.configLocations(this.xml("WithXorCsrfTokenRequestAttributeHandler"), this.xml("shared-controllers")) | ||||||
|  | 			.autowire(); | ||||||
|  | 		// @formatter:off | ||||||
|  | 		MvcResult mvcResult1 = this.mvc.perform(get("/csrf")) | ||||||
|  | 				.andExpect(status().isOk()) | ||||||
|  | 				.andReturn(); | ||||||
|  | 		// @formatter:on | ||||||
|  | 		MockHttpServletRequest request1 = mvcResult1.getRequest(); | ||||||
|  | 		MockHttpSession session = (MockHttpSession) request1.getSession(); | ||||||
|  | 		CsrfTokenRepository repository = WebTestUtils.getCsrfTokenRepository(request1); | ||||||
|  | 		// @formatter:off | ||||||
|  | 		MockHttpServletRequestBuilder login = post("/login") | ||||||
|  | 			.param("username", "user") | ||||||
|  | 			.param("password", "password") | ||||||
|  | 			.session(session) | ||||||
|  | 			.with(csrf()); | ||||||
|  | 		this.mvc.perform(login) | ||||||
|  | 			.andExpect(status().is3xxRedirection()) | ||||||
|  | 			.andExpect(redirectedUrl("/")); | ||||||
|  | 		// @formatter:on | ||||||
|  | 		assertThat(repository.loadToken(request1)).isNull(); | ||||||
|  | 		// @formatter:off | ||||||
|  | 		MvcResult mvcResult2 = this.mvc.perform(get("/csrf").session(session)) | ||||||
|  | 			.andExpect(status().isOk()) | ||||||
|  | 			.andReturn(); | ||||||
|  | 		// @formatter:on | ||||||
|  | 		MockHttpServletRequest request2 = mvcResult2.getRequest(); | ||||||
|  | 		CsrfToken csrfToken = repository.loadToken(request2); | ||||||
|  | 		CsrfToken csrfTokenAttribute = (CsrfToken) request2.getAttribute(CsrfToken.class.getName()); | ||||||
|  | 		assertThat(csrfTokenAttribute).isNotNull(); | ||||||
|  | 		assertThat(csrfTokenAttribute.getToken()).isNotBlank(); | ||||||
|  | 		assertThat(csrfTokenAttribute.getToken()).isNotEqualTo(csrfToken.getToken()); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	@Test | 	@Test | ||||||
| 	public void postWhenHasCsrfTokenButSessionExpiresThenRequestIsCancelledAfterSuccessfulAuthentication() | 	public void postWhenHasCsrfTokenButSessionExpiresThenRequestIsCancelledAfterSuccessfulAuthentication() | ||||||
| 			throws Exception { | 			throws Exception { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue