2010年12月17日星期五

Re: [fw-mvc] problem in Zend_Auth_HTTP

It looks like you're authenticating, but not storing the results of that
authentication anywhere. I'm not sure if the HTTP authentication is any
different from the others, but I believe you need to use Zend_Auth's
authenticate method instead of calling it on the adapter directly:

$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('somenamespace'));
$result = $auth->authenticate($adapter);

Internally, Zend_Auth will call the authenticate() method on your adapter,
and if successful store the results in the storage adapter. This will allow
you to check for authentication on the next request without having to set up
your HTTP adapter all over again:

// next request
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('somenamespace'));
if ($auth->hasIdentity()) {
// logged in
$identity = $auth->getIdentity();
} else {
// not logged in
}

I hope this helps.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Thu, Dec 16, 2010 at 11:45 PM, sina miandashti <miandashti@gmail.com>wrote:

> hey alll :)
>
> i want to use this on my AdminController.php
> so in public init() i wrote this :
>
> $config = array(
> 'accept_schemes' => 'basic digest',
> 'realm' => 'My Web Site',
> 'digest_domains' => '/members_only /my_account',
> 'nonce_timeout' => 3600,
> );
> $adapter = new Zend_Auth_Adapter_Http($config);
>
> $basicResolver = new Zend_Auth_Adapter_Http_Resolver_File();
>
> $basicResolver->setFile(APPLICATION_PATH.'\basicPasswd.txt');
>
>
> $adapter->setBasicResolver($basicResolver);
>
>
>
> $adapter->setRequest($this->_request);
>
> $adapter->setResponse($this->_response);
>
> $result = $adapter->authenticate();
>
> if (!$result->isValid()) {
> throw new Zend_Exception("You Dont have access to admin area");
> } else {
> die('u have access');
> }
>
>
>
> *and in my password file :
> admin:827ccb0eea8a706c4c34a16891f84e7b
>
> *the above pass is md5 of '12345'
>
>
>
> the problem is it request for password again and again also when u type
> the correct user password.
> :(
>
> i think it cannot match the userpass from password file
> how to fix it?
>
> --
> ________________
> Sincerely
> Sina Miandashti
> MuSicBasE.ir & InvisionPower.ir Admin
>

没有评论: