我在Spring MVC中使用RememberMe服务。它以前是有效的,但现在不是了。它会创建一个Cookie,但当重新启动浏览器时,该cookie将自动删除。我用3-4台机器进行了测试,这不是浏览器的问题。这可能是一些配置问题。我们在Spring Security中使用基于令牌的rememberMe服务,配置如下。
<bean id="shoTokenBasedRememberMeServices" class="com.sho.web.security.ShoTokenBasedRememberMeServices">
<constructor-arg ref="shoUserDetailsService"/>
</bean>我错过了什么吗?
发布于 2012-12-21 10:51:50
我经历了这个特殊的问题。我通过向我的身份验证管理器添加一个RememberMeAuthenticationProvider来解决这个问题。
<beans:bean id="rememberMeAuthenticationProvider"
class="org.springframework.security.authentication.RememberMeAuthenticationProvider">
...
</beans:bean>
<authentication-manager alias="authMgr">
...
<authentication-provider ref="rememberMeAuthenticationProvider">
</authentication-provider>
</authentication-manager>因此,我的身份验证管理器最终使用了两个身份验证提供者:
<authentication-manager alias="authMgr">
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder hash="sha">
<salt-source user-property="username" />
</password-encoder>
</authentication-provider>
<authentication-provider ref="rememberMeAuthenticationProvider">
</authentication-provider>
</authentication-manager>这篇文章说“在你的AuthenticationManager中包含RememberMeAuthenticationProvider”:http://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html
https://stackoverflow.com/questions/13310035
复制相似问题