php - 同一防火墙中的Symfony2认证方式

标签 php symfony symfony-security

我是 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 issueGitHub 上的 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/

相关文章:

php - Doctrine 如何在使用 addSelect 查询时在一行中获得结果

symfony - 如何检查用户是否在 Controller 内登录 Symfony2?

Symfony Forms - 如何更改 CollectionTypes 项目标签

php - 如果属性具有空字符串值,如何使 Doctrine 拒绝实体?

php - 保护 symfony 3 中登录系统的安全

php - Symfony 3 通过手机阵列登录

php - 与默认的 Ubuntu 构建相比,为什么重新编译的 PHP 使用大量 CPU?

php - 使用 PHP 从 JSON 中获取值

php - 为什么我收到 Swift_TransportException : Unable to connect with TLS encryption in Server?

php - 显示具体编号每页行数?