【问题标题】:Nearly all OpenId relying parties reject assertions from my dotNetOpenAuth backed provider几乎所有 OpenId 依赖方都拒绝来自我的 dotNetOpenAuth 支持的提供商的断言
【发布时间】:2011-04-19 23:49:03
【问题描述】:

构建一个 OpenId 提供程序时,我遇到了一个奇怪的问题,即只有 Stack Exchange 站点会接受它。

发现工作正常,并且查看我发送的日志流量(在我看来是什么)一个有效的回复。

很高兴,没有合规性测试*可以告诉我出了什么问题,大多数通过 OpenId 提供登录的网站也不会给您任何有用的错误消息。 Stack Overflow 提供了一些,但它似乎是唯一接受我的断言的依赖方,所以......是的。

无论如何,如果我尝试登录(例如)Typepad,我最终会重定向回类似的网址

https://www.typepad.com/secure/services/signin/openid?openid-check=1&archetype.quickreg=1&tos_locale=en_US&portal=typepad&oic.time=1303249620-9db5665031c9c6b36031&openid.claimed_id=https://example/user/8c481fb7-1b5c-4e50-86b5-xxxxxxxxx&openid.identity=https://example/user/8c481fb7-1b5c-4e50-86b5-xxxxxxxxx&openid.sig=hoaxQrsN4BBg6H8kp50NoQwpHmcO96BBe+jB3oOP2UA=&openid.signed=claimed_id,identity,assoc_handle,op_endpoint,return_to,response_nonce,ns.alias3,alias3.mode&openid.assoc_handle={634388464235195799}{oqMrOA==}{32}&openid.op_endpoint=https://example/openid/provider&openid.return_to=https://www.typepad.com/secure/services/signin/openid?openid-check=1&archetype.quickreg=1&tos_locale=en_US&portal=typepad&oic.time=1303249620-9db5665031c9c6b36031&openid.response_nonce=2011-04-19T21:47:03Z1aa4NZ48&openid.mode=id_res&openid.ns=http://specs.openid.net/auth/2.0&openid.ns.alias3=http://openid.net/srv/ax/1.0&openid.alias3.mode=fetch_response

为了(稍微)更容易阅读而中断:

openid-check=1
archetype.quickreg=1
tos_locale=en_US
portal=typepad
oic.time=1303249620-9db5665031c9c6b36031
openid.claimed_id=https://example/user/8c481fb7-1b5c-4e50-86b5-xxxxxxxxx
openid.identity=https://example/user/8c481fb7-1b5c-4e50-86b5-xxxxxxxxx
openid.sig=hoaxQrsN4BBg6H8kp50NoQwpHmcO96BBe+jB3oOP2UA=
openid.signed=claimed_id,identity,assoc_handle,op_endpoint,return_to,response_nonce,ns.alias3,alias3.mode
openid.assoc_handle={634388464235195799}{oqMrOA==}{32}
openid.op_endpoint=https://example/openid/provider
openid.return_to=https://www.typepad.com/secure/services/signin/openid?openid-check=1
archetype.quickreg=1
tos_locale=en_US
portal=typepad
oic.time=1303249620-9db5665031c9c6b36031
openid.response_nonce=2011-04-19T21:47:03Z1aa4NZ48
openid.mode=id_res
openid.ns=http://specs.openid.net/auth/2.0
openid.ns.alias3=http://openid.net/srv/ax/1.0
openid.alias3.mode=fetch_response

这是用户的 XRDS(因为发现似乎没问题)。

<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
xmlns:xrds="xri://$xrds"
xmlns:openid="http://openid.net/xmlns/1.0"
xmlns="xri://$xrd*($v*2.0)">
    <XRD>
      <Service priority="10">
        <Type>http://specs.openid.net/auth/2.0/signon</Type>
        <LocalID>https://example/user/8c481fb7-1b5c-4e50-86b5-xxxxxxxxx</LocalID>
        <Type>http://openid.net/extensions/sreg/1.1</Type>
        <Type>http://axschema.org/contact/email</Type>
        <URI>https://example/openid/provider</URI>
      </Service>

      <Service priority="20">
        <Type>http://openid.net/signon/1.0</Type>
        <Type>http://openid.net/extensions/sreg/1.1</Type>
        <Type>http://axschema.org/contact/email</Type>
        <URI>https://example/openid/provider</URI>
     </Service>
   </XRD>
</xrds:XRDS>

如果你深入TypePad的html,你会发现如下错误信息

<!-- Error Code: unexpected_url_redirect -->

...这就是我以它们为例的原因。有点没用,但它的东西。

这段代码很大程度上基于 dotNetOpenAuth 附带的示例 MVC 项目,SendAssertion 实现是我怀疑出现问题的地方。

protected ActionResult SendAssertion(IAuthenticationRequest authReq)
{
    // Not shown: redirect to a prompt if needed

    if (authReq.IsDirectedIdentity)
    {
        authReq.LocalIdentifier = Current.LoggedInUser.GetClaimedIdentifier();
    }
    if (!authReq.IsDelegatedIdentifier)
    {
        authReq.ClaimedIdentifier = authReq.LocalIdentifier;
    }

    authReq.IsAuthenticated = this.UserControlsIdentifier(authReq);

    if (authReq.IsAuthenticated.Value)
    {
        // User can setup an alias, but we don't actually want relying parties to store that since it can change over time
        authReq.ClaimedIdentifier = Current.LoggedInUser.GetClaimedIdentifier();
        authReq.LocalIdentifier = Current.LoggedInUser.GetClaimedIdentifier();

        // Not shown: responding to AX and SREG requests
    }

    var req = OpenIdProvider.PrepareResponse(authReq);
    var ret = req.AsActionResult();

    return ret;
}

抱歉,这是一个如此庞大的信息转储,但我没有太多工作要做,因此无法真正将其缩小到简单的范围。

所以我想最终的问题是......有什么想法我在这里做错了吗?

*好的,有sort of tests。但是没有说“啊哈,这坏了。”

【问题讨论】:

    标签: c# openid dotnetopenauth provider


    【解决方案1】:

    这里发现了一大堆其他陷阱,没有一个真正与 dotNetOpenAuth 相关。

    1. 这整件事是在强制使用 SSL,并重定向所有传入的 HTTP 流量。
      • ...除了所有 HTTP 流量的重定向是到 /,这破坏了发现
    2. HTML 发现被破坏。
      • 虽然理论上依赖方可以使用标头进行所有发现,但实际上几乎每个人都在某个时候开始解析 HTML。
    3. 一些依赖方修改了 OpenId 1.1 和 2.0 规范
      • 这与 #2 有点重叠,但一些依赖方非常乐意使用标头 (OpenId 2.0) 进行发现,然后在返回的 HTML 中寻找openid.server

    dotNetOpenAuth 作为(显然为数不多的)OpenId 库之一,可以在标头上完成整个 OpenId 的舞蹈,巧合。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-01
      • 1970-01-01
      • 2011-09-24
      • 2015-08-03
      • 2017-01-15
      • 1970-01-01
      相关资源
      最近更新 更多