【发布时间】:2011-08-04 05:35:23
【问题描述】:
我正在使用 DotNetOpenAuth v3.5.0.10357 来支持 OpenID。该站点是使用 DNOA VS 2010 MVC 模板创建的,我对其进行了一些修改(不使用 Ajax 支持或用户控件 - 而是使用 OpenID jquery 插件)。我正在使用特定版本,因为我还实现了 Facebook 支持。这一切都很好。但是当我尝试使用 Google 应用程序时,它似乎并没有像我预期的那样工作。以下是发生的事情:
1) 我使用以下开放 ID 提供程序将我的表单提交到:https://www.google.com/accounts/o8/site-xrds?ns=2&hd=example.com(我通过检查 https://www.google.com/accounts/o8/.well-known/host-meta?hd=example.com 返回的文件得到这个)
2) 我被重定向到谷歌应用,并被要求使用我的谷歌应用凭据登录。
3) 我被重定向到:http://example.com/Auth/LogOnPostAssertion?dnoa.uipopup=1&dnoa.popupUISupported=1&index=0&dnoa.userSuppliedIdentifier=https://www.google.com/accounts/o8/site-xrds?ns=2&hd=example.com&dnoa.op_endpoint=https://www.google.com/a/example.com/o8/ud?be=o8&dnoa.claimed_id=&openid.ns=http://specs.openid.net/auth/2.0&openid.mode=id_res&openid.op_endpoint=https://www.google.com/a/example.com/o8/ud?be=o8&openid.response_nonce=2011-08-04T05:03:14ZmDjx966VdNKGAQ&openid.return_to=http://example.com/Auth/LogOnPostAssertion?dnoa.uipopup=1&dnoa.popupUISupported=1&index=0&dnoa.userSuppliedIdentifier=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fsite-xrds%3Fns%3D2%26hd%3Dexample.com&dnoa.op_endpoint=https%3A%2F%2Fwww.google.com%2Fa%2Fexample.com%2Fo8%2Fud%3Fbe%3Do8&dnoa.claimed_id=&openid.assoc_handle=redacted_value&openid.signed=op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle,ns.ext1,ext1.mode,ext1.type.alias3,ext1.value.alias3,ext1.type.alias1,ext1.value.alias1&openid.sig=redacted_value=&openid.identity=http://example.com/openid?id=redacted_value&openid.claimed_id=http://example.com/openid?id=redacted_value&openid.ns.ext1=http://openid.net/srv/ax/1.0&openid.ext1.mode=fetch_response&openid.ext1.type.alias3=http://schema.openid.net/contact/email&openid.ext1.value.alias3=mark.miller@example.com&openid.ext1.type.alias1=http://axschema.org/contact/email&openid.ext1.value.alias1=mark.miller@example.com&openid.ns.ext2=http://specs.openid.net/extensions/ui/1.0&openid.ext2.mode=popup
然后,当调用 RelyingParty.GetResponse() 时,我将被重定向到 http://example.com/openid. 我知道如果我要托管自己的 XRD,我需要提供响应,但似乎所需的一切都在响应中。它不应该只是从请求中读取值,在查询字符串中使用声明的标识符并完成它吗?控制器操作如下 - RelyingParty 属性的类型为 IOpenIDRelyingParty,并包装了 DotNetOpenAuth 库中 OpenIdRelyingParty 类型的实例。
我应该以不同的方式处理这种情况吗?还是不完全支持这种情况?如果不支持,是否有人对我可以自己添加支持有任何指导?
public ActionResult LogOnPostAssertion(string openid_openidAuthData, string returnUrl){
var response = this.RelyingParty.GetResponse();
if (response == null)
{
//Let us submit the request to OpenID provider
Identifier id;
if (Identifier.TryParse(openid_openidAuthData, out id))
{
try
{
var request = this.RelyingParty.CreateRequest(id, Realm.AutoDetect, Url.ActionFull("LogOnPostAssertion"), this.PrivacyPolicyUrl);
return request.RedirectingResponse.AsActionResult();
}
catch (ProtocolException ex)
{
ViewBag.Message = ex.Message;
}
}
else
{
ViewBag.Message = "Invalid identifier";
}
}
if (response != null && String.IsNullOrEmpty(ViewBag.Message))
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
var token = RelyingPartyLogic.User.ProcessUserLogin(response);
this.FormsAuth.SignIn(token.ClaimedIdentifier, false);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
case AuthenticationStatus.Canceled:
ModelState.AddModelError("OpenID", "It looks like you canceled login at your OpenID Provider.");
break;
case AuthenticationStatus.Failed:
ModelState.AddModelError("OpenID", response.Exception.Message);
break;
}
}
// If we're to this point, login didn't complete successfully.
// Show the LogOn view again to show the user any errors and
// give another chance to complete login.
return View("LogOn");
}
编辑 好的,所以在使用我的标准 gmail 帐户(例如,@gmail.com,而不是 google 应用程序域,@example.com)调试相同的过程后,我收到了来自 google 几乎的回复,与一个以上(#3)。除了标识符和与参数 dnoa.userSuppliedIdentifier 相关的东西外,一切都几乎相同 - 这是预期的。但不一样的一件事是参数 openid.claimedid 参数。这是两者的样子:
openid.claimed_id=http://example.com/openid?id=long_integer_value
openid.claimed_id=https://www.google.com/accounts/o8/id?id=some_hash_value
所以看起来 DNOA 必须使用 claim_id 的值对 OP(OpenID 提供者)进行二次验证。我猜我需要提供一个响应该 url 的端点。但是,我的问题就变成了,因为我事先不知道值“id”,我该如何响应来自 DNOA 的请求?
【问题讨论】:
-
我尝试使用我的 Google Apps 帐户 puffypoodles.com 并能够登录。我刚刚在文本框中输入了我的域 example.com 并能够登录。那么这仅仅是 DNOA 不支持这种情况的结果吗?
-
你能把问题标题改成问题的形式吗?
标签: asp.net-mvc-3 openid dotnetopenauth google-apps