2013-08-06 77 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', ),

希望對你有所幫助...

相關問題