I have a CMS built on the Zend Framework. It uses Zend_Auth
for "CMS User" authentication. CMS users have roles and permissions that are enforced with Zend_Acl
. I am now trying to create "Site Users" for things like an online store. For simplicity sake I would like to use a separate instance of Zend_Auth
for site users. Zend_Auth
is written as a singleton, so I'm not sure how to accomplish this.
Reasons I don't want to accomplish this by roles:
In that case, you want to create your own 'Auth' class to extend and remove the 'singleton' design pattern that exists in Zend_Auth
This is by no means complete, but you can create an instance and pass it a 'namespace'. The rest of Zend_Auth's public methods should be fine for you.
<?php
class My_Auth extends Zend_Auth
{
public function __construct($namespace) {
$this->setStorage(new Zend_Auth_Storage_Session($namespace));
// do other stuff
}
static function getInstance() {
throw new Zend_Auth_Exception('I do not support getInstance');
}
}
Then where you want to use it, $auth = new My_Auth('CMSUser');
or $auth = new My_Auth('SiteUser');