This is using Spring Security 4.0 RELEASE and Spring Security CAS.
I'm setting up session concurrency management using Java Config:
http
.sessionManagement()
.maximumSessions(1)
.maxSessionsPreventsLogin(false)
.expiredUrl("/tooManySessions")
.and()
.and();
HttpSessionEventublisher is enabled in a WebApplicationInitializer and I can confirm it is working as I'm using it for other stuff too that is working:
@Override
protected void registerDispatcherServlet(ServletContext servletContext) {
super.registerDispatcherServlet(servletContext);
// to handle session creation and destruction events
servletContext.addListener(new HttpSessionEventPublisher());
}
However at runtime it looks like the code is never called.
Note that I'm using Spring Security CAs. Could this impact session concurrency management?
Turns out that to get Session Management working with CAS when using Java Config (don't know about XML config) you need to make sure you explicitly set
SessionAuthenticationStrategy(s) onCASAuthorizationFilter.I solved this by using an ObjectPostProcessor on
CsfrFilter(doing it in session manangement setup would not get the Csrf specificSessionAuthenticationStrategy):