Symfony2安全令牌存储正在破坏我的项目

时间:2015-09-24 17:02:08

标签: security symfony

获得此安全配置:

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_provider: security.csrf.token_manager
            use_referer:  true
            require_previous_session: true
        logout:
            path:   /logout
            success_handler: authentication_handler
        anonymous:    true
        remember_me:
            key:      "%secret%"
            lifetime: 31536000
            path:     /
            domain:   "%domain%"
            name:     "REMEMEMBERME"

当我要在生产环境中打开我的项目时,它会崩溃。

[2015-09-24 18:53:26] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException: "The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL." at
[2015-09-24 18:53:26] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException: "The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL." at
[2015-09-24 18:53:26] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException: "The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL." at
[2015-09-24 18:53:26] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException: "The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL." at

它传递给项目的所有路线。

其他信息

当资产显示图像时,我只能看到中断。也就是说,在视图中没有包含图像不会被破坏,如果它破裂了。

更多信息

这是导致错误的函数:

$this->get('security.authorization_checker')->isGranted('ROLE_USER')

如果我评论该功能,该项目工作正常。

1 个答案:

答案 0 :(得分:0)

您必须为您的网址配置防火墙。

一些例子:

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