Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-06-2007, 08:18 AM
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 06:15 AM
Junior Member
 
Join Date: Apr 2008
Posts: 1
Default Zend Framework does not support Internet Explorer

Yes, I have the same problem in 1.5.1

I can get it work only in Opera and Firefox, but Internet Explorer 7/8 and Safari fails navigation.

I am done with http adapter in ZF

There is not a single one working tutorial to get http adapter working.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-21-2008, 03:47 AM
BJM BJM is offline
Junior Member
 
Join Date: Apr 2008
Posts: 8
Default

Hi,

parse: If you are subscribed to this post (and therefore see this message), do you mind letting us know how you overcame your issue? Do you have code you can share? If you haven't looked into it further, I believe one problem is that you md5 encoded your password, yet choose the basic authentication. Only digest is md5 encoded, not basic. I copied your code and put admin2:xcstorm:admin2 in the password file and it seemed to allow me to login. Having said that, as you noticed I'm repeatedly asked for the username and password if I enter incorrect values, therefore I haven't yet figured out how to display an error message instead. Let me know if you figured this out.

As for techi's comment, I haven't found much help either. If anyone knows of some good examples, please post the URLs.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-11-2008, 11:16 PM
Junior Member
 
Join Date: Oct 2008
Posts: 2
Arrow

Hi,

had the same problem and it took me almost an hour to figure out a solution.. the trick is to send the response when authentication failed (see code below). :-)

PHP Code:
        // ...
        // parse's code from post above
        // ...

        
$adapter->setRequest($request);
        
$adapter->setResponse($response);
        
        
$auth $adapter->authenticate();
        
        if (!
$auth->isValid()){
            
$response->sendResponse();  // <-- here we go..
            
die;
        }else
            die(
"You have access"); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-12-2008, 01:08 AM
Junior Member
 
Join Date: Oct 2008
Posts: 2
Default

Well.. another couple of hours wasted: This whole thing only works when PHP runs as apache module. If you run apache as cgi, the $_SERVER vars containing the authentication infos won't be set..


see: Zend Developer Zone

Last edited by epegzz : 10-12-2008 at 01:11 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:52 AM.