1

我正在尝试设置 ZfcUser 以通过回退到 LDAP 进行身份验证。我的 zfcuser.global.php 包含:

'auth_adapters' => array( 
    100 => 'ZfcUser\Authentication\Adapter\Db', 
    99 => 'ZfcUser\Authentication\Adapter\Ldap', 
),

我使用以下设置创建了一个 Ldap.php 作为 AbstractAdapter。为简洁起见,我删除了功能代码:

namespace ZfcUser\Authentication\Adapter;

use DateTime;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\Session\Container as SessionContainer;
use ZfcUser\Authentication\Adapter\AdapterChainEvent as AuthEvent;
use ZfcUser\Mapper\User as UserMapperInterface;
use ZfcUser\Options\AuthenticationOptionsInterface;


class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface
{
    protected $mapper;
    protected $serviceManager;
    protected $options;

    public function authenticate(AuthEvent $e)
    {
        ...
    }

    public function getMapper()
    {
        ...
    }

    public function setMapper(UserMapperInterface $mapper)
    {
        ...
    }

    public function getServiceManager()
    {
        return $this->serviceManager;
    }

    public function setServiceManager(ServiceManager $serviceManager)
    {
        $this->serviceManager = $serviceManager;
    }

    public function setOptions(AuthenticationOptionsInterface $options)
    {
        $this->options = $options;
    }

    public function getOptions()
    {
        ...
    }  

}

我还将它作为可调用的模块包含在 Module.php 文件中:

public function getServiceConfig()
{
    return array(
        'invokables' => array(
            'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Authentication\Adapter\Db',
            'ZfcUser\Authentication\Adapter\Ldap' => 'ZfcUser\Authentication\Adapter\Ldap',
            ...
        ),
        ...
 }

如果我翻转优先级值,它会改变谁可以登录。首先执行的适配器允许登录,但另一个适配器永远不会被使用。如果第一个适配器失败,任何人都知道如何让 ZfcUser 回退到下一个适配器?

4

1 回答 1

0

此处修复的问题https://github.com/SocalNick/ScnSocialAuth/issues/123

对我来说,我只是跟着 matwright(github) 响应(参见https://github.com/matwright/ScnSocialAuth)所以我替换了两个文件:

  1. socalnick/src/ScnSocialAuth/Controller/Plugin/ScnSocialAuthProvider.php by ScnSocialAuthProvider.php
  2. socalnick/src/ScnSocialAuth/Controller/UserController.php by UserController.php

在 zfcuser.global.php 中:

'auth_adapters' => array( 100 => 'ZfcUser\Authentication\Adapter\Db', ),

希望这有助于...

于 2014-01-10T10:22:14.110 回答