How to enable session and set session timeout in Spring Security

后端 未结 5 2203
轮回少年
轮回少年 2020-12-14 00:53

I am new to Spring Security and I am working on a login, logout, and session timeout feature. I have configured my code by referring to this document. My code looks below:

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 01:27

    I handled it inside subclass of UsernamePasswordAuthenticationFilter You can get username by -

    obtainUsername(request);
    

    and apply user checks and set time out accordingly, like-

    if(username.equalsIgnoreCase("komal-singh-sisodiya@xyz.com")) 
            {
            logger.debug("setting timeout 15 min");
            request.getSession(false).setMaxInactiveInterval(15*60);
            }
    

提交回复
热议问题