당신은 당신이 또는 저장소 (LDAP 등) 원래 어댑터를 다시 사용할 수 있습니다, 이러한 클래스에서 Zend_Auth_Adpater_Interface 및 Zend_Auth_Storage_Interface
를 구현하는, 자신의 어댑터/저장 클래스를 생성하고 만 인증을 구현하는 코드를 작성할 수 있습니다 규칙. Zend_Auth_Adapter에 대한 여러 소스를 사용하여 예를 들어
는 :
<?php
class My_Auth_Adapter implements Zend_Auth_Adapter_Interface
{
private $ldapAdapter;
private $cookieAdapter;
private $apiKeyAdapter;
public function __construct($ldapAdapter, $cookieAdapter, $apiKeyAdapter) {
{
$this->ldapAdapter = $ldapAdapter;
$this->cookieAdapter = $cookieAdapter;
$this->apyKeyAdapter = $apiKeyAdapter;
}
public function authenticate()
{
if ($this->ldapAdapter->authenticate()) {
//return the Zend_Auth_Restult
} elseif ($this->cookieAdapter->authenticate() {
//return the result
} elseif ($this->apiKeyAdapter->authenticate() {
//return the result
} else {
//Create and return a Zend_Auth_Result which prevents logging in
}
}
}
나는 당신의 로그인 규칙을 이해 확실하지 오전하지만 개념은 스토리지 클래스에 대한 동일하게 유지 :
<?php
class My_Auth_Storage implements Zend_Auth_Storage_Interface
private $sessionStorage;
private $cookieStorage;
private $apiStorage;
public function read()
{
if (!$this->sessionStorage->isEmpty())
{
return $this->sessionStorage->read();
} elseif (!$this->cookieStorage->isEmpty())
{
return $this->cookieStorage->read();
} //And so one, do not forget to implement all the interface's methods
으로 이 구현을 사용하면 여러 자격 증명 소스와 여러 세션 저장 엔진 (쿠키, 세션, db 또는 사용하려는 모든 것)을 가질 수 있습니다.
acl 문제 때문에 컨트롤러 플러그인에서 LDAP 그룹을 가져 와서 인증 후에 필요에 따라 저장할 수 있습니다. 그런 다음 각 요청에서 ACL을 검사하는 두 번째 플러그인을 사용할 수 있습니다.