|  | 
| 101 | 101 | import org.springframework.security.web.authentication.HttpStatusEntryPoint; | 
| 102 | 102 | import org.springframework.security.web.context.HttpRequestResponseHolder; | 
| 103 | 103 | import org.springframework.security.web.context.HttpSessionSecurityContextRepository; | 
|  | 104 | +import org.springframework.security.web.context.NullSecurityContextRepository; | 
| 104 | 105 | import org.springframework.security.web.context.SecurityContextRepository; | 
| 105 | 106 | import org.springframework.security.web.session.HttpSessionDestroyedEvent; | 
| 106 | 107 | import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher; | 
|  | 
| 110 | 111 | 
 | 
| 111 | 112 | import static org.assertj.core.api.Assertions.assertThat; | 
| 112 | 113 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | 
|  | 114 | +import static org.assertj.core.api.Assertions.assertThatNoException; | 
| 113 | 115 | import static org.mockito.ArgumentMatchers.any; | 
| 114 | 116 | import static org.mockito.ArgumentMatchers.anyString; | 
| 115 | 117 | import static org.mockito.BDDMockito.given; | 
| @@ -696,6 +698,12 @@ public void oidcLoginWhenOAuth2ClientBeansConfiguredThenNotShared() throws Excep | 
| 696 | 698 | 		verifyNoInteractions(clientRegistrationRepository, authorizedClientRepository); | 
| 697 | 699 | 	} | 
| 698 | 700 | 
 | 
|  | 701 | +	// gh-16623 | 
|  | 702 | +	@Test | 
|  | 703 | +	public void oauth2LoginConfigSecurityContextRepository() { | 
|  | 704 | +		assertThatNoException().isThrownBy(() -> loadConfig(OAuth2LoginConfigSecurityContextRepository.class)); | 
|  | 705 | +	} | 
|  | 706 | + | 
| 699 | 707 | 	private void loadConfig(Class<?>... configs) { | 
| 700 | 708 | 		AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); | 
| 701 | 709 | 		applicationContext.register(configs); | 
| @@ -944,6 +952,24 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | 
| 944 | 952 | 
 | 
| 945 | 953 | 	} | 
| 946 | 954 | 
 | 
|  | 955 | +	@Configuration | 
|  | 956 | +	@EnableWebSecurity | 
|  | 957 | +	static class OAuth2LoginConfigSecurityContextRepository extends CommonSecurityFilterChainConfig { | 
|  | 958 | + | 
|  | 959 | +		@Bean | 
|  | 960 | +		SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | 
|  | 961 | +			// @formatter:off | 
|  | 962 | +			http | 
|  | 963 | +				.oauth2Login((login) -> login | 
|  | 964 | +					.clientRegistrationRepository( | 
|  | 965 | +							new InMemoryClientRegistrationRepository(GOOGLE_CLIENT_REGISTRATION)) | 
|  | 966 | +					.securityContextRepository(new NullSecurityContextRepository())); | 
|  | 967 | +			// @formatter:on | 
|  | 968 | +			return super.configureFilterChain(http); | 
|  | 969 | +		} | 
|  | 970 | + | 
|  | 971 | +	} | 
|  | 972 | + | 
| 947 | 973 | 	@Configuration | 
| 948 | 974 | 	@EnableWebSecurity | 
| 949 | 975 | 	static class OAuth2LoginConfigCustomAuthorizationRequestResolver extends CommonSecurityFilterChainConfig { | 
|  | 
0 commit comments