Jon*_*ram 4 basic-authentication http-digest symfony
我正在使用FOSUserBundle配置Symfony2应用程序以使用http_digest身份验证.这是Symfony 2.1.0-BETA2.
在security.yml,我简单地切换出来http_basic了http_digest,并添加所需的key属性.其他一切都是一样的.
有效的相关配置:
firewalls:
main:
pattern: ^/
anonymous: ~
form_login: false
provider: fos_user_bundle
http_basic:
realm: "Example Realm"
Run Code Online (Sandbox Code Playgroud)
相关配置不起作用:
firewalls:
main:
pattern: ^/
anonymous: ~
form_login: false
provider: fos_user_bundle
http_digest:
realm: "Example Realm"
key: "%secret%"
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,唯一的区别是切换出来http_basic的http_digest.更改key属性的值似乎没有区别.
使用in_memory提供程序时,http_digest工作得很好.只有在使用fos_user_bundle提供商时才会出现此问题.
通过工作,我的意思是在使用时http_basic,接受有效的用户凭证.使用http_digest相同的有效用户时,不接受详细信息,并重新显示浏览器的默认http验证提示.
在安全配置更改之间,我清除dev和prod缓存,清空浏览器缓存并关闭浏览器.
配置中是否缺少一些关键的东西?
更新
我已经记录了一次成功的http_basic尝试和一次不成功的http_digest尝试,并将日志分开.
两个日志都是相同的,包括Doctrine记录用于身份验证的SQL查询的位置.
在http_digest日志中的身份验证查询之后是以下行:
security.DEBUG: Expected response: '3460e5c31b09d4e8872650838a0c0f1a' but received: '5debe5d0028f65ae292ffdea2616ac19'; is AuthenticationDao returning clear text passwords? [] []
security.INFO: exception 'Symfony\Component\Security\Core\Exception\BadCredentialsException' with message 'Incorrect response' in /home/jon/www/local.app.simplytestable.com/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php:105
Run Code Online (Sandbox Code Playgroud)
密码使用FOSUserBundle进行盐渍和散列.
我想确定这件事是由于我的错误配置还是因为它是FOSUserBundle中的错误而引起的.
简而言之,HTTP摘要式身份验证通过比较根据包括用户名,域,密码和各种nonse和重放避免值的值计算的哈希值来工作.
客户端和服务器端都需要明文密码才能生成相同的哈希值.
FOSUserBundle 盐和哈希密码.
在Symfony\Component\Security\Http\Firewall\DigestAuthenticationListener类中生成的服务器端哈希将传递散列而不是明文密码,因此永远不会生成正确的哈希值进行比较.