From the code you presented, it appears that your usage is correct. However, I can't tell where the $request and $response variables are coming from. Are those assert() lines failing? If not, how are you getting the $request and $response? The HTTP adapter expects those to be the actual request and response the front controller is using to handle the current request, because it needs to read request headers from the client and send out response headers.

Also, please use a tool that will let you view all the HTTP headers during the request and response cycle involving your testAction. If I could see those, it would help me understand what's going on.

Regards,
Bryce Lohr


mbneto wrote:
Hi,

I am trying to use Zend_Auth_Adapter_Http according to the example from http://framework.zend.com/manual/en/zend.auth.adapter.http.html with no luck.

I have the following code inside a testAction

$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('/home/devel/admin/password.txt');

        $digestResolver = new Zend_Auth_Adapter_Http_Resolver_File();
        $digestResolver->setFile('/home/devel/admin/password.txt');
$adapter->setBasicResolver($basicResolver);
        $adapter->setDigestResolver($digestResolver);

        assert($request instanceof Zend_Controller_Request_Http);
        assert($response instanceof Zend_Controller_Response_Http);
$adapter->setRequest($request);
        $adapter->setResponse($response);

        $result = $adapter->authenticate();
        if (!$result->isValid()) {
        // Bad userame/password, or canceled password prompt
        }

Am I missing something or where those request / response should be defined somewhere?

How do I force that user/password dialog to open on specific controller/action? I used to add a .htaccess but that works only on a directory level right?

Reply via email to