首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于持久化的Remember-Me for Regular Login in Spring Social示例

基于持久化的Remember-Me for Regular Login in Spring Social示例
EN

Stack Overflow用户
提问于 2013-05-31 17:35:33
回答 1查看 941关注 0票数 0

所以我想在Spring Social Showcase-Sec-XML示例中添加一个记住我的特性。所以我想让它成为一个基于持久化的记住我,然而,每当我将数据源添加到记住我时,我就会得到一个错误。

这是我在security.xml中的代码

代码语言:javascript
复制
<http use-expressions="true">
    <!-- Authentication policy -->
    <form-login login-page="/signin" login-processing-url="/signin/authenticate" authentication-failure-url="/signin?param.error=bad_credentials" />
    <logout logout-url="/signout" delete-cookies="JSESSIONID" />
    <intercept-url pattern="/favicon.ico" access="permitAll" />
    <intercept-url pattern="/resources/**" access="permitAll" />
    <intercept-url pattern="/auth/**" access="permitAll" />
    <intercept-url pattern="/signin/**" access="permitAll" />
    <intercept-url pattern="/signup/**" access="permitAll" />
    <intercept-url pattern="/disconnect/facebook" access="permitAll" />
    <intercept-url pattern="/**" access="isAuthenticated()"  />
    <remember-me key="jbcpCalendar"
                data-source-ref="dataSource"/>

    <!--  Spring Social Security authentication filter -->
    <custom-filter ref="socialAuthenticationFilter" before="PRE_AUTH_FILTER" />
</http>

这是给出错误的socialAuthenticationFilter bean。

代码语言:javascript
复制
<bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter"
    c:_0-ref="authenticationManager"
    c:_1-ref="userIdSource"
    c:_2-ref="usersConnectionRepository"
    c:_3-ref="connectionFactoryLocator"
    p:signupUrl="/spring-social-showcase/signup"
    p:rememberMeServices-ref="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0" /> <!-- TODO: Figure out how to wire this without this name -->

这是产生的堆栈跟踪):

代码语言:javascript
复制
Cannot resolve reference to bean 'socialAuthenticationFilter' while setting 
constructor argument with key [2]; nested exception is 
org.springframework.beans.factory.BeanCreationException: 

Error creating bean with name 'socialAuthenticationFilter' 
defined in ServletContext resource [/WEB-INF/spring/social-security.xml]: Cannot 
resolve reference to bean 
'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0'
while setting bean property 'rememberMeServices'; nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No bean named   
'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0' is defined

有没有办法让它使用持久化的基础上记住我时,它的常规登录?

EN

回答 1

Stack Overflow用户

发布于 2013-06-04 03:25:10

我认为您必须在配置的名称空间中添加别名,记住:

代码语言:javascript
复制
<remember-me services-alias="toto"
             key="jbcpCalendar"
             data-source-ref="dataSource"/>

并在socialAuthenticationFilter配置中使用别名引用它:

代码语言:javascript
复制
<bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter"
    c:_0-ref="authenticationManager"
    c:_1-ref="userIdSource"
    c:_2-ref="usersConnectionRepository"
    c:_3-ref="connectionFactoryLocator"
    p:signupUrl="/spring-social-showcase/signup"
    p:rememberMeServices-ref="toto" />
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16854227

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档