Symfony2使用多个防火墙避免security.yml中的重复/重复属性
在我的应用程序中,security.yml中有两个防火墙(下面提供的示例)。正如您所看到的,“管理员安全区域”和“帐户安全区域”防火墙具有非常相似的属性,只是偶尔有所不同。我想知道是否有一种方法可以避免公共属性输入两次。例如,我可以从基本(父)防火墙继承属性吗?或者我可以从单个位置导入所需的属性吗?或者其他选择Symfony2使用多个防火墙避免security.yml中的重复/重复属性,symfony,yaml,Symfony,Yaml,在我的应用程序中,security.yml中有两个防火墙(下面提供的示例)。正如您所看到的,“管理员安全区域”和“帐户安全区域”防火墙具有非常相似的属性,只是偶尔有所不同。我想知道是否有一种方法可以避免公共属性输入两次。例如,我可以从基本(父)防火墙继承属性吗?或者我可以从单个位置导入所需的属性吗?或者其他选择 security: firewalls: admin_secured_area: stateless: true
security:
firewalls:
admin_secured_area:
stateless: true
lexik_jwt:
authorization_header:
enabled: false
query_parameter:
enabled: true
name: lexiktoken
throw_exceptions: true
create_entry_point: true
entry_point: foobar.authentication_handler
provider: in_memory
pattern: ^/admin
form_login:
username_parameter: username
password_parameter: password
require_previous_session: false
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
check_path: /admin/login
logout:
path: /admin/logout
success_handler: foobar.authentication_handler
account_secured_area:
stateless: true
lexik_jwt:
authorization_header:
enabled: false
query_parameter:
enabled: true
name: lexiktoken
throw_exceptions: true
create_entry_point: true
entry_point: foobar.authentication_handler
provider: user_db
pattern: ^(/account)|(/reset-password)
form_login:
username_parameter: username
password_parameter: password
require_previous_session: false
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
check_path: /account/login
logout:
path: /account/logout
success_handler: foobar.authentication_handler
应该可以使用参数。有关配置键“lexik_jwt”,请参见我的示例
感谢您的回复@sebbo,我将实施您的建议。理想情况下,我正在寻找一个解决方案,在这个解决方案中,我可以定义所有“基本”参数,然后针对每个防火墙,只覆盖一些属性。(与Zend Framework 1中的.ini文件类似)@Sam看看这里,我想这就是你想要的:
security:
parameters:
lexik_jwt_settings:
authorization_header:
enabled: false
query_parameter:
enabled: true
name: lexiktoken
throw_exceptions: true
create_entry_point: true
firewalls:
admin_secured_area:
stateless: true
lexik_jwt: %lexik_jwt_settings%
entry_point: foobar.authentication_handler
provider: in_memory
pattern: ^/admin
form_login:
username_parameter: username
password_parameter: password
require_previous_session: false
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
check_path: /admin/login
logout:
path: /admin/logout
success_handler: foobar.authentication_handler
account_secured_area:
stateless: true
lexik_jwt: %lexik_jwt_settings%
entry_point: foobar.authentication_handler
provider: user_db
pattern: ^(/account)|(/reset-password)
form_login:
username_parameter: username
password_parameter: password
require_previous_session: false
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
check_path: /account/login
logout:
path: /account/logout
success_handler: foobar.authentication_handler