使用Symfony 3,我设置了多个防火墙。我遇到的问题是只有一个防火墙工作正常。当我设置新防火墙时,它总是会重定向到主页面。
以下是我的security.yml文件代码
# To get started with security, check out the documentation:
# https://symfony.com/doc/current/security.html
security:
encoders:
AppBundle\Entity\User:
algorithm: bcrypt
cost: 12
ClientBundle\Entity\SuperAdmin:
algorithm: bcrypt
cost: 12
providers:
user:
entity:
class: AppBundle:User
property: email
simplesaml:
id: my_user_provider
client:
entity:
class: ClientBundle:SuperAdmin
property: email
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
client_login:
pattern: ^/client/login$
security: false
user_login:
pattern: ^/user/login$
security: false
user_secured_area:
pattern: ^/user
anonymous: ~
provider: user
form_login:
login_path: /user/login
check_path: /user/login
use_referer: true
success_handler: app_user_security.login_success_handler
require_previous_session: false
remember_me:
secret: '%secret%'
lifetime: 604800
path: /user/login
always_remember_me: true
logout:
path: /user/logout
target: /user/login
client_secured_area:
pattern: ^/client
anonymous: ~
provider: client
form_login:
login_path: /client/login
check_path: /client/login
default_target_path: /client/logindss
remember_me:
secret: '%secret%'
lifetime: 604800
path: /client/
always_remember_me: true
logout:
path: /client/logout
target: /client/login
saml:
pattern: ^/saml
anonymous: true
stateless: true
simple_preauth:
authenticator: simplesamlphp.authenticator
provider: simplesaml
logout:
path: /logout
success_handler: simplesamlphp.logout_handler
access_control:
- { path: ^/client/, roles : IS_AUTHENTICATED_ANONYMOUSLY}
我为客户端登录创建了新的捆绑包,其他appbundle是普通用户登录我希望对不同页面进行2次单独登录访问。
请帮助
答案 0 :(得分:0)
根据official documentation,您是否尝试在登录表单上使用_target_path
?
<form action="{{ path('login') }}" method="post">
{# ... #}
<input type="hidden" name="_target_path" value="{{ path('account') }}" />
<input type="submit" name="login" />
</form>