springsecurity session并发问题

首先,先介绍一下登录互顶流程。

假设a账户在1处登录成功,此时,springsecurity将sessionId和用户信息封装成sessionInfomation保存到 SessionRegistry对象中,

然后a账户又在2处登录,此时会从sessionRegistry对象中获取所有sessionInfomation,并判断有没有与当前用户名一样的sessionInfomation,若有,就会根据sessionId使得在1处登录的session过期,然后a账户在1随便点击一个操作,过滤器验证session是否过期,显示登录过期,然后重定向到登录页。

手机端出现的问题在于:session过期后要求返回给手机端是一个json数据,而我们目前返回的是登录页面

修正:判断请求是否来自手机端,若是则返回json数据。

springSecurity并发控制步骤

1.

To use concurrent session support, you’ll need to add the following to web.xml:

<listener>
	<listener-class>
	org.springframework.security.web.session.HttpSessionEventPublisher
	</listener-class>
</listener>

2.In addition, you will need to add the ConcurrentSessionFilter to your FilterChainProxy. The ConcurrentSessionFilter requires two properties, sessionRegistry, which generally points to an instance of SessionRegistryImpl, and expiredUrl, which points to the page to display when a session has expired

猜你喜欢

转载自blog.csdn.net/qq_34886599/article/details/81087496