Symfony2 remember that I do not work with the fos user package

I am currently trying to implement the “remember me in Symfony2 project” function after this http://symfony.com/doc/master/cookbook/security/remember_me.html guide . (I am currently developing in the locale)

So my current configuration in security.yml is:

        form_login:
            [...]
            remember_me: true

        remember_me:
            key:      secretKey
            lifetime: 31536000 # 365 days in seconds
            path:     /
            domain:   localhost # Defaults to the current domain from $_SERVER

        access_control:
            - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/admin/login-check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/admin, role: [IS_AUTHENTICATED_REMEMBERED, ROLE_ADMIN] }

The cookie "REMEMBERME" is created at login and saved after closing the browser window. When I open the browser again, the cookie still exists, but it is deleted when I try to access the / admin path and then redirected to the login page.

Actually my head cannot be ... has anyone encountered such problems?

thank

+4
1

, access_control

,

: http://symfony.com/doc/current/book/security.html#securing-url-patterns-access-control

You can define as many URL patterns as you need - each is a regular expression. BUT, only one will be matched...

: http://symfony.com/doc/current/cookbook/security/access_control.html

" " FosUserBundle 1.3.5 ( Symfony 2.6) . (. , ...) .

'IS_AUTHENTICATED_FULLY' 'IS_AUTHENTICATED_REMEMBERED'.

:

{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
...
{% endif %}

security.yml Symfony Cookbook ( " " ). security.yml FossUserBundle Github.

# app/config/security.yml
security:
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout:       true
            anonymous:    true
            remember_me:
                key:      "%secret%"
                lifetime: 31536000 # 365 days in seconds
                path:     /
                domain:   ~ # Defaults to the current domain from $_SERVER
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

P.S : , IE11

+4

Source: https://habr.com/ru/post/1569549/


All Articles