访问控制无法正常使用symfony 2.8

时间:2017-03-30 21:46:39

标签: symfony

我的访问控制有问题,即使我没有登录,我也可以访问某些路径/ Acceuil !! 这通常是security.yml中的问题 的 security.yml

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
         ROLE_ADMIN:       [ROLE_ADMIN ,ROLE_USER]
        ROLE_SUPER_ADMIN: ROLE_ADMIN


    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email


    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            pattern: ^/
            form_login:
                check_path: fos_user_security_check
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager
                default_target_path: /acceuil
            # if you are using Symfony < 2.8, use the following config instead:
                 # csrf_provider: form.csrf_provider

            logout:      
                target: /login
            anonymous:    true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register/etudiant, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register/entreprise, role: IS_AUTHENTICATED_ANONYMOUSLY     }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }
        - { path: ^/acceuil/, role: ROLE_USER }
        - { path: ^/gestion/, role: ROLE_ADMIN }
你可以帮我吗?

0 个答案:

没有答案