我是 Symfony2 的新手。我阅读了文档并看到了登录表单的一些配置 http://symfony.com/doc/current/cookbook/security/form_login_setup.html
# app/config/security.yml
security:
# ...
firewalls:
default:
anonymous: ~
http_basic: ~
form_login:
login_path: /login
check_path: /login_check
我不明白为什么在同一个防火墙中有 2 个安全方法 http_basic 和 form_login?安全系统将使用哪种方法? http_basic 或 form_login 或两者兼而有之?它是多余的吗? 上面的一些问题看起来很愚蠢,但 symfony2 安全组件文档似乎很差。
最佳答案
在旧的 Symfony
文档中有一个小提示:
When the user is not authenticated and if there is more than one authentication mechanisms, Symfony2 automatically defines a default entry point (in the example above, the login form; but if the user send an Authorization HTTP header with wrong credentials, Symfony2 will use the HTTP basic entry point).
但在下一个版本中,当文档被重新组织时,它被减少了,我不知道为什么。
所以我开了一个new issue在 GitHub
上的 symfony-docs
存储库中,建议恢复提示。
引自 @WouterJ的回答:
The code seems to no longer work as described in the quoted paragraph. It seems to always use form login, except when there is no Authentication header sent and the HTTP basic credentials are correct.
所以你是对的——这根本不是微不足道的。想知道结论就关注issue。
关于php - 同一防火墙中的Symfony2认证方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28402123/