Sam*_*ght 9 .net wcf wif thinktecture-ident-server
我目前正在使用Thinktecture Identity Server版本2.4和Windows Identity Foundation来保护.net应用程序和服务器之间的通信,使用已发布的令牌.
我通过公开联合端点并使用通道工厂的"CreateChannelWithIssuedToken(SecurityToken)"方法来提供从Issue请求返回的安全令牌,从而在标准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消息安全模式在双工通道上实现联邦安全性?
尽管手动创建通道并使用 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>
Run Code Online (Sandbox Code Playgroud)
上面的代码片段显示了如何使用安全对话和 secureConversationBootstrap 创建双工通道来处理联合安全性。
这样做的优点之一是您还可以设置自己的依赖方 URI,因此您不必使用 WCF 端点作为依赖方的标识符。
您还需要设置联合服务行为以启用 WIF,如下所示(useIdentityConfiguration 很重要,因为它会打开 WIF):
<behavior name="FederatedServiceBehaviour">
<clientCredentials useIdentityConfiguration="true" supportInteractive="false" >
<serviceCertificate/>
</clientCredentials>
</behavior>
Run Code Online (Sandbox Code Playgroud)
设置服务端点记录如下:http://msdn.microsoft.com/en-us/library/cc668765 (v=vs.110).aspx(在某种程度上)
据我所知,DuplexChannelFactory 本身没有公开在传递实例上下文时使用已发行令牌创建通道的方法。
希望这可以帮助!