Skip to content

Commit 5d8df25

Browse files
Merge branch '6.0.x'
Closes gh-12681
2 parents 28d353d + ce222de commit 5d8df25

File tree

2 files changed

+836
-183
lines changed

2 files changed

+836
-183
lines changed

docs/modules/ROOT/pages/servlet/architecture.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,60 @@ The code below demonstrates how to customize the `RequestCache` implementation t
268268

269269
include::partial$servlet/architecture/request-cache-continue.adoc[]
270270

271+
[[requestcache-prevent-saved-request]]
272+
==== Prevent the Request From Being Saved
273+
274+
There are a number of reasons you may want to not store the user's unauthenticated request in the session.
275+
You may want to offload that storage onto the user's browser or store it in a database.
276+
Or you may want to shut off this feature since you always want to redirect the user to the home page instead of the page they tried to visit before login.
277+
278+
To do that, you can use {security-api-url}org/springframework/security/web/savedrequest/NullRequestCache.html[the `NullRequestCache` implementation].
279+
280+
.Prevent the Request From Being Saved
281+
====
282+
.Java
283+
[source,java,role="primary"]
284+
----
285+
@Bean
286+
SecurityFilterChain springSecurity(HttpSecurity http) throws Exception {
287+
RequestCache nullRequestCache = new NullRequestCache();
288+
http
289+
// ...
290+
.requestCache((cache) -> cache
291+
.requestCache(nullRequestCache)
292+
);
293+
return http.build();
294+
}
295+
----
296+
297+
.Kotlin
298+
[source,kotlin,role="secondary"]
299+
----
300+
@Bean
301+
open fun springSecurity(http: HttpSecurity): SecurityFilterChain {
302+
val nullRequestCache = NullRequestCache()
303+
http {
304+
requestCache {
305+
requestCache = nullRequestCache
306+
}
307+
}
308+
return http.build()
309+
}
310+
----
311+
312+
.XML
313+
[source,xml,role="secondary"]
314+
----
315+
<http auto-config="true">
316+
<!-- ... -->
317+
<request-cache ref="nullRequestCache"/>
318+
</http>
319+
320+
<b:bean id="nullRequestCache" class="org.springframework.security.web.savedrequest.NullRequestCache"/>
321+
----
322+
====
323+
324+
271325
[[requestcacheawarefilter]]
272326
=== RequestCacheAwareFilter
273327

0 commit comments

Comments
 (0)