Skip to content

Commit 2e92dad

Browse files
Merge branch '5.7.x' into 5.8.x
Closes gh-12835
2 parents ebabcaa + 84cca81 commit 2e92dad

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
@@ -50,7 +50,7 @@
5050
import org.springframework.security.util.FieldUtils;
5151
import org.springframework.security.web.DefaultRedirectStrategy;
5252
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
53-
import org.springframework.security.web.context.RequestAttributeSecurityContextRepository;
53+
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
5454
import org.springframework.security.web.context.SecurityContextRepository;
5555
import org.springframework.security.web.util.matcher.AnyRequestMatcher;
5656
import org.springframework.test.util.ReflectionTestUtils;
@@ -511,10 +511,10 @@ public void setSwitchFailureUrlWhenValidThenNoException() {
511511
}
512512

513513
@Test
514-
void filterWhenDefaultSecurityContextRepositoryThenRequestAttributeRepository() {
514+
void filterWhenDefaultSecurityContextRepositoryThenHttpSessionRepository() {
515515
SwitchUserFilter switchUserFilter = new SwitchUserFilter();
516516
assertThat(ReflectionTestUtils.getField(switchUserFilter, "securityContextRepository"))
517-
.isInstanceOf(RequestAttributeSecurityContextRepository.class);
517+
.isInstanceOf(HttpSessionSecurityContextRepository.class);
518518
}
519519

520520
@Test

0 commit comments

Comments
 (0)