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 SummaryConstructors
- 
Method SummaryModifier 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- 
ConcurrentSessionsSpecpublic ConcurrentSessionsSpec()
 
- 
- 
Method Details- 
sessionRegistrypublic ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec sessionRegistry(ReactiveSessionRegistry reactiveSessionRegistry) Sets theReactiveSessionRegistryto use.- Parameters:
- reactiveSessionRegistry- the- ReactiveSessionRegistryto use
- Returns:
- the ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpecto continue customizing
 
- 
maximumSessionspublic 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
 
- 
maximumSessionsExceededHandlerpublic ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpec maximumSessionsExceededHandler(ServerMaximumSessionsExceededHandler maximumSessionsExceededHandler) Sets theServerMaximumSessionsExceededHandlerto use when the maximum number of sessions is exceeded.- Parameters:
- maximumSessionsExceededHandler- the- ServerMaximumSessionsExceededHandlerto use
- Returns:
- the ServerHttpSecurity.SessionManagementSpec.ConcurrentSessionsSpecto continue customizing
 
 
-