FOSUserBundle and remember me

前端 未结 4 1145
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 00:43

I\'m using a FOSUserBundle for authentication in Symfony2. Everything works fine except \"remember me\". My security.yml looks like this:

security:
providers:
           


        
4条回答
  •  北海茫月
    2021-02-06 01:28

    This was not working for me neither because i used 2 user providers: FOSUserBundle and FosFacebook.

    The cookie was actually being set, but in TokenBasedRememberMeServices, processAutoLoginCookie i saw that the wrong provider was being used.

    To fix it i had to specify in security.yml in remember_me section the provider i wanted to use.

    firewalls:
        main:
            ...
            remember_me:
                secret:      "%secret%"
                lifetime: 2592000
                path:     /
                domain:   ~
                user_provider: fos_userbundle
    

    Maybe this helps somebody else too.

    Update: I've modified the response since in newer versions of Symfony, the "key" under remember_me is now called "secret".

提交回复
热议问题