2014-06-24 27 views
9

我目前使用Thinktecture Identity Server版本2.4和Windows标识基础来保护.net应用程序和使用发行令牌的服务器之间的通信。WIF(使用Thinktecture Identity Server)和双工WCF频道

我通过公开一个联合端点并使用通道工厂的“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 - 在客户端凭据,但它是只读的。

有没有人通过使用TCP消息安全模式的双工通道实现联合安全,谁可以提供一些建议?

回答

3

尽管手动创建通道并使用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> 

上面的代码片段展示了如何使用安全对话和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本身公开没有方法创建频道与发出的令牌,而通过实例上下文。

希望这会有所帮助!

相关问题