Pablo M. Cibraro (aka Cibrax)

My thoughts on Web Services and .NET development

News

Pablo Cibraro's VisualCV

Blogs

Personal

Programming

Federation Over TCP With WCF

One of the discussions that we had during the last summit with the rest of "Connected Systems" MVPs was the possibility of supporting a Federation Scenario over TCP in WCF. For many of us that scenario was possible in theory, but unfortunately no documentation or samples existed to support it. In fact, WCF only comes with pre-built binding for federation scenarios, the "WsFederationHttpBinding" binding, which is completely tied to Http.

For that reason, I decided to give it a shot and try to manipulate some custom bindings to use tcp instead of the common used http transport. One curios thing about TCP is that it requires security sessions (SecureConversation with requireSecurityContextCancellation equals to "True") in order to work fine. If you do not configure the binding with those security settings, WCF will throw a nice error message saying that the order of the binding elements is not correct. At the beginning I did not configure it in that way, and it took me sometime to figure out what the problem was, I would save some time with a better error description. 

The resulting bindings for client, STS and the sample service were the following (In this sample, the client is authenticating against the service with a client certificate).

1. Client

<bindings>

  <customBinding>

    <binding name="STSBinding">

      <security authenticationMode="SecureConversation" requireSecurityContextCancellation="true">

        <secureConversationBootstrap authenticationMode="MutualCertificate"/>

      </security>

      <binaryMessageEncoding/>

      <tcpTransport />

    </binding>

    <binding name="ServiceBinding">

       <security authenticationMode="SecureConversation">

         <secureConversationBootstrap authenticationMode="IssuedToken">

           <issuedTokenParameters tokenType=http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1>

             <issuer address="net.tcp://localhost:8000/sts" bindingConfiguration="STSBinding" binding="customBinding">

               <identity>

                 <dns value="STSAuthority"/> <!--Sample Cert for the STS -->

               </identity>

             </issuer>

           </issuedTokenParameters>

        </secureConversationBootstrap>

      </security>

      <binaryMessageEncoding/>

      <tcpTransport />

    </binding>

  </customBinding>

</bindings>

2. STS

<bindings>

  <customBinding>

    <binding name="MutualCertificateBinding">

      <security authenticationMode="SecureConversation" requireSecurityContextCancellation="true">

        <secureConversationBootstrap authenticationMode="MutualCertificate"/>

      </security>

      <binaryMessageEncoding/>

      <tcpTransport />

    </binding>    </customBinding>

</bindings>

3. Sample Service

<bindings>

  <customBinding>

    <binding name="SampleService">

      <security authenticationMode="SecureConversation" requireSecurityContextCancellation="true">

        <secureConversationBootstrap authenticationMode="IssuedToken">

           <issuedTokenParameters tokenType=http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1>

        </issuedTokenParameters>

       </secureConversationBootstrap>

     </security>

     <binaryMessageEncoding/>

    <tcpTransport />

   </binding>

  </customBinding>

</bindings>

It is not required that the STS and service use both TCP transport for communicating with the client, which is a cool thing because now we can combine different transports in a whole federation scenario. For instance, we can have a Http communication between the client and the STS, and a TCP communication with between the client and the final service.

The complete sample is available to download from here.

 

Comments

dominick said:

cool!

# April 22, 2008 1:09 AM

Milan said:

How can I add "TokenRequestParameters" to abinding, when I use NetTcpBinding instead of WsHttpFederationBinding?

# April 28, 2008 11:05 AM

Sam Gentile said:

CLR/DLR/Popfly IronPython 2.0 Beta 2 Popfly Game Creator Windows PowerShell V2 CTP2 SOA/WCF Weekly SOA

# May 2, 2008 10:51 PM

zahmed said:

I have written a related post to make this work in a TCP streaming scenario.

www.zamd.net/.../FederationOverTCPStreaming.aspx

# July 3, 2008 10:16 PM

Scott said:

Can this extrapolated to deal with MSMQ backed WCF Services by simply changing the transport?

# October 30, 2008 11:33 AM

cibrax said:

Hi Scott,

I haven't tried. I am not sure if it is going to work due to the fact that MSMQ is a one way channel.

Regards,

Pablo.

# October 30, 2008 11:43 AM

Scott said:

Pablo,

It does indeed work.  I floundered for a couple of days to get the proper custom binding configuration and trying to stop it from popping up CardSpace dialogs, but I finally got something to work.

Not sure if the xml will display properly here in this comment, I'm putting code tags around it incase that is supported.

<CODE>

<binding name="queBinding">

<security authenticationMode="IssuedToken" requireSecurityContextCancellation="true">

<issuedTokenParameters keyType="SymmetricKey"  tokenType="docs.oasis-open.org/.../oasis-wss-saml-token-profile-1.1

<issuer address ="localhost/.../windows" binding ="wsHttpBinding" />

</issuedTokenParameters>

</security>

<textMessageEncoding messageVersion="Soap11WSAddressing10"/>

<msmqTransport exactlyOnce ="true" durable="true">

<msmqTransportSecurity msmqAuthenticationMode ="None" msmqProtectionLevel ="None"/>

</msmqTransport>

</binding>

</CODE>

# November 3, 2008 1:39 PM

cibrax said:

Hi Scott,

That's pretty cool. So you could make it work with Msmq between the client and the final service ?.

Thanks

Pablo.

# November 3, 2008 2:37 PM

John said:

Hey Pablo,

So, in a real world scenario, how are you passing other types of client credentials to the service, such as a credential that would identify an individual user instead of the certificate identity?

Thanks!

# March 31, 2009 5:36 AM

Yaniv said:

Hey Pablo,

Thanks for the example.

I tried to implement your solution on MS litware's solution.

It is little more complicated because the STS is seperated into

Authentication STS and Authorization STS, and its based on

Username password validation.

Do you have an example using UserName for Client Credential Type?

Thanks

# May 24, 2009 8:04 AM

persa said:

Hi!

I have tried to adapt your sample solution to use http for communication with an STS, in my case the StarterSTS from CodePlex. It seems hard to get the configuration right, you don't happen to have an updated sample using the WIF (Geneva) SDK Beta 2?

/Per

# September 24, 2009 10:27 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)