1
  • DotNetOpenAuth 3.4.1.10044
  • Windows 7(64 位)
  • VS 2008 SP1、.NET 3.5、C#
  • 视窗天青

围绕 OpenID 调用的片段背后的ASP.NET代码:

OpenIdRelyingParty rp = new OpenIdRelyingParty(null);
string discoveryUri = "";
if (provider == "google") {
    discoveryUri = "https://www.google.com/accounts/08/id";
    Application.Set("Provider", "Google");
} else if (provider == "yahoo") {
    discoveryUri = "https://me.yahoo.com";
    Application.Set("Provider", "Yahoo");
}
try {
    string openIdUri = Request.Url.ToString();
    var b = new UriBuilder(openIdUri) { Query = "" };
    Response.Write("OpenId_Click: Request.Url = " + Request.Url);
    var req = rp.CreateRequest(discoveryUri, b.Uri, b.Uri);
    Response.Write("OpenId_Click: discoveryUri = " + discoveryUri);
    try {
        req.RedirectToProvider();
    } catch (ThreadAbortException tae) {
        string taem = tae.Message;
    }
} catch (Exception ex) {
    string s = ex.Message;
}
rp.Dispose();

我有以下(3)行为:

当我第一次启动 ASP.NET(Azure 开发存储)时,如果我对 Yahoo! 进行身份验证,则它是成功的。如果我尝试对 Yahoo! 进行身份验证!一分钟后,对 RedirectToProvider 的调用不再返回响应。之后,对 Google 和 Yahoo! 的额外调用!不返回响应。

当我第一次启动 ASP.NET 时,如果我对 Google 进行身份验证,它是成功的。如果我在一分钟后再次尝试对 Google 进行身份验证,则对 RedirectToProvider 的调用会成功,而不会询问我的用户名/密码。(我没有选中记住我复选框。)之后,对 Google 的其他调用仍然成功。(谷歌似乎缓存了第一个请求的结果。)如果我随后对 Yahoo! 进行身份验证!对 RedirectToProvider 的调用永远不会返回响应。如果我切换回 Google,我会再次成功,而无需询问我的用户名/密码。

当我第一次启动 ASP.NET(Azure 开发存储)时,如果我对 Yahoo! 进行身份验证,则它是成功的。如果我在一分钟后尝试对 Google 进行身份验证,则对 RedirectToProvider 的调用永远不会返回响应。

没有明显的失败(除了通常的 ThreadAbortException 噪音,无论调用是否成功,似乎都会发生)。

关于可能发生的事情有什么想法吗?

以下是来自 Yahoo! 的第三种情况的一些跟踪信息。成功了,那么谷歌不行:

使用单个消息创建的同步队列 ==> 忙:信息 [WaWebHost.exe] DotNetOpenAuth,版本=3.4.1.10044,文化=中性,PublicKeyToken=2780ccd10d57b246(官方)
[WaWebHost.exe] 将 Provider 的最低 OpenID 版本要求提高到 2.0,以保护此无状态 RP 免受重放攻击。
[WaWebHost.exe] 报告将使用具有范围的隔离存储:用户、域、程序集
[WaWebHost.exe] HTTP GET https://me.yahoo.com/
[WaWebHost.exe] 在 HTTP 标头中找到 X-XRDS-Location。准备从 https://open.login.yahooapis.com/openid20/www.yahoo.com/xrds 提取 XRDS
[WaWebHost.exe] HTTP GET https://open.login.yahooapis.com/openid20/www.yahoo.com/xrds
[WaWebHost.exe] 在 XRDS 中发现的服务总数:1
[WaWebHost.exe] [{
    ClaimedIdentifier:http://specs.openid.net/auth/2.0/identifier_select
    ProviderLocalIdentifier:http://specs.openid.net/auth/2.0/identifier_select
    ProviderEndpoint:https://open.login.yahooapis.com/openid/op/auth
    OpenID 版本:2.0
    服务类型 URI:
        http://specs.openid.net/auth/2.0/server
        http://specs.openid.net/extensions/pape/1.0
        http://openid.net/sreg/1.0
        http://openid.net/extensions/sreg/1.1
        http://openid.net/srv/ax/1.0
        http://specs.openid.net/extensions/oauth/1.0
        http://specs.openid.net/extensions/ui/1.0/lang-pref
        http://specs.openid.net/extensions/ui/1.0/mode/popup
        http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier
        http://www.idmanagement.gov/schema/2009/05/icam/no-pii.pdf
        http://www.idmanagement.gov/schema/2009/05/icam/openid-trust-level1.pdf
        http://csrc.nist.gov/publications/nistpubs/800-63/SP800-63V1_0_2.pdf
},]
[WaWebHost.exe] 跳过 HTML 发现,因为 XRDS 包含服务端点。
[WaWebHost.exe] 对用户提供的标识符执行发现:https://me.yahoo.com/
[WaWebHost.exe] 为用户提供的标识符创建身份验证请求:https://me.yahoo.com/
[WaWebHost.exe] 准备发送 CheckIdRequest (2.0) 消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement 应用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.RelyingPartySecurityOptions 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.BackwardCompatibilityBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.Messaging.Bindings.StandardExpirationBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement 不适用于消息。
[WaWebHost.exe] 发送消息:CheckIdRequest
[WaWebHost.exe] 重定向到 https://open.login.yahooapis.com/openid/op/auth?openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity =http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=http%3A%2F%2F127.0.0.1%3A5100%2FOpenId.aspx%3Fdnoa.userSuppliedIdentifier%3Dhttps%253A%252F %252Fme.yahoo.com&openid.realm=http%3A%2F%2F127.0.0.1%3A5100%2FOpenId.aspx&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
[WaWebHost.exe] 将 Provider 的最低 OpenID 版本要求提高到 2.0,以保护此无状态 RP 免受重放攻击。
[WaWebHost.exe] 传入的 HTTP 请求:GET http://127.0.0.1:5100/OpenId.aspx?dnoa.userSuppliedIdentifier=https%3A%2F%2Fme.yahoo.com&openid.ns=http%3A%2F%2Fspecs。 openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.return_to=http%3A%2F%2F127.0.0.1%3A5100%2FOpenId.aspx%3Fdnoa.userSuppliedIdentifier%3Dhttps%253A%252F%252Fme.yahoo.com&openid。 claim_id=https%3A%2F%2Fme.yahoo.com%2Fa%2FXLKt_2gxi_gDtLXSO4IyPi6gz3xDxA--%23afa8c&openid.identity=https%3A%2F%2Fme.yahoo.com%2Fa%2FXLKt_2gxi_gDtLXSO4IyPi6gz3xDxA3%2%F=http% %2F127.0.0.1%3A5100%2FOpenId.aspx&openid.assoc_handle=kCG5j8w0Czja2yJ.JumEVy3SNaHp4aZQ4AdjguIo.OU2SrcpQsEtBxiZvqP_wP9Yf03KI_eOet5.Qsbv2Ov7MXEyGdVP4b4p4Cewoent7pmFNBxanpkYCg_W_zvJXkUo&openid.response_nonce=2010-03-04T19%3A48%3A00ZT3svYxSveINSAkkLdpO.IApS8NhEBBSdLQ--&openid.签名=assoc_handle%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned%2Cpape.auth_level.nist&openid.op_endpoint=https%3A%2F%2Fopen.login.yahooapis.com%2Fopenid%2Fop%2Fauth&openid.pape。 auth_level.nist=0&openid.sig=mnpe8U7hLo3XBpUnmuX2tRgPwHA%3D
[WaWebHost.exe] 收到的传入请求:PositiveAssertionResponse
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.BackwardCompatibilityBindingElement 不适用于消息。
[WaWebHost.exe] 验证传入的 PositiveAssertionResponse 消息签名:mnpe8U7hLo3XBpUnmuX2tRgPwHA=
[WaWebHost.exe] 准备发送 CheckAuthenticationRequest (2.0) 消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.RelyingPartySecurityOptions 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.BackwardCompatibilityBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.Messaging.Bindings.StandardExpirationBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement 不适用于消息。
[WaWebHost.exe] 发送 CheckAuthenticationRequest 请求。
[WaWebHost.exe] HTTP POST https://open.login.yahooapis.com/openid/op/auth
[WaWebHost.exe] 收到 CheckAuthenticationResponse 响应。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.BackwardCompatibilityBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.Messaging.Bindings.StandardExpirationBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.RelyingPartySecurityOptions 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement 应用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.Messaging.Bindings.StandardExpirationBindingElement 应用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.RelyingPartySecurityOptions 应用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement 应用于消息。
[WaWebHost.exe] 验证断言匹配标识符发现结果...
[WaWebHost.exe] HTTP GET https://me.yahoo.com/a/XLKt_2gxi_gDtLXSO4IyPi6gz3xDxA--#afa8c
[WaWebHost.exe] 在 HTTP 标头中找到 X-XRDS-Location。准备从 https://open.login.yahooapis.com/openid20/user_profile/xrds 提取 XRDS
[WaWebHost.exe] HTTP GET https://open.login.yahooapis.com/openid20/user_profile/xrds
[WaWebHost.exe] 在 XRDS 中发现的服务总数:1
[WaWebHost.exe] [{
    ClaimedIdentifier:https://me.yahoo.com/a/XLKt_2gxi_gDtLXSO4IyPi6gz3xDxA--#afa8c
    ProviderLocalIdentifier:https://me.yahoo.com/a/XLKt_2gxi_gDtLXSO4IyPi6gz3xDxA--#afa8c
    ProviderEndpoint:https://open.login.yahooapis.com/openid/op/auth
    OpenID 版本:2.0
    服务类型 URI:
        http://specs.openid.net/auth/2.0/signon
        http://specs.openid.net/extensions/pape/1.0
        http://openid.net/sreg/1.0
        http://openid.net/extensions/sreg/1.1
        http://openid.net/srv/ax/1.0
        http://specs.openid.net/extensions/oauth/1.0
        http://specs.openid.net/extensions/ui/1.0/lang-pref
        http://specs.openid.net/extensions/ui/1.0/mode/popup
        http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier
        http://www.idmanagement.gov/schema/2009/05/icam/no-pii.pdf
        http://www.idmanagement.gov/schema/2009/05/icam/openid-trust-level1.pdf
        http://csrc.nist.gov/publications/nistpubs/800-63/SP800-63V1_0_2.pdf
},]
[WaWebHost.exe] 跳过 HTML 发现,因为 XRDS 包含服务端点。
[WaWebHost.exe] 通过 https://open.login.yahooapis.com/openid/op/auth 收到 https://me.yahoo.com/a/XLKt_2gxi_gDtLXSO4IyPi6gz3xDxA--#afa8c 的身份断言。
[WaWebHost.exe] 将 Provider 的最低 OpenID 版本要求提高到 2.0,以保护此无状态 RP 免受重放攻击。
[WaWebHost.exe] 传入的 HTTP 请求:GET http://127.0.0.1:81/OpenId.aspx?provider=Yahoo&email=rjf@surfmark.com&userid=XLKt_2gxi_gDtLXSO4IyPi6gz3xDxA--
[WaWebHost.exe] 将 Provider 的最低 OpenID 版本要求提高到 2.0,以保护此无状态 RP 免受重放攻击。
[WaWebHost.exe] HTTP GET https://www.google.com/accounts/o8/id
[WaWebHost.exe] 在用户提供的标识符处从 GET 接收到 XRDS 响应。
[WaWebHost.exe] 在 XRDS 中发现的服务总数:1
[WaWebHost.exe] [{
    ClaimedIdentifier:http://specs.openid.net/auth/2.0/identifier_select
    ProviderLocalIdentifier:http://specs.openid.net/auth/2.0/identifier_select
    ProviderEndpoint:https://www.google.com/accounts/o8/ud
    OpenID 版本:2.0
    服务类型 URI:
        http://specs.openid.net/auth/2.0/server
        http://openid.net/srv/ax/1.0
        http://specs.openid.net/extensions/ui/1.0/mode/popup
        http://specs.openid.net/extensions/ui/1.0/icon
        http://specs.openid.net/extensions/pape/1.0
},]
[WaWebHost.exe] 跳过 HTML 发现,因为 XRDS 包含服务端点。
[WaWebHost.exe] 对用户提供的标识符执行发现:https://www.google.com/accounts/o8/id
[WaWebHost.exe] 为用户提供的标识符创建身份验证请求:https://www.google.com/accounts/o8/id
[WaWebHost.exe] 准备发送 CheckIdRequest (2.0) 消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement 应用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.RelyingPartySecurityOptions 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.BackwardCompatibilityBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.Messaging.Bindings.StandardExpirationBindingElement 不适用于消息。
[WaWebHost.exe] 绑定元素 DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement 不适用于消息。
[WaWebHost.exe] 发送消息:CheckIdRequest
[WaWebHost.exe] 重定向到 https://www.google.com/accounts/o8/ud?openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http %3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=http%3A%2F%2F127.0.0.1%3A5100%2FOpenId.aspx%3Fdnoa.userSuppliedIdentifier%3Dhttps%253A%252F%252Fwww .google.com%252Faccounts%252Fo8%252Fid&openid.realm=http%3A%2F%2F127.0.0.1%3A5100%2FOpenId.aspx&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth %2F2.0

4

1 回答 1

2

看起来您正在捕获异常而不是重新抛出它们,这ThreadAbortException可能会改变它应该如何工作。我不知道这是否是问题的一部分,但这只是一个想法。

另外,我注意到您将请求 URL(无论是什么)用作 return_to 和领域。我建议不要让领域成为任何请求 URL,因为 Google 使用定向身份,如果一个用户访问“login.aspx”,然后同一用户访问“Login.aspx”(仅大写不同),Google 会将其视为两个不同的站点并向您发送两个不同的身份。您必须确保“领域”在您的站点、大小写和所有方面始终相同。

至于间歇性重定向问题,我看不出有什么会导致这种情况的。日志表明正在发生重定向。尽管您再次捕获异常可能会导致此处失败。当重定向没有发生时你会得到什么

于 2010-03-07T21:21:51.167 回答