【发布时间】:2010-06-24 21:41:07
【问题描述】:
我一直在玩弄 JanRain OpenID PHP 库,主要关注 a tutorial I found on ZendZone。
如何区分用户 - 尤其是最终使用相同 OpenID URL https://www.google.com/accounts/o8/id 的 Google 用户?
基本上,我可以检测到他们有一个 OpenID 帐户......他们已经成功通过身份验证......但我的应用程序仍然不知道他们是谁;只是他们通过了身份验证。
为了区分用户,本教程使用“简单注册请求”来请求用户的 OpenID 提供者的电子邮件 - 然后使用电子邮件地址查看这是否是返回用户。
它对我不起作用,apparently won't work with some providers 所以当我偶然发现一个函数 getDisplayIdentifier 时我很兴奋。
require_once "Auth/OpenID/Consumer.php";
require_once "Auth/OpenID/FileStore.php";
// create file storage area for OpenID data
$store = new Auth_OpenID_FileStore('/wtv');
$consumer = new Auth_OpenID_Consumer($store);
$oid_response = $consumer->complete("http://example.com/oir_return");
if ($oid_response->status == Auth_OpenID_SUCCESS) {
$hopefullyUniqueUserID = $oid_response->getDisplayIdentifier(); // I assumed this would be a relatively permanent way to identify the user...
// I was wrong.
}
不幸的是,几个小时后,getDisplayIdentifier 返回的值发生了变化。
【问题讨论】:
-
请仔细阅读规范。
https://www.google.com/accounts/o8/id是用户提供的标识符,用户不一定声称他拥有它,其目的可能只是引导用户选择标识符,就像 Google 的情况一样。
标签: php authentication openid janrain