2013-08-06 46 views
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回退到下一个适配器?

回答

0

问题这里https://github.com/SocalNick/ScnSocialAuth/issues/123

对我来说,固定的我只是我跟着matwright(GitHub的)响应(见https://github.com/matwright/ScnSocialAuth),所以我代替两个文件:

  1. socalnick/src目录/ ScnSocialAuth /控制器/插件/ ScnSocialAuthProvider .PHP通过ScnSocialAuthProvider.php
  2. socalnick/SRC/ScnSocialAuth /控制器/ UserController.php通过UserController.php

而且在zfcuser.global.php中:

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

希望对你有所帮助...

相关问题