简体   繁体   English

Symfony2在同一防火墙中的身份验证方法

[英]Symfony2 authentication method in the same firewall

I'm new to Symfony2. 我是Symfony2的新手。 I read documentation and saw some config for login form http://symfony.com/doc/current/cookbook/security/form_login_setup.html 我阅读了文档并看到了登录表单的一些配置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

I dont understand why there are 2 security methods http_basic and form_login in the same firewall? 我不明白为什么在同一个防火墙中有2个安全方法http_basic和form_login? Which method security system will use? 安全系统将使用哪种方法? http_basic or form_login or both? http_basic或form_login或两者兼而有之? Is it redundant? 这是多余的吗? Some questions above seem stupid but It seems symfony2 security component documentation so poor. 上面的一些问题似乎很愚蠢,但似乎symfony2安全组件文档很差。

In old Symfony documentation there was a small tip: 在旧的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). 当用户未经过身份验证并且有多个身份验证机制时,Symfony2会自动定义默认入口点(在上面的示例中为登录表单;但如果用户发送带有错误凭据的Authorization HTTP标头,Symfony2将使用HTTP基本入口点)。

But in next versions when documentation were reorganized it was reduced and I don't know why. 但是在下一个版本中,当文档被重新组织时,它被减少了,我不知道为什么。

So I opened a new issue in symfony-docs repository on GitHub with the proposal to restore the tip. 所以我在GitHub上的symfony-docs存储库中打开了一个新问题 ,提出了恢复提示的建议。

The quote from @WouterJ 's answer: 引自@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. 它似乎始终使用表单登录,除非没有发送身份验证标头并且HTTP基本凭据正确。

So you were right — it's not trivial at all. 所以你是对的 - 这根本不是微不足道的。 Just follow the issue if you want to know the conclusion. 如果您想知道结论,请关注此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM