【问题标题】:Kerberos authentication with Symfony2Symfony2 的 Kerberos 身份验证
【发布时间】:2013-11-22 14:56:12
【问题描述】:

我正在尝试在 Symfony2 中使用 kerberos 对用户进行身份验证,但我有点迷路了。

当用户通过身份验证时,Apache 服务器返回$ _SERVER ['REMOTE_USER'] 变量,给我他的用户名。我可以恢复这个值:

$request = Request::createFromGlobals();
$user = $request->server->get('REMOTE_USER');

但是如何告诉 Symfony 只用这个值来验证用户呢?不需要密码。

我在创建custom authentication provider 还是创建custom use provider 之间犹豫不决。

请问最好的方法是什么?

【问题讨论】:

  • 自定义用户提供程序似乎不正确,因为该接口具有 getPassword() 和 getSalt() 方法。自定义身份验证提供程序似乎是正确的,您所要做的就是空虚地返回成功(因为身份验证是先验发生的)。类 KerberosTicket 扩展 AbstractToken 和类 KerberosClientProvider 实现 AuthenticationProviderInterface
  • 好的,谢谢主教,我试试这个方法。

标签: symfony kerberos


【解决方案1】:

为安全防火墙添加了基于 REMOTE_USER 的侦听器

几个 Apache 安全模块(auth_kerb、auth_cas 等)通过名为 REMOTE_USER 的环境变量提供用户名。因此,Symfony 2.6 将包含一个基于此变量的新身份验证侦听器。

要在您的应用程序中使用它,只需在您的安全配置中定义一个新的 remote_user 类型的防火墙:

# app/config/security.yml
security:
    firewalls:
        secured_area:
            pattern: ^/
            remote_user:
                provider: your_user_provider

来源:http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements

【讨论】:

    猜你喜欢
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 2017-06-28
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多