Symfony 2-防火墙和访问控制问题 [英] Symfony 2 - firewall and access control issue

查看:76
本文介绍了Symfony 2-防火墙和访问控制问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用symfony 2安全组件时遇到了有线问题.由于{{ app.user }}对象仅在安全区域内可用,因此我将防火墙模式设置为^/.现在,我想取消抵押"某些页面,例如注册.我已经尝试过使用access_control,但是它不起作用.

I've got a wired problem with the symfony 2 security component. Due to the fact that the {{ app.user }} object is only available within the secured area, I set the firewall pattern to ^/. Now I want to "unsecured" some pages, like registration. I've tried this by using access_control but it doesn't work.

这是我的安全性.yml

Here is my security.yml

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

    login:
        pattern:  ^/account/login$
        security: false

    account_area:
        pattern:    ^/
        form_login:
            check_path: /account/login_check
            login_path: /account/login
            default_target_path: /account
        remember_me:
            key:      blaBlubKey
            lifetime: 3600
            path:     /
            domain:   ~
        logout:
            path:   /account/logout
            target: /

access_control:
    #works
    - { path: ^/backend, roles: ROLE_USER }
    #works not
    - { path: ^/registration, roles: IS_AUTHENTICATED_ANONYMOUSLY }

提前谢谢!

推荐答案

在account_area中使用任何匿名指令:

USe anynymous directive in account_area:

account_area:
        pattern:    ^/
        anonymous: ~

这篇关于Symfony 2-防火墙和访问控制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆