Skip to content

Commit 0bdf685

Browse files
committed
Add Kotlin logout samples to docs
Issue gh-8172
1 parent 4fb5ff3 commit 0bdf685

File tree

1 file changed

+23
-2
lines changed
  • docs/manual/src/docs/asciidoc/_includes/servlet/authentication

1 file changed

+23
-2
lines changed

docs/manual/src/docs/asciidoc/_includes/servlet/authentication/logout.adoc

+23-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
== Handling Logouts
33

44
[[logout-java-configuration]]
5-
=== Logout Java Configuration
5+
=== Logout Java/Kotlin Configuration
66

77
When using the `{security-api-url}org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.html[WebSecurityConfigurerAdapter]`, logout capabilities are automatically applied.
88
The default is that accessing the URL `/logout` will log the user out by:
@@ -14,7 +14,10 @@ The default is that accessing the URL `/logout` will log the user out by:
1414

1515
Similar to configuring login capabilities, however, you also have various options to further customize your logout requirements:
1616

17-
[source,java]
17+
.Logout Configuration
18+
====
19+
.Java
20+
[source,java,role="primary"]
1821
----
1922
protected void configure(HttpSecurity http) throws Exception {
2023
http
@@ -30,6 +33,24 @@ protected void configure(HttpSecurity http) throws Exception {
3033
}
3134
----
3235
36+
.Kotlin
37+
[source,kotlin,role="secondary"]
38+
-----
39+
override fun configure(http: HttpSecurity) {
40+
http {
41+
logout {
42+
logoutUrl = "/my/logout" // <1>
43+
logoutSuccessUrl = "/my/index" // <2>
44+
logoutSuccessHandler = customLogoutSuccessHandler // <3>
45+
invalidateHttpSession = true // <4>
46+
addLogoutHandler(logoutHandler) // <5>
47+
deleteCookies(cookieNamesToClear) // <6>
48+
}
49+
}
50+
}
51+
-----
52+
====
53+
3354
<1> Provides logout support.
3455
This is automatically applied when using `WebSecurityConfigurerAdapter`.
3556
<2> The URL that triggers log out to occur (default is `/logout`).

0 commit comments

Comments
 (0)