2010年11月2日星期二

Re: [fw-auth] Mimic a user

On Tuesday 02 Nov 2010 00:55:25 monk.e.boy wrote:
> I was thinking of extending Zend_Auth_Adapter_DbTable so it would respond
> with the user name when I am mimicing them? Should I be looking at ACL?
>
> How do you guys solve this?

This function is most time called impersonating. It means you appears to be
another user for the system.

Zend_Auth takes care of authentication ("Who are you?") so impersonating is
typically a Zend_Auth part. ACL asks the question "Are you allowed to ...?",
which is not the case here (only the question whether a user is allowed to
impersonate.

Zend_Auth has all kind of storage adapters, but apply the
Zend_Auth_Adapter_Interface. This has a method write(), which write the
identity into persistence (often a session).

So the only thing you need to do is:
$username = $myOtherUser->username;
Zend_Auth::getInstance()->getAdapter()->write($username);

You might want to store your current identity into another session. When you
log out, you become your old admin user again.

Regards, Jurian
--
Jurian Sluiman
Soflomo - http://soflomo.com

没有评论: