我目前正在使用 Thinktecture Identity Server 版本 2.4 和 Windows Identity Foundation,以使用颁发的 token 来保护 .net 应用程序和服务器之间的通信。
我通过公开联合端点并使用 channel 工厂的“CreateChannelWithIssuedToken(SecurityToken)”方法来提供从问题请求返回的安全 token ,从而在标准 WCF NET TCP channel 上实现此操作。
然而,DuplexChannelFactory 似乎没有等效的方法允许我们传入实例上下文。我读过这篇文章 - http://msdn.microsoft.com/en-us/library/cc668765(v=vs.110).aspx – 其中详细介绍了如何创建双工绑定(bind)来实现此目的,但是在创建 channel 时,我看不到如何在 channel 上设置安全 token 。
有 IssuedToken 属性 - http://msdn.microsoft.com/en-us/library/system.servicemodel.description.clientcredentials.issuedtoken(v=vs.110).aspx - 在客户端凭据上,但它是只读的。
有没有人使用 TCP 消息安全模式在双工 channel 上实现联合安全,可以提供一些建议?
最佳答案
虽然手动创建 channel 并使用 STS 自行颁发 token 并没有错,但您可以利用 WIF 框架来为您完成此操作。
如果您通过配置将客户端配置为了解 STS,则框架将使用您在 channel 上设置的消息凭据检索 token 本身。然后,框架将在 channel 的凭据上设置“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 创建双工 channel 来处理联合安全性。
这样做的一个优点是您还可以设置自己的依赖方 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 本身没有公开在传递实例上下文时使用已发行 token 创建 channel 的方法。
希望这有帮助!
关于.net - WIF(使用 Thinktecture Identity Server)和双工 WCF channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24390433/