Thursday, July 29, 2010

Getting Digest Authentication to Work

I am having difficulty getting digest authentication to work. The
code works if I use basic, but when I switch to digest, the
credentials don't authenticate (i.e. the browser username/password
popup keeps displaying). I have tried to md5 hash the password and
leave it plain text and neither works.

Here's the code that works (basic authentication):

function beforeFilter() {
if ( $this->RequestHandler->isXml() ) {
$this->Auth->allow('index');
$this->Security->loginOptions = array(
'type' => 'basic',
'realm' => 'WebService'
);
$this->Security->loginUsers = array('user' => 'secret');

$this->Security->requireLogin('index');
} else {
parent::beforeFilter();
}
}

And here's the code that doesn't (digest authentication):

function beforeFilter() {
if ( $this->RequestHandler->isXml() ) {
$this->Auth->allow('index');
$this->Security->loginOptions = array(
'type' => 'digest',
'realm' => 'WebService'
);
$this->Security->loginUsers = array('user' => 'secret');
/* $this->Security->loginUsers = array('user' => md5('secret')); */

$this->Security->requireLogin('index');
} else {
parent::beforeFilter();
}
}


What am I still missing?

Note, I'm using CakePHP 1.2.5. Web server is Apache 1.3.41. PHP is
5.2.9.

thanks in advance,
Michael

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: