Skip to content

Commit

Permalink
Add Kotlin example for logout configuration of reactive authentication
Browse files Browse the repository at this point in the history
Closes gh-10819
  • Loading branch information
talerngpong authored and eleftherias committed Feb 11, 2022
1 parent 9f9fbb3 commit d0faff6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion docs/modules/ROOT/pages/reactive/authentication/logout.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ This will:
Often, you will want to also invalidate the session on logout.
To achieve this, you can add the `WebSessionServerLogoutHandler` to your logout configuration, like so:

[source,java]
.Java
[source,java,role="primary"]
----
@Bean
SecurityWebFilterChain http(ServerHttpSecurity http) throws Exception {
Expand All @@ -26,3 +27,23 @@ SecurityWebFilterChain http(ServerHttpSecurity http) throws Exception {
return http.build();
}
----

.Kotlin
[source,kotlin,role="secondary"]
----
@Bean
fun http(http: ServerHttpSecurity): SecurityWebFilterChain {
val customLogoutHandler = DelegatingServerLogoutHandler(
WebSessionServerLogoutHandler(), SecurityContextServerLogoutHandler()
)
return http {
authorizeExchange {
authorize(anyExchange, authenticated)
}
logout {
logoutHandler = customLogoutHandler
}
}
}
----

0 comments on commit d0faff6

Please sign in to comment.