浏览代码

Add Kotlin logout samples to docs

Issue gh-8172
Eleftheria Stein 5 年之前
父节点
当前提交
0bdf6859be
共有 1 个文件被更改,包括 23 次插入2 次删除
  1. 23 2
      docs/manual/src/docs/asciidoc/_includes/servlet/authentication/logout.adoc

+ 23 - 2
docs/manual/src/docs/asciidoc/_includes/servlet/authentication/logout.adoc

@@ -2,7 +2,7 @@
 == Handling Logouts
 
 [[logout-java-configuration]]
-=== Logout Java Configuration
+=== Logout Java/Kotlin Configuration
 
 When using the `{security-api-url}org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.html[WebSecurityConfigurerAdapter]`, logout capabilities are automatically applied.
 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:
 
 Similar to configuring login capabilities, however, you also have various options to further customize your logout requirements:
 
-[source,java]
+.Logout Configuration
+====
+.Java
+[source,java,role="primary"]
 ----
 protected void configure(HttpSecurity http) throws Exception {
     http
@@ -30,6 +33,24 @@ protected void configure(HttpSecurity http) throws Exception {
 }
 ----
 
+.Kotlin
+[source,kotlin,role="secondary"]
+-----
+override fun configure(http: HttpSecurity) {
+    http {
+        logout {
+            logoutUrl = "/my/logout"                              // <1>
+            logoutSuccessUrl = "/my/index"                        // <2>
+            logoutSuccessHandler = customLogoutSuccessHandler     // <3>
+            invalidateHttpSession = true                          // <4>
+            addLogoutHandler(logoutHandler)                       // <5>
+            deleteCookies(cookieNamesToClear)                     // <6>
+        }
+    }
+}
+-----
+====
+
 <1> Provides logout support.
 This is automatically applied when using `WebSecurityConfigurerAdapter`.
 <2> The URL that triggers log out to occur (default is `/logout`).