Skip to content

Commit aed203f

Browse files
committed
Docs for WebSessionServerLogoutHandler
Issue gh-4838
1 parent a4c088a commit aed203f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

docs/manual/src/docs/asciidoc/_includes/reactive/index.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ include::registered-oauth2-authorized-client.adoc[leveloffset=+1]
1010

1111
include::x509.adoc[leveloffset=+1]
1212

13+
include::logout.adoc[leveloffset=+1]
14+
1315
include::webclient.adoc[leveloffset=+1]
1416

1517
include::method.adoc[leveloffset=+1]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[[reactive-logout]]
2+
= Logout
3+
4+
Spring Security provides a logout endpoint by default.
5+
Once logged in, you can `GET /logout` to see a default logout confirmation page, or you can `POST /logout` to initiate logout.
6+
This will:
7+
8+
- clear the `ServerCsrfTokenRepository`, `ServerSecurityContextRepository`, and
9+
- redirect back to the login page
10+
11+
Often, you will want to also invalidate the session on logout.
12+
To achieve this, you can add the `WebSessionServerLogoutHandler` to your logout configuration, like so:
13+
14+
[source,java]
15+
----
16+
@Bean
17+
SecurityWebFilterChain http(ServerHttpSecurity http) throws Exception {
18+
DelegatingServerLogoutHandler logoutHandler = new DelegatingServerLogoutHandler(
19+
new WebSessionServerLogoutHandler(), new SecurityContextServerLogoutHandler()
20+
);
21+
22+
http
23+
.authorizeExchange((exchange) -> exchange.anyExchange().authenticated())
24+
.logout((logout) -> logout.logoutHandler(logoutHandler));
25+
26+
return http.build();
27+
}
28+
----

0 commit comments

Comments
 (0)