Skip to content

Commit

Permalink
Update max sessions docs
Browse files Browse the repository at this point in the history
Add WebSessionStore constructor parameter to the handler

Issue gh-6192
  • Loading branch information
marcusdacoregio committed Feb 27, 2024
1 parent a5ce8ae commit c86fd99
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ Java::
[source,java,role="primary"]
----
@Bean
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
SecurityWebFilterChain filterChain(ServerHttpSecurity http, DefaultWebSessionManager webSessionManager) {
http
// ...
.sessionManagement((sessions) -> sessions
.concurrentSessions((concurrency) -> concurrency
.maximumSessions(SessionLimit.of(1))
.maximumSessionsExceededHandler(new PreventLoginMaximumSessionsExceededHandler())
.maximumSessionsExceededHandler(new PreventLoginMaximumSessionsExceededHandler(webSessionManager.getSessionStore()))
)
);
return http.build();
Expand All @@ -225,13 +225,13 @@ Kotlin::
[source,kotlin,role="secondary"]
----
@Bean
open fun springSecurity(http: ServerHttpSecurity): SecurityWebFilterChain {
open fun springSecurity(http: ServerHttpSecurity, webSessionManager: DefaultWebSessionManager): SecurityWebFilterChain {
return http {
// ...
sessionManagement {
sessionConcurrency {
maximumSessions = SessionLimit.of(1)
maximumSessionsExceededHandler = PreventLoginMaximumSessionsExceededHandler()
maximumSessionsExceededHandler = PreventLoginMaximumSessionsExceededHandler(webSessionManager.sessionStore)
}
}
}
Expand Down Expand Up @@ -380,6 +380,11 @@ public class SessionControl {
----
======

[NOTE]
====
If you are not using the `WebSessionStoreReactiveSessionRegistry` as the implementation, and you want the `WebSession` to be invalidated as well, you will need to use the `WebSessionStore` to retrieve and invalidate the `WebSession`.
====

[[disabling-for-authentication-filters]]
== Disabling It for Some Authentication Filters

Expand Down

0 comments on commit c86fd99

Please sign in to comment.