View Single Post
  #1 (permalink)  
Old 12-06-2007, 07:18 AM
parse parse is offline
Junior Member
 
Join Date: Aug 2007
Posts: 7
Default Zend_Auth_Adapter_Http doesn't authenticate

Hi folks. I'm running a modular setup on ZF 1.0.3
This is the url.com: Search with Many (the admin-module).

PHP Code:
<?php
require_once 'Zend/Auth/Adapter/Http.php';
require_once 
'Zend/Auth/Adapter/Http/Resolver/File.php';

class 
Admin_IndexController extends Zend_Controller_Action {
    
    public function 
init()
    {
        
$this->getHelper('layoutManager')->useLayoutName('admin');

        
$config = array(
            
'accept_schemes' => 'basic',
            
'realm'          => 'xcstorm'
        
);
        
        
$adapter = new Zend_Auth_Adapter_Http($config);
        
        
$basicResolver = new Zend_Auth_Adapter_Http_Resolver_File();
        
$basicResolver->setFile('../app/etc/basicPasswd.txt');
        
        
$adapter->setBasicResolver($basicResolver);
        
        
$request Zend_Controller_Front::getInstance()->getRequest();
        
$response Zend_Controller_Front::getInstance()->getResponse();
        
        
assert($request instanceof Zend_Controller_Request_Http);
        
assert($response instanceof Zend_Controller_Response_Http);
        
        
$adapter->setRequest($request);
        
$adapter->setResponse($response);
        
        
$auth $adapter->authenticate();
        
        if (!
$auth->isValid())
            die(
"No access");
        else
            die(
"You have access");

    }
    
    public function 
indexAction() {
    }

}
If I run the code like this, it will not ask for my credentials. But if I remove the die()-parts in the end. It will ask, but it will continue to ask.
A dump of $auth gives: object(Zend_Auth_Result)#59 (3) {
["_coderotected"]=> int(-3) ["_identityrotected"]=> array(0) { } ["_messagesrotected"]=> array(1) { [0]=> string(49) "Invalid or absent
credentials; challenging client" } }

My basicPasswd.txt is like this (admin/admin):
admin:xcstorm:21232f297a57a5a743894a0e4a801fc3

Happy for any advice anyone will give.
Reply With Quote