开发者

getting SREG data using Zend_Auth and OpenID

I can't figure out how to get SREG extension values when using Zend_Auth_Adapter_OpenId. I'm following these documentation pages:

http://framework.zend.com/manual/en/zend.auth.introduction.html

http://framework.zend.com/manual/en/zend.openid.consumer.html

In the documentation on Zend_Auth, it says when using OpenID to make a second call to authenticate(), like this:

$auth_result = $auth->authenticate(new Zend_Auth_Adapter_OpenId());

And that works, with $auth_result ending up as Zend_Auth_Result::SUCCESS.

However, in the Zend_OpenId_Consumer documentation, in order to get at the returned SREG data it says to do this:

$sreg = new Zend_OpenId_Extension_Sreg(array('email'=>false,'fullname'=>false), null, 1.1);
$consumer = new Zend_OpenId_Consumer();
$consume开发者_开发百科r->verify($_GET, $id, $sreg);

And that works too, as verify() returns true and $sreg->getProperties() returns the SREG fields I requested.

The problem is that I cannot do both of these things! If I make that call to authenticate() first, then verify() returns false. If I verify() first, then authenticate() returns Zend_Auth_Result::FAILURE. Looking at the code in Zend/Auth/Adapter/OpenId.php, it's evident that authenticate() is calling verify() internally, which makes sense. However the SREG values that are populated by this internal call are not exposed through any means I can see. What am I missing?

(While typing this and experimenting I discovered that I can just grab the SREG values off of $_GET, e.g. $_GET['openid_sreg_email'], but that doesn't seem like it would be the intended pattern. It solves my problem, but I would still like to know if there is a more official solution.)


Zend officially does not support OpenID 2.0 and Google OpenID provider. But there is a patch available from the Issue tracker. Here is the link to that patch. You must replace your Consumer.php from that site. After applying this patch, OpenID should work with Google and other major providers like Yahoo!

And talking about the OP, getting SREG from OpenID result, there is no such standard available for the GET parameter. This is already discussed once in StackOverflow here and in Meta StackOverflow here.

Attribute Exchange is another thing that is needed in Zend Framework.

Related question here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜