簡體   English   中英

WIF(使用Thinktecture Identity Server)和雙工WCF通道

[英]WIF (using Thinktecture Identity Server) and Duplex WCF Channels

我目前正在使用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>

上面的代碼片段顯示了如何使用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/cc668765v = vs.110.aspx (某種程度)

據我所知,DuplexChannelFactory本身沒有公開在通過實例上下文時創建具有已發布令牌的通道的方法。

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM