【发布时间】:2011-01-16 23:18:06
【问题描述】:
我在使用 openid check_authentication 时遇到了一些问题。 openid 提供者的答案(我用 google 和 myopenid 试过)总是:is_valid:false
我确实已经获得了 openid.sig 和 openid.identity 但是当我尝试 使用 check_authentication 调用验证我的数据,它总是返回 is_valid:false。
到目前为止我所做的(在此示例中使用 google openid 进行身份验证,但对于 myopenid 是相同的):
我将网络用户从我的页面重定向到以下网址:
https://www.google.com/accounts/o8/ud ?openid.ns=http://specs.openid.net/auth/2.0 &openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select &openid.identity=http://specs.openid.net/auth/2.0/identifier_select &openid.return_to=http://localhost:104/evalgoogle.aspx &openid.mode=checkid_setup
(当然没有换行符,我把它们放在这篇文章中只是为了 保持可读性。 localhost:104/evalgoogle.aspx 是我本地的测试环境)
然后我将被重定向到我可以签名的谷歌登录页面 并接受我将在 Localhost 登录。 不过我取消了记住复选框。
登录后,我将被重定向到我设置的 return_to 页面 在请求中获取以下数据:
openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0 &openid.mode=id_res &openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud &openid.response_nonce=2010-02-12T14%3A46%3A52Z1PDyxBssEN9p5g &openid.return_to=http%3A%2F%2Flocalhost%3A104%2Fevalgoogle.aspx &openid.assoc_handle=AOQobUfpVnBFYzFO15z92rru88nWjEnw0u8ethVscpjDwkssp8GjVc0u &openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to %2Cresponse_nonce%2Cassoc_handle &openid.sig=24Hetky5HrNwrY3%2B%2B2vtIGnvmnI%3D &openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3D{SOMEID} &openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3D{SOMEID}
(其中 {SOMEID} 是我的 google id)
为了验证这个签名和 google id,我编写了一个 webrequest 按照 openid.net/specs/openid-authentication-1_1.html#mode_check_authentication 中的描述调用 check_authentication
我现在的问题是这总是返回 is_valid:false
为了消除我的 webrequest 中可能出现的问题,我现在只创建一个 html 表单,其中包含我从谷歌返回的数据,如下所示:
<form method="post" action="<%=Request.Params["openid.op_endpoint"] %>">
<div>
<input type="text" name="openid.mode" value="check_authentication" />
<input type="text" name="openid.assoc_handle" value="<
%=Request.Params["openid.assoc_handle"] %>" /> " /> " /> " /> " /> " /> " />
但这也只会产生 is_valid:false
有人知道我的方法有什么问题吗?
非常感谢
【问题讨论】:
-
您对 OpenID 1.1 规范的引用表明您正在查看错误的规范。您应该参考 OpenID 2.0 规范。我怀疑您的实施中存在一些大的安全漏洞,基于您正在尝试做的一些事情。您是否考虑过使用经过验证的库,例如 DotNetOpenAuth? blog.nerdbank.net/2008/04/argument-for-extra-dependency-of.html