Zend_Auth_Adpater_Interface と Zend_Auth_Storage_Interface を実装して、独自のアダプター/ストレージ クラスを作成できます。
これらのクラスでは、元のアダプター (LDAP など) またはストレージを再利用でき、認証ルールを実装するコードのみを記述できます。
たとえば、 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
この実装により、複数の資格情報ソースと複数のセッション ストレージ エンジン (Cookie、セッション、DB、または使用したいもの) を持つことができます。
acl の問題については、コントローラー プラグインで LDAP グループを取得し、認証後に必要な場所に保存できます。次に、リクエストごとに ACL をチェックする 2 つ目のプラグインを使用できます。