parent
9a9a43a0c0
commit
e79b6b3ac8
|
@ -64,7 +64,7 @@ import org.springframework.security.web.session.ForceEagerSessionCreationFilter;
|
|||
public final class SecurityContextConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
extends AbstractHttpConfigurer<SecurityContextConfigurer<H>, H> {
|
||||
|
||||
private boolean requireExplicitSave;
|
||||
private boolean requireExplicitSave = true;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.springframework.security.web.SecurityFilterChain;
|
|||
import org.springframework.security.web.access.ExceptionTranslationFilter;
|
||||
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
|
||||
import org.springframework.security.web.context.SecurityContextHolderFilter;
|
||||
import org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter;
|
||||
import org.springframework.security.web.header.HeaderWriterFilter;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class HttpSecurityAddFilterTest {
|
|||
this.spring.register(MyOtherFilterRelativeToMyFilterAtConfig.class).autowire();
|
||||
|
||||
assertThatFilters().containsSubsequence(WebAsyncManagerIntegrationFilter.class, MyFilter.class,
|
||||
MyOtherFilter.class, SecurityContextPersistenceFilter.class);
|
||||
MyOtherFilter.class, SecurityContextHolderFilter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -90,6 +90,7 @@ public class SecurityReactorContextConfigurationResourceServerTests {
|
|||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.securityContext().requireExplicitSave(false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
|
|||
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.security.web.authentication.logout.LogoutFilter;
|
||||
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
|
||||
import org.springframework.security.web.context.SecurityContextHolderFilter;
|
||||
import org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter;
|
||||
import org.springframework.security.web.csrf.CsrfFilter;
|
||||
import org.springframework.security.web.csrf.CsrfToken;
|
||||
|
@ -105,7 +105,7 @@ public class DefaultFiltersTests {
|
|||
List<? extends Class<? extends Filter>> classes = secondFilter.getFilters().stream().map(Filter::getClass)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(classes.contains(WebAsyncManagerIntegrationFilter.class)).isTrue();
|
||||
assertThat(classes.contains(SecurityContextPersistenceFilter.class)).isTrue();
|
||||
assertThat(classes.contains(SecurityContextHolderFilter.class)).isTrue();
|
||||
assertThat(classes.contains(HeaderWriterFilter.class)).isTrue();
|
||||
assertThat(classes.contains(LogoutFilter.class)).isTrue();
|
||||
assertThat(classes.contains(CsrfFilter.class)).isTrue();
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -74,16 +75,16 @@ public class SecurityContextConfigurerTests {
|
|||
@Test
|
||||
public void configureWhenRegisteringObjectPostProcessorThenInvokedOnSecurityContextPersistenceFilter() {
|
||||
this.spring.register(ObjectPostProcessorConfig.class).autowire();
|
||||
verify(ObjectPostProcessorConfig.objectPostProcessor).postProcess(any(SecurityContextPersistenceFilter.class));
|
||||
verify(ObjectPostProcessorConfig.objectPostProcessor).postProcess(any(SecurityContextHolderFilter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securityContextWhenInvokedTwiceThenUsesOriginalSecurityContextRepository() throws Exception {
|
||||
this.spring.register(DuplicateDoesNotOverrideConfig.class).autowire();
|
||||
given(DuplicateDoesNotOverrideConfig.SCR.loadContext(any(HttpRequestResponseHolder.class)))
|
||||
.willReturn(mock(SecurityContext.class));
|
||||
given(DuplicateDoesNotOverrideConfig.SCR.loadContext(any(HttpServletRequest.class)))
|
||||
.willReturn(() -> mock(SecurityContext.class));
|
||||
this.mvc.perform(get("/"));
|
||||
verify(DuplicateDoesNotOverrideConfig.SCR).loadContext(any(HttpRequestResponseHolder.class));
|
||||
verify(DuplicateDoesNotOverrideConfig.SCR).loadContext(any(HttpServletRequest.class));
|
||||
}
|
||||
|
||||
// SEC-2932
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.springframework.security.web.authentication.session.ChangeSessionIdAu
|
|||
import org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy;
|
||||
import org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy;
|
||||
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
||||
import org.springframework.security.web.context.HttpRequestResponseHolder;
|
||||
import org.springframework.security.web.context.SecurityContextRepository;
|
||||
import org.springframework.security.web.savedrequest.RequestCache;
|
||||
import org.springframework.security.web.session.ConcurrentSessionFilter;
|
||||
|
@ -101,11 +100,9 @@ public class SessionManagementConfigurerTests {
|
|||
public void sessionManagementWhenConfiguredThenDoesNotOverrideSecurityContextRepository() throws Exception {
|
||||
SessionManagementSecurityContextRepositoryConfig.SECURITY_CONTEXT_REPO = mock(SecurityContextRepository.class);
|
||||
given(SessionManagementSecurityContextRepositoryConfig.SECURITY_CONTEXT_REPO
|
||||
.loadContext(any(HttpRequestResponseHolder.class))).willReturn(mock(SecurityContext.class));
|
||||
.loadContext(any(HttpServletRequest.class))).willReturn(() -> mock(SecurityContext.class));
|
||||
this.spring.register(SessionManagementSecurityContextRepositoryConfig.class).autowire();
|
||||
this.mvc.perform(get("/"));
|
||||
verify(SessionManagementSecurityContextRepositoryConfig.SECURITY_CONTEXT_REPO)
|
||||
.saveContext(any(SecurityContext.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue