【问题标题】:WIF (using Thinktecture Identity Server) and Duplex WCF ChannelsWIF(使用 Thinktecture Identity Server)和双工 WCF 通道
【发布时间】:2014-08-14 22:33:36
【问题描述】:

我目前正在使用 Thinktecture Identity Server 2.4 版和 Windows Identity Foundation 来保护 .net 应用程序和使用已颁发令牌的服务器之间的通信。

我通过公开联合端点并使用通道工厂的“CreateChannelWithIssuedToken(SecurityToken)”方法来提供从发布请求返回的安全令牌,从而在标准 WCF NET TCP 通道上工作。

但是,对于 DuplexChannelFactory 似乎没有等效的方法允许我们传入实例上下文。我已经阅读了这篇文章 - http://msdn.microsoft.com/en-us/library/cc668765(v=vs.110).aspx - 其中详细介绍了如何创建双工绑定来实现这一点,但是在创建通道时,我看不到在通道上设置安全令牌的方法。

客户端凭据上有 IssuedToken 属性 - http://msdn.microsoft.com/en-us/library/system.servicemodel.description.clientcredentials.issuedtoken(v=vs.110).aspx,但它是只读的。

有没有人可以提供一些建议?

【问题讨论】:

    标签: .net wcf wif thinktecture-ident-server


    【解决方案1】:

    虽然手动创建通道并自己使用 STS 颁发令牌并没有错,但您可以利用 WIF 框架为您完成此操作。

    如果您通过配置将客户端配置为了解 STS,则框架将使用您在通道上设置的消息凭据检索令牌本身。然后,框架将在通道的凭据上设置“IssuedToken”属性。

    <ws2007HttpBinding>
        <binding name="ws">
          <security mode="TransportWithMessageCredential">
            <message establishSecurityContext="false"
              negotiateServiceCredential="true"
                     clientCredentialType="UserName" />
          </security>
        </binding>
    </ws2007HttpBinding>
    <customBinding>
        <binding name="FederationDuplexTcpMessageSecurityBinding">
          <reliableSession />
          <security authenticationMode="SecureConversation">
                <secureConversationBootstrap authenticationMode="IssuedTokenForSslNegotiated">
                    <issuedTokenParameters>
                        <issuer address="https://IdentityServer.domain/issue/wstrust/mixed/username" binding="ws2007HttpBinding" bindingConfiguration="ws" />
                        <issuerMetadata address="https://IdentityServer.domain/issue/wstrust/mex" />
                        <additionalRequestParameters>
                            <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                                <EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
                                  <Address>RelyingParty.com</Address>
                                </EndpointReference>
                            </wsp:AppliesTo>
                        </additionalRequestParameters>
                    </issuedTokenParameters>
                </secureConversationBootstrap>
            </security>
        <tcpTransport />
        </binding>
    </customBinding>
    

    上面的代码 sn-p 显示了如何使用 Secure Conversation 和 secureConversationBootstrap 创建双工通道来处理联合安全性。

    这样做的一个好处是您还可以设置自己的信赖方 URI,因此您不必使用 WCF 端点作为信赖方的标识符。

    您还需要设置联合服务行为以启用 WIF,如下所示(useIdentityConfiguration 很重要,因为它会打开 WIF):

    <behavior name="FederatedServiceBehaviour">
      <clientCredentials useIdentityConfiguration="true" supportInteractive="false" >
        <serviceCertificate/>
      </clientCredentials>
    </behavior>
    

    此处记录了设置服务端点:http://msdn.microsoft.com/en-us/library/cc668765(v=vs.110).aspx(在一定程度上)

    据我所知,DuplexChannelFactory 本身没有公开在通过实例上下文时使用已颁发令牌创建通道的方法。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-29
      • 1970-01-01
      • 2013-12-13
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 1970-01-01
      • 2014-05-28
      相关资源
      最近更新 更多