Manipulating an HTTP header in WCF before HTTP authentication in HttpBinding

This refers to this issue.

I host this WCF service on a user host. IIS is not an option.

Is there a way to insert the HTTP "Authenticate" header on the server stack (if one is missing) at an early stage of the request process - so that the default user can be transferred to the authentication system / authorization process that I have for anonymous requests?

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

I'm sure I can do this with a custom BindingElement or by extending WebHttpBinding, but any examples or recommendations would be welcome. I cannot find examples of early header manipulations (preauthentication) in WCF.

+3
source share
2 answers

By implementing IDispatchMessageInspector, you can connect to the server side of the pipeline; and manipulate messages.

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

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

+1
source

I would print this, but there are many. So here is a good recommendation.

The Avner Kashtan blog post tells me what you think you're looking for. Hope this helps!

WCF

-1

Source: https://habr.com/ru/post/1698418/


All Articles