Hi,

I'm implementing Zend_Auth scheme and do not understand what is the best way
to store role of the user.

My scheme is based on http://devzone.zend.com/node/view/id/1665 (which seems
broken now because last code fragment is incomplete) and I want to store
user's identity and all associated information in the session storage as
follows:

class SomeAuthAdapter extends ... {
 ...
 function authenticate() {
   ...
   return new Zend_Auth_Result($authResult['code'], array('name' => ...,
'role' => ..., ...), $authResult['messages']);
 }
 ...
}

$adapter = new SomeAuthAdapter();
$adapter->setIdentity($name);
$adapter->setCredential($password);
$auth = Zend_Auth::getInstance();
$auth->authenticate($adapter);

authenticate() calls $this->getStorage()->write($result->getIdentity()); and
identity is supposed to be string only. So what if I want to store Visible
Name, Role, Email and other attributes associated with the identity?
It will be interesting to use serialize/deserialize calls in
Zend_Auth_Storage_Session's read() and write() so it will be possible to
store identity object of any type.
Or maybe add Identity class or Principal class with get/setIdentity() to
store unique identity and get/setProperty() to store associated data?

Sincerely,

--
Alexander
http://www.alexatnet.com/ - Blog and CMS created with Zend Framework and
Ajax.

Reply via email to