除了一些网址,我需要拒绝匿名连接。
firewalls:
install:
pattern: ^/install/.*
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: /login
check_path: /login_check
use_forward: true
always_use_default_target_path: true
default_target_path: /
post_only: true
logout: true
anonymous: ~
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login_check, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/install/, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/*, roles: ROLE_USER }
这听起来像“ - {path:^ / *,roles:ROLE_USER}”这一行,但覆盖我的防火墙“安装”,因为它们共享相同的根(模式/)。
我该怎么办?
答案 0 :(得分:1)
一种快捷方法是从/install
防火墙中排除main
路径:
firewalls:
install:
pattern: ^/install/.*
security: false
main:
pattern: ^/(?!install/)
...