Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Header to WCF RequestSecurityToken Message

I'm attempting to set up a client (Web Application) and service (WCF Service) that will communicate using a WSHttpBinding. It appears that in order to use this binding the client sends preliminary messages to set up the channel.

Between the client and the service exists a service bus which is routing on a custom header. The message, when using BasicHttpBinding security, routes without issue.

My question is: Is there any way to add the same custom header to the preliminary RequestSecurityToken message?

Thank you in advance.

like image 433
hunda27 Avatar asked Nov 10 '22 11:11

hunda27


1 Answers

This has been resolved.

Unfortunately, according to the MSDN documentation, a service using WCF transport security cannot go through a router, nor should either, service nor client, be located on the internet (https://msdn.microsoft.com/en-us/library/ff648863.aspx#TransportSecurity).

We wanted to violate both 'principles'.

So in order to cut down the messages, from five calls and responses to one, we switched to Message Security and turned off EstablishSecurityContext and NegotiateServiceCredential. - This had to be done on both the Service and Client configuration settings.

In addition to this, a noteworthy tip may be that, in order to point the service to our service bus, we changed theClientViaBehavior of the service on the Client Side.

Turn off EstablishContext and NegotiateServiceCredential:

WSHttpBinding binding = new WSHttpBinding();

binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.EstablishSecurityContext = false;
binding.Security.Message.NegotiateServiceCredential = false;

Point client to Service Bus:

serviceClient.Endpoint.EndpointBehaviors.Add(new ClientViaBehavior(new Uri("http://url/WCFService/ServiceName.svc")));
like image 104
hunda27 Avatar answered Nov 14 '22 22:11

hunda27