Merge branch '6.0.x'

Closes gh-12641
This commit is contained in:
Josh Cummings 2023-02-07 12:46:42 -07:00
commit d91837eadc
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
2 changed files with 15 additions and 0 deletions

View File

@ -380,6 +380,9 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
http.setSharedObject(SecurityContextRepository.class, defaultRepository);
}
}
else {
this.sessionManagementSecurityContextRepository = securityContextRepository;
}
RequestCache requestCache = http.getSharedObject(RequestCache.class);
if (requestCache == null) {
if (stateless) {

View File

@ -125,6 +125,18 @@ public class SessionManagementConfigurerTests {
this.mvc.perform(get("/"));
}
@Test
public void sessionManagementWhenSecurityContextRepositoryIsConfiguredThenUseIt() throws Exception {
SessionManagementSecurityContextRepositoryConfig.SECURITY_CONTEXT_REPO = mock(SecurityContextRepository.class);
given(SessionManagementSecurityContextRepositoryConfig.SECURITY_CONTEXT_REPO
.loadDeferredContext(any(HttpServletRequest.class)))
.willReturn(new TestDeferredSecurityContext(mock(SecurityContext.class), false));
this.spring.register(SessionManagementSecurityContextRepositoryConfig.class).autowire();
this.mvc.perform(get("/"));
verify(SessionManagementSecurityContextRepositoryConfig.SECURITY_CONTEXT_REPO)
.containsContext(any(HttpServletRequest.class));
}
@Test
public void sessionManagementWhenInvokedTwiceThenUsesOriginalSessionCreationPolicy() throws Exception {
this.spring.register(InvokeTwiceDoesNotOverride.class).autowire();