Skip to content

Commit cdc0fa0

Browse files
Merge branch '5.8.x' into 6.0.x
Closes gh-12836
2 parents c06e604 + 2e92dad commit cdc0fa0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
6060
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
6161
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
62+
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
6263
import org.springframework.security.web.context.RequestAttributeSecurityContextRepository;
6364
import org.springframework.security.web.context.SecurityContextRepository;
6465
import org.springframework.security.web.util.UrlUtils;
@@ -148,7 +149,7 @@ public class SwitchUserFilter extends GenericFilterBean implements ApplicationEv
148149

149150
private AuthenticationFailureHandler failureHandler;
150151

151-
private SecurityContextRepository securityContextRepository = new RequestAttributeSecurityContextRepository();
152+
private SecurityContextRepository securityContextRepository = new HttpSessionSecurityContextRepository();
152153

153154
@Override
154155
public void afterPropertiesSet() {

web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import org.springframework.security.util.FieldUtils;
5050
import org.springframework.security.web.DefaultRedirectStrategy;
5151
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
52-
import org.springframework.security.web.context.RequestAttributeSecurityContextRepository;
52+
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
5353
import org.springframework.security.web.context.SecurityContextRepository;
5454
import org.springframework.security.web.util.matcher.AnyRequestMatcher;
5555
import org.springframework.test.util.ReflectionTestUtils;
@@ -510,10 +510,10 @@ public void setSwitchFailureUrlWhenValidThenNoException() {
510510
}
511511

512512
@Test
513-
void filterWhenDefaultSecurityContextRepositoryThenRequestAttributeRepository() {
513+
void filterWhenDefaultSecurityContextRepositoryThenHttpSessionRepository() {
514514
SwitchUserFilter switchUserFilter = new SwitchUserFilter();
515515
assertThat(ReflectionTestUtils.getField(switchUserFilter, "securityContextRepository"))
516-
.isInstanceOf(RequestAttributeSecurityContextRepository.class);
516+
.isInstanceOf(HttpSessionSecurityContextRepository.class);
517517
}
518518

519519
@Test

0 commit comments

Comments
 (0)