我正在尝试将FOSUserBundle合并到具有admin身份验证系统的现有项目中,并且我正在为用户使用FOSUserBundle,但出现防火墙错误!
我正在使用以下网址:http://localhost/myproject/web/app_dev.php/fr/user/login
和错误:
InvalidConfigurationException in BaseNode.php line 313:
Invalid configuration for path "security.firewalls.Fos_secured_area": The check_path "/login_check" for login method "form_login" is not matched by the firewall pattern "^/(fr|en)/user/.*".
这是我的安全性。yml
admin:
entity: { class: AppBundle:Admin}
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
Fos_secured_area:
pattern: ^/(%app_locales%)/User/.*
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
admin_secured_area:
pattern: ^/(%app_locales%)/admin/.*
anonymous: true
provider: admin
form_login:
check_path: security_admin_login
login_path: security_admin_login
csrf_token_generator: security.csrf.token_manager
default_target_path: admin_page
logout:
path: admin_logout
target: homepage
access_control:
- { path: ^/(%app_locales%)/User/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(%app_locales%)/User/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(%app_locales%)/User/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
我的routing.yml
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
app:
resource: '@AppBundle/Controller/'
type: annotation
prefix: /{_locale}
requirements:
_locale: '%app_locales%'
defaults:
_locale: '%locale%'
答案 0 :(得分:0)
尝试更改
pattern: ^/(%app_locales%)/User/.*
到
pattern: ^/
我认为您的情况无需这种模式
简短说明: 该模式是一个正则表达式,它确定哪种防火墙规则将应用于什么路由。
Fosuserbundle使用类似于/ login_check的路由来进行登录操作的回调。而且由于它与您的模式不匹配,因此Fos_secured_area规则将不适用于该路线。