"No session state found" with Konqueror and MyOpenID
Daniel Hofstetter
daniel-hofstetter at gmx.ch
Tue Mar 27 09:03:01 PST 2007
Jonathan Daugherty wrote:
> # As the combination Konqueror/MyOpenID usually works fine, I think
> # the problem has to be in my application. Anyone an idea what could
> # be the problem resp. how to debug this issue?
>
> Are you willing to post your RP code (either here, or to me,
> privately)? That would help. Also, is the site public? Can I test?
I put it to http://test.42dh.com .
Here the code I am using (together with PHP OpenID library 1.2.2):
class UsersController extends AppController {
var $components = array('Openid');
var $helpers = array('Form');
var $uses = array();
function login() {
if (!empty($this->data)) {
$status =
$this->Openid->authenticate($this->data['OpenidUrl']['openid'],
'http://'.$_SERVER['SERVER_NAME'].'/users/login',
'http://'.$_SERVER['SERVER_NAME']);
if ($status === false) {
$this->set('authenticationError', true);
}
} else {
if (count($_GET) > 1) {
$response = $this->Openid->getResponse();
debug($response);
exit();
}
}
}
}
Plus the component:
class OpenidComponent extends Object {
var $controller = null;
function startUp($controller) {
$this->controller = $controller;
$pathExtra = APP.DS.'vendors'.DS.PATH_SEPARATOR.VENDORS;
$path = ini_get('include_path');
$path = $pathExtra . PATH_SEPARATOR . $path;
ini_set('include_path', $path);
}
function authenticate($openId, $processUrl, $trustRoot,
$extensionArguments = null) {
$consumer = $this->__getConsumer();
$authRequest = $consumer->begin($openId);
if (!$authRequest) {
return false;
}
if ($extensionArguments != null) {
foreach ($extensionArguments as $extensionArgument) {
if (count($extensionArgument) == 3) {
$authRequest->addExtensionArg($extensionArgument[0],
$extensionArgument[1], $extensionArgument[2]);
}
}
}
$redirectUrl = $authRequest->redirectURL($trustRoot, $processUrl);
$this->controller->redirect($redirectUrl);
}
function getResponse() {
$consumer = $this->__getConsumer();
$response = $consumer->complete($_GET);
return $response;
}
function __getConsumer() {
vendor('Auth'.DS.'OpenID'.DS.'Consumer');
vendor('Auth'.DS.'OpenID'.DS.'FileStore');
$storePath = TMP."openid";
if (!file_exists($storePath) && !mkdir($storePath)) {
print "Could not create the FileStore directory
'$storePath'. Please check the effective permissions.";
exit(0);
}
$store = new Auth_OpenID_FileStore($storePath);
$consumer = new Auth_OpenID_Consumer($store);
return $consumer;
}
}
Thanks,
daniel
More information about the Dev
mailing list