Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manipulating the HTTP header in WCF before HTTP authentication in HttpBinding

This is in relation to this question

I am hosting this WCF service in a custom service host. IIS is not an option.

Is there a way to inject an HTTP "Authenticate" header in the server stack (if it's missing) early on in the request process - such that a default user can be passed into the authentication/authorization process that I have in place for anonymous requests?

I need the SERVER to inject this on the receiving end - before further WCF processing...

I'm pretty sure I can do this with a custom BindingElement, or by extending the WebHttpBinding, but any examples or guidance would be greatly appreciated. I can't find any examples of early header manipulation (pre authentication) in WCF.

like image 446
TheSoftwareJedi Avatar asked Apr 08 '26 19:04

TheSoftwareJedi


1 Answers

By implementing an IDispatchMessageInspector you can plug into the pipeline server side; and manipulate messages.

In the AfterReceiveRequest method you can add to Request.Headers quite happily.

Wrap it with a behaviour attribute and apply it to your service.

like image 131
blowdart Avatar answered Apr 11 '26 14:04

blowdart