我的symfony2安全配置有问题。我需要两个防火墙用于两个不同的用户实体。一个用于管理员用户区,一个用于客户端用户。 问题是它显示登录表单,当我浏览到/ admin / cabinet时,我可以成功登录管理员 但是当我去/ client / cabinet时,它不会显示登录表单,只是在控制器中运行操作。 这是我的security.yml文件:
security:
encoders:
Test\TestBundle\Entity\Client: pbkdf2
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
admin:
memory:
users:
admin: { password: password, roles: [ 'ROLE_ADMIN' ] }
clients:
entity: { class: TestTestBundleBundle:Client, property: login }
firewalls:
admin_firewall:
pattern: ^/admin
anonymous: ~
provider: admin
form_login:
login_path: /admin/login
check_path: /admin/login_check
username_parameter: login
password_parameter: password
default_target_path: /admin/cabinet
logout:
intention: logout
path: /admin/logout
target: /
success_handler: ~
invalidate_session: true
firewalls:
client_firewall:
pattern: ^/client
anonymous: ~
provider: clients
form_login:
login_path: /client/login
check_path: /client/login_check
username_parameter: login
password_parameter: password
default_target_path: /client/cabinet
logout:
intention: logout
path: /client/logout
target: /
success_handler: ~
invalidate_session: true
access_control:
- { path: ^/admin/cabinet, roles: ROLE_ADMIN }
- { path: ^/client/cabinet, roles: ROLE_USER }
- { path: ^/client/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/client/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }