Session Spring安全并发会话未按预期工作
它不是限制每个用户一个会话,而是限制每个用户一个会话 整个应用程序 因此,如果一个用户登录,没有人可以登录 这是我的配置Session Spring安全并发会话未按预期工作,session,spring-security,Session,Spring Security,它不是限制每个用户一个会话,而是限制每个用户一个会话 整个应用程序 因此,如果一个用户登录,没有人可以登录 这是我的配置 <session-management invalid-session-url="/login"> <concurrency-control error-if-maximum-exceeded="true" max-sessions="1" /> </session-management> 我甚至在web
<session-management invalid-session-url="/login">
<concurrency-control error-if-maximum-exceeded="true" max-sessions="1" />
</session-management>
我甚至在web.xml中添加了监听器
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- HTTP security configurations -->
<http auto-config="true" use-expressions="true">
<form-login login-processing-url="/resources/j_spring_security_check"
login-page="/login" default-target-url="/index"
authentication-success-handler-ref="myAuthenticationSuccessHandler"
authentication-failure-url="/login?login_error=t" />
<logout invalidate-session="true"
logout-url="/resources/j_spring_security_logout" success-handler-ref="myLogoutSuccessHandler"/>
<!-- Configure these elements to secure URIs in your application -->
<intercept-url pattern="/choices/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/member/**" access="isAuthenticated()" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/**" access="permitAll" />
<session-management invalid-session-url="/login">
<concurrency-control error-if-maximum-exceeded="true"
max-sessions="1" />
</session-management>
</http>
<!-- Configure Authentication mechanism -->
<authentication-manager alias="authenticationManager">
<authentication-provider ref="customDaoAuthenticationProvider">
</authentication-provider>
</authentication-manager>
<beans:bean id="myAuthenticationSuccessHandler" class="com.test.connect.web.login.MyAuthenticationSuccessHandler"/>
<beans:bean id="myLogoutSuccessHandler" class="com.test.connect.web.login.MyLogoutSuccessHandler"/>
</beans:beans>
根据您提供的配置,其中包括自定义AuthenticationProvider,以及您遇到的问题,我猜您返回的自定义UserDetails实现没有正确实现equals和hashCode方法
请确保在任何自定义UserDetails实现上正确实现了equals和hashCode,因为这些方法用于查找用户是否包含活动会话。只需在此处突出显示,请确保equals和hashCode方法返回的值为true。如果这些方法未返回true,则不会终止或终止现有会话。如何测试?不是来自同一个浏览器,我希望?@AleksandrM Ya当然来自不同浏览器显示您的完整spring安全配置。@AleksandrM Hi我没有使用任何自定义Userdetails实现。我在RetrieveUser方法中返回以下org.springframework.security.core.Userdetails.Userdetails。您确定customDaoAuthenticationProvider正在返回吗那么独特的用户呢?如果它意外返回具有相同用户名的用户对象,则会导致类似问题。如果这没有帮助,请尝试启用调试日志记录,并为第一次和第二次登录附加日志。根据日志,一切正常。唯一的问题是我的浏览器。有时IE7在成功登录后没有重定向。