File tree 2 files changed +29
-0
lines changed
main/java/org/springframework/security/config/annotation/web/configurers
test/java/org/springframework/security/config/annotation/web/configurers
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 25
25
import org .springframework .security .config .annotation .web .HttpSecurityBuilder ;
26
26
import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
27
27
import org .springframework .security .web .savedrequest .HttpSessionRequestCache ;
28
+ import org .springframework .security .web .savedrequest .NullRequestCache ;
28
29
import org .springframework .security .web .savedrequest .RequestCache ;
29
30
import org .springframework .security .web .savedrequest .RequestCacheAwareFilter ;
30
31
import org .springframework .security .web .util .matcher .AndRequestMatcher ;
@@ -87,6 +88,12 @@ public RequestCacheConfigurer<H> requestCache(RequestCache requestCache) {
87
88
return this ;
88
89
}
89
90
91
+ @ Override
92
+ public H disable () {
93
+ getBuilder ().setSharedObject (RequestCache .class , new NullRequestCache ());
94
+ return super .disable ();
95
+ }
96
+
90
97
@ Override
91
98
public void init (H http ) throws Exception {
92
99
http .setSharedObject (RequestCache .class , getRequestCache (http ));
Original file line number Diff line number Diff line change @@ -249,6 +249,28 @@ protected void configure(HttpSecurity http) throws Exception {
249
249
}
250
250
}
251
251
252
+ // gh-6102
253
+ @ Test
254
+ public void getWhenRequestCacheIsDisabledThenExceptionTranslationFilterDoesNotStoreRequest () throws Exception {
255
+ this .spring .register (RequestCacheDisabledConfig .class , ExceptionHandlingConfigurerTests .DefaultSecurityConfig .class ).autowire ();
256
+
257
+ MockHttpSession session = (MockHttpSession )
258
+ this .mvc .perform (get ("/bob" ))
259
+ .andReturn ().getRequest ().getSession ();
260
+
261
+ this .mvc .perform (formLogin (session ))
262
+ .andExpect (redirectedUrl ("/" ));
263
+ }
264
+
265
+ @ EnableWebSecurity
266
+ static class RequestCacheDisabledConfig extends WebSecurityConfigurerAdapter {
267
+ @ Override
268
+ protected void configure (HttpSecurity http ) throws Exception {
269
+ super .configure (http );
270
+ http .requestCache ().disable ();
271
+ }
272
+ }
273
+
252
274
@ EnableWebSecurity
253
275
static class DefaultSecurityConfig {
254
276
You can’t perform that action at this time.
0 commit comments