How do I implement Direct Identity based OpenID authentication with Zend OpenID

Answer

Little late to the game but I was able to get this working with some hacks I found around the interwebs.

First. Yahoo. To get Yahoo working all I had to do was change the JavaScript to use me.yahoo.com instead of just yahoo.com and it worked perfectly with the version of the Zend Framework I'm using. Unfortunately Google still wasn't, so some hacking was in order.

All of these changes go in Zend/OpenId/Consumer.php

First, in the _discovery method add the following on the series of preg_match checks that starts at around line 740.

}elseif(preg_match('/<URI>([^<]+)<\/URI>/i', $response, $r)){
    $version =2.0;
    $server = $r[1];

I added this right before the return false; statement that's in the else {} block.

Second, in the _checkId method you'll need to add 3 new blocks (I haven't dug around enough to know what causes each of these three cases to be called, so I covered all to be on the safe side.

Inside the $version <= 2.0 block, you'll find an if/else if/else block. In the first if statement ($this->_session !== null) add this to the end:

if($server =='https://www.google.com/accounts/o8/ud'){
    $this->_session->identity ='http://specs.openid.net/auth/2.0/identifier_select';
    $this->_session->claimed_id ='http://specs.openid.net/auth/2.0/identifier_select';}

In the else if (defined('SID') block add this to the end:

if($server =='https://www.google.com/accounts/o8/ud'){
    $_SESSION['zend_openid']['identity']='http://specs.openid.net/auth/2.0/identifier_select';
    $_SESSION['zend_openid']['claimed_id']='http://specs.openid.net/auth/2.0/identifier_select';}

And then after the else block (so outside the if/else if/else block all together, but still inside the $version <= 2.0 block) add this:

if($server =='https://www.google.com/accounts/o8/ud'){
    $params['openid.identity']='http://specs.openid.net/auth/2.0/identifier_select';
    $params['openid.claimed_id']='http://specs.openid.net/auth/2.0/identifier_select';

All zend-framework Questions

Ask your interview questions on zend-framework

Write Your comment or Questions if you want the answers on zend-framework from zend-framework Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---