Symfony2:在SecurityContext中找不到令牌

时间:2013-11-18 14:35:29

标签: authentication symfony

应允许匿名连接到URL的防火墙需要进行身份验证。例如,/reports/foodbank/2013/10应该只提供一组值而不是需要登录。语法错误?

security.yml包括:

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    foodbank:
      pattern: ^/reports/foodbank/~
      anonymous: ~

    login_firewall:
        pattern:    ^/login$
        anonymous:  ~

    secured_area:
        pattern:    ^/
        form_login:
          default_target_path: /home
          use_referer: true

        logout:
          target: /login

access_control:
    - { path: ^/reports/foodbank/~, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, roles: ROLE_USER }

1 个答案:

答案 0 :(得分:0)

回访文档显示路径是正则表达式,我(不幸的是)只是模糊地熟悉。但是以下修改使其有效:

foodbank:   模式:^ / reports / foodbank / *   匿名:〜

ACCESS_CONTROL:      - {路径:^ / reports / foodbank / *,角色:IS_AUTHENTICATED_ANONYMOUSLY}