我实际上已经找到了解决问题的方法,而且令人惊讶的是,它非常简单。我仍然不了解 XRDS 和 Yadis,但我很容易像这样利用它。
你想要什么,你正在寻找什么是做 OpenID“中继方”东西的代码。这就是作为 OpenID 提供者的消费者的“你”。您输入一个 OpenID 端点,瞧,您已经启用了您的站点的 OpenID,此代码在实践中说明了这一点。
// using DotNetOpenAuth
var openid = new OpenIdRelyingParty();
var response = openid.GetResponse();
if (response == null)
{
// Google account end point (works fine)
var googleID = "https://www.google.com/accounts/o8/id";
// Google hosted account end point
// https://www.google.com/accounts/o8/site-xrds?hd=mydomain.com
// I was unable to test this, but I was running my RP (this code)
// from localhost and it's quite possible that a hosted account RP
// has to return to the same domain.
// It went fine, but crashed with a "Unable to resolve mydomain.com" error
// once I logged in.
openid.CreateRequest(googleID).RedirectToProvider();
}
else
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
// Success
// to allow persistance across sessions
// you'll have to track the "claimed identifier"
// some OpenID providers allow you to get an email address through
// extensions but this is not always possible.
// the claimed identifier is typically your safest bet
// and it's a big URL which uniquely identifies the guest
// as a specific user, however, you know very little about this user
// which is a good thing becuase you don't have to give out personal or
// sensitive information to start using a service.
break;
default:
// Something went wrong, check Status property
break;
}
}
当我弄清楚这一点时,我从每个规格中都得到了印象。在那里,我应该托管我自己的“OpenID 提供程序”,这听起来像是我应该处理帐户或流程的某些部分。实际上,我所要做的就是这个。
请求该 URL,或者如果您收到 OpenID 请求作为响应。检查该请求是否包含有效的登录信息。