Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java EE (J2EE) и Spring > Spring Security не работает remember me


Автор: MblR 21.10.2013, 15:03
Здравствуйте. Необходимо добавить remembe me, но оно не работает, вообще
вот мой конфиг
Код

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:security="http://www.springframework.org/schema/security"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:beans="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans [URL=http://www.springframework.org/schema/beans/spring-beans-3.1.xsd]http://www.springframework.org/schema/bean...g-beans-3.1.xsd[/URL]
          [URL=http://www.springframework.org/schema/security]http://www.springframework.org/schema/security[/URL] [URL=http://www.springframework.org/schema/security/spring-security-3.1.xsd]http://www.springframework.org/schema/secu...ecurity-3.1.xsd[/URL] [URL=http://www.springframework.org/schema/jdbc]http://www.springframework.org/schema/jdbc[/URL] [URL=http://www.springframework.org/schema/jdbc/spring-jdbc.xsd&quot;&gt;]http://www.springframework.org/schema/jdbc...p;quot;>[/URL]

    <security:global-method-security secured-annotations="enabled"/>

    <bean id="passwordEncoder"
          class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>

    <security:http auto-config="false" authentication-manager-ref="myAuthenticationManager"
                   use-expressions="true"
                   entry-point-ref="authenticationEntryPoint" >

        <security:intercept-url pattern="/login" access="permitAll" />
        <security:intercept-url pattern="/css/**" access="permitAll"/>
        <security:intercept-url pattern="/js/**" access="permitAll"/>
        <security:intercept-url pattern="/img/**" access="permitAll"/>

        <security:intercept-url pattern="/regions" access="hasRole('ROLE_USER')"/>
        <security:intercept-url pattern="/scriptList/**" access="hasRole('ROLE_USER')"/>
        <security:intercept-url pattern="/show/**" access="hasRole('ROLE_USER')"/>
        <security:intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')"/>

        <security:remember-me key="sau" services-ref="rememberMeServices" />

         <security:intercept-url pattern="/**" access="isAuthenticated()"/>
        <security:logout logout-success-url="/login" invalidate-session="true" logout-url="/logout" />

        <security:logout logout-url="/logout"
                         invalidate-session="true"
                         success-handler-ref="logoutHandler"
                         delete-cookies="JSESSIONID"/>
    </security:http>

   <beans:bean id="authenticationEntryPoint"
          class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
        <property name="loginFormUrl" value="/login"/>
        <beans:property name="useForward" value="true"/>
    </beans:bean>
  <bean id="logoutHandler" class=""ru.lat.sau.handler.LogoutHandler"/>

    <bean id="myAuthenticationProvider" class="ru.lat.sau.manager.UserManager"/>

    <security:authentication-manager id="myAuthenticationManager" >
        <security:authentication-provider ref="myAuthenticationProvider"/>
    </security:authentication-manager>

   <bean id="rememberMeServices"
          class="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
        <property name="userDetailsService" ref="myAuthenticationProvider"/>
        <property name="key" value="springRocks"/>
    </bean>

</beans>


Подскажите, пожалуйста, что не так. Заранее спасибо всем за участие

Автор: MisterCleric 22.10.2013, 15:30
Привет.

К сожалению, я никогда не работал с remember me и не знаю какие там могут быть проблемы.
Попробуй покопать в документации: http://docs.spring.io/spring-security/site/docs/3.1.4.RELEASE/reference/remember-me.html
Посмотреть пример: https://github.com/spring-projects/spring-security/blob/f34b459c80e8d083cbe53586ccceb80c568011e1/itest/web/src/main/webapp/WEB-INF/http-security.xml
Или в крайнем случае задай вопроса на форуме Spring: http://forum.spring.io/forum/spring-projects/security

Автор: MblR 23.10.2013, 15:04
ок, поищу еще инфу. спасибо за отклик

Автор: d_k 24.10.2013, 15:42
_spring_security_remember_me при логине устанавливаешь в true?

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)