Results 1 to 3 of 3

Thread: Hack for Google OpenID support ZF 1.6.2

  1. #1
    bholub is offline Junior Member
    Join Date
    Dec 2007
    Posts
    7

    Default Hack for Google OpenID support ZF 1.6.2

    EDIT: this doesn't work anymore....

    I found that version 1.6.2 of the ZF wasn't working with Google's OpenID provider. A few lines added to the consumer class seems to work if you're willing to hack it, until ZF supports it (maybe 1.7 does, I'm not sure).

    File info:
    * @version $Id: Consumer.php 11817 2008-10-10 04:24:20Z yoshida@zend.co.jp $

    Find "protected function _discovery" (line 688). There's a big block of "if/else if" under /* HTML-based discovery */

    Just tack the following onto it: (should be lines 732 - 738)

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

    NOTE: I HAVE NOT TESTED THIS BEYOND USING IT ONCE TO SUCCESSFULLY LOGIN. USE AT YOUR OWN RISK
    Last edited by bholub; 05-07-2009 at 04:43 AM.

  2. #2
    paritycheck is offline Junior Member
    Join Date
    May 2008
    Posts
    8

    Default

    I tried this but it doesn't seem to be working instead I get redirected to a page on google which is not the authentication page How do I get this to work. From what I noticed I can't use my google or Yahoo to sign in using the zend_openid

  3. #3
    bholub is offline Junior Member
    Join Date
    Dec 2007
    Posts
    7

    Default

    Heh I just started implementing OpenID again (with ZF 1.8) and ran into a problem (again) working with Google's Provider... this is where my google search led me :P

    First I'll say that Yahoo is working fine for me (using https://me.yahoo.com as the endpoint). Now for Google.... discovery still seems to be failing... and my hack above results in getting an invalid page from Google. I'll peek around to see if I can find/make a fix.

    Here's my code, which is pretty similar to the example in the ZF OpenID docs (as i said before using https://me.yahoo.com as $_POST['login_openid'] works for me, but https://www.google.com/accounts/o8/id does not work [discovery fails].)
    Code:
    if (isset($_POST['login_openid'])) {
    	$consumer = new Zend_OpenId_Consumer();
    	
    	if (!$consumer->login($_POST['login_openid'])) {
    		echo $consumer->getError() . "<hr />";
    		exit("failed on openid login");
    	}
    } elseif (isset($_GET['openid_mode'])) {
    	if ($_GET['openid_mode'] == 'id_res') {
    		$consumer = new Zend_OpenId_Consumer();
    		if ($consumer->verify($_GET, $id)) {
    			/* block of pseudo code, you probably want to use $id (the user's openid identifier) to retrieve the appropriate user id from your database or something  */
    			$query = "check your database for $id";
    			$data = "get the row from $query response";
    			if (!$data) {
    				exit("openid doesnt exist in db, failed openid login: $id");
    			}
    			$userid = $data['userid'];
    		} else {
    			exit("invalid id");
    		}
    	} else {
    		exit("failed on openid_mode");
    	}
    }

Similar Threads

  1. Zend OpenID Provider DB Storage
    By johnjackson in forum Authentication & Authorization
    Replies: 3
    Last Post: 01-22-2011, 08:58 PM
  2. Getting network error when authenticating with OpenID
    By eaglerock07 in forum Installation & Configuration
    Replies: 1
    Last Post: 08-15-2009, 10:05 PM
  3. Authentication Error with OpenID
    By eaglerock07 in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 08-15-2009, 09:57 PM
  4. openID Association failed
    By shunmugaprasath in forum Authentication & Authorization
    Replies: 1
    Last Post: 12-02-2008, 08:53 AM
  5. OpenID url rewrite
    By netraits in forum Authentication & Authorization
    Replies: 1
    Last Post: 10-22-2008, 06:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •