Class ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec
java.lang.Object
org.springframework.security.config.web.server.ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec
- Enclosing class:
 - ServerHttpSecurity.SessionManagementSpec
 
Configures how many sessions are allowed for a given user.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionmaximumSessions(SessionLimit sessionLimit) Sets the maximum number of sessions allowed for any user.maximumSessionsExceededHandler(ServerMaximumSessionsExceededHandler maximumSessionsExceededHandler) Sets theServerMaximumSessionsExceededHandlerto use when the maximum number of sessions is exceeded.sessionRegistry(ReactiveSessionRegistry reactiveSessionRegistry) Sets theReactiveSessionRegistryto use. 
- 
Constructor Details
- 
ConcurrentSessionsSpec
public ConcurrentSessionsSpec() 
 - 
 - 
Method Details
- 
sessionRegistry
public ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec sessionRegistry(ReactiveSessionRegistry reactiveSessionRegistry) Sets theReactiveSessionRegistryto use.- Parameters:
 reactiveSessionRegistry- theReactiveSessionRegistryto use- Returns:
 - the 
ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpecto continue customizing 
 - 
maximumSessions
public ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec maximumSessions(SessionLimit sessionLimit) Sets the maximum number of sessions allowed for any user. You can useSessionLimit.of(int)to specify a positive integer orSessionLimit.UNLIMITEDto allow unlimited sessions. To customize the maximum number of sessions on a per-user basis, you can provide a customSessionLimitimplementation, like so:http .sessionManagement((sessions) -> sessions .concurrentSessions((concurrency) -> concurrency .maximumSessions((authentication) -> { if (authentication.getName().equals("admin")) { return Mono.empty() // unlimited sessions for admin } return Mono.just(1); // one session for every other user }) ) )- Parameters:
 sessionLimit- the maximum number of sessions allowed for any user- Returns:
 - the 
ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpecto continue customizing 
 - 
maximumSessionsExceededHandler
public ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec maximumSessionsExceededHandler(ServerMaximumSessionsExceededHandler maximumSessionsExceededHandler) Sets theServerMaximumSessionsExceededHandlerto use when the maximum number of sessions is exceeded.- Parameters:
 maximumSessionsExceededHandler- theServerMaximumSessionsExceededHandlerto use- Returns:
 - the 
ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpecto continue customizing 
 
 -