Zend framework2 如何使用回退设置多个身份验证适配器
我正在尝试设置ZfcUser,以便通过LDAP回退进行身份验证。我的zfcuser.global.php包含:Zend framework2 如何使用回退设置多个身份验证适配器,zend-framework2,zfcuser,Zend Framework2,Zfcuser,我正在尝试设置ZfcUser,以便通过LDAP回退进行身份验证。我的zfcuser.global.php包含: 'auth_adapters' => array( 100 => 'ZfcUser\Authentication\Adapter\Db', 99 => 'ZfcUser\Authentication\Adapter\Ldap', ), 我使用以下设置创建了一个Ldap.php作为抽象适配器。为了简洁起见,我删除了函数代码: namespace
'auth_adapters' => array(
100 => 'ZfcUser\Authentication\Adapter\Db',
99 => 'ZfcUser\Authentication\Adapter\Ldap',
),
我使用以下设置创建了一个Ldap.php作为抽象适配器。为了简洁起见,我删除了函数代码:
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返回到下一个适配器吗?问题已在此处修复
对我来说,我只是遵循matwright(github)的响应(请参阅),所以我替换了两个文件:
“身份验证适配器”=>数组(
100=>ZfcUser\Authentication\Adapter\Db',
),
希望这有助于