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 23
23
import org .springframework .security .config .annotation .web .HttpSecurityBuilder ;
24
24
import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
25
25
import org .springframework .security .web .savedrequest .HttpSessionRequestCache ;
26
+ import org .springframework .security .web .savedrequest .NullRequestCache ;
26
27
import org .springframework .security .web .savedrequest .RequestCache ;
27
28
import org .springframework .security .web .savedrequest .RequestCacheAwareFilter ;
28
29
import org .springframework .security .web .util .matcher .AndRequestMatcher ;
@@ -85,6 +86,12 @@ public RequestCacheConfigurer<H> requestCache(RequestCache requestCache) {
85
86
return this ;
86
87
}
87
88
89
+ @ Override
90
+ public H disable () {
91
+ getBuilder ().setSharedObject (RequestCache .class , new NullRequestCache ());
92
+ return super .disable ();
93
+ }
94
+
88
95
@ Override
89
96
public void init (H http ) throws Exception {
90
97
http .setSharedObject (RequestCache .class , getRequestCache (http ));
Original file line number Diff line number Diff line change @@ -236,6 +236,28 @@ protected void configure(HttpSecurity http) throws Exception {
236
236
}
237
237
}
238
238
239
+ // gh-6102
240
+ @ Test
241
+ public void getWhenRequestCacheIsDisabledThenExceptionTranslationFilterDoesNotStoreRequest () throws Exception {
242
+ this .spring .register (RequestCacheDisabledConfig .class , DefaultSecurityConfig .class ).autowire ();
243
+
244
+ MockHttpSession session = (MockHttpSession )
245
+ this .mvc .perform (get ("/bob" ))
246
+ .andReturn ().getRequest ().getSession ();
247
+
248
+ this .mvc .perform (formLogin (session ))
249
+ .andExpect (redirectedUrl ("/" ));
250
+ }
251
+
252
+ @ EnableWebSecurity
253
+ static class RequestCacheDisabledConfig extends WebSecurityConfigurerAdapter {
254
+ @ Override
255
+ protected void configure (HttpSecurity http ) throws Exception {
256
+ super .configure (http );
257
+ http .requestCache ().disable ();
258
+ }
259
+ }
260
+
239
261
@ EnableWebSecurity
240
262
static class DefaultSecurityConfig {
241
263
You can’t perform that action at this time.
0 commit comments