有时,一个防火墙有多种认证方式[就会有多个 authenticator](例如,既有表单登录[form_login],又有API令牌认证[json_login])。在这些情况下, 现在需要配置认证入口点。该入口点用于在用户尚未认证但试图访问需要认证的页面时生成一个 响应。例如,这可以用来将用户重定向到登录页面。
比如:
# config/packages/security.yaml
security:
enable_authenticator_manager: true
# ...
firewalls:
main:
# allow authentication using a form or HTTP basic
form_login: ~
http_basic: ~
# configure the form authentication as the entry point for unauthenticated users
entry_point: form_login
可以将某个授权方式配置为false,那么这个授权方式即为不可用,如: form_login: false
