我对实现 OpenID 很感兴趣,并且我一直在阅读有关它的内容,但仍有一些方面我有点困惑。
我见过多个交互流程图和分步细节,例如this one http://www.windley.com/archives/2006/04/how_does_openid.shtml,但它们都跳过了有关成功登录后发生的情况的详细信息。我读过的所有内容都说“成功登录后,用户将被重定向回该网站”。那么,我的网站如何知道登录成功呢? cookie 是否已设置,我是否会收到 POST 回复,或者其他什么?
例如,以下是我包含的链接中的详细信息
9. User POSTs response to OpenID Server.
10. User is redirected to either the success URL or the failure URL returned in (5) depending on the User response
//this is the step that it says tells me I've had a succes/failure upon login
5. Consumer inspects the HTML document header for <link/> tags with the attribute rel set to openid.server and, optionally, openid.delegate. The Consumer uses the values in these tags to construct a URL with mode checkid_setup for the Identity Server and redirects the User Agent. This checkid_setup URL encodes, among other things, a URL to return to in case of success and one to return to in the case of failure or cancellation of the request
我不太确定如何解释这一点。具体是什么告诉我登录成功?根据我收集的信息,似乎标头中的某些内容已设置,但如何访问它?假设我发现登录成功,这是否意味着我可以继续设置与我的网站相关的 cookie/会话?
编辑-我发现LightOpenID http://gitorious.org/lightopenid#more它似乎适合我的需求,但我仍然有点不确定
我在本地主机上测试了它并让谷歌登录正常工作。登录后我收到一个类似的 URL
User https://www.google.com/accounts/o8/id?id=sdlkfjlkwliej9392010fjos has logged in.
检查代码,它是由以下内容生成的
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
我假设这意味着我只需检查 $openid->validate() 进行登录?对于给定的 google 帐户,$openid->identity 每次都会相同吗?我假设是的,否则就无法每次都跟踪用户。如果用户已经登录,我就可以设置 cookie、会话以及我认为必要的任何其他有趣的东西,对吗?