Używam w projekcie WebSecurityConfigurerAdapter i znalazłem feature do zarządzania sesją, jak poniżej.
Czy można w tym jakoś ustawić customowy czas sesji?
w xmlu to można było chyba tak ustawić:
<session-config>
<session-timeout>15</session-timeout>
</session-config>
Override
protected void configure(HttpSecurity http) {
http.authorizeRequests()
.antMatchers()
// links, roles here etc.
// session management
.sessionManagement().invalidSessionUrl(url).maximumSessions(1)
.expiredUrl(url)
.maxSessionsPreventsLogin(false)
.and()
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
//dalej login, logout custom handlers etc.
.successHandler(sessionLifecycleHandler()).
To zrobiłem swojego beana w tym stylu:
public class SessionLifecycleHandler extends SimpleUrlAuthenticationSuccessHandler {
public final Integer SESSION_TIMEOUT_IN_SECONDS = 60 * 60;
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
request.getSession().setMaxInactiveInterval(SESSION_TIMEOUT_IN_SECONDS);
}
}
Chciałbym tez ustawić redirecta na expired session na login, to chyba tez ten session management powinien pozwolic.
Ale coś nie chce to zadziałać.
Za wszelką pomoc bardzo dziękuję.