JustAMartin
JustAMartin

Reputation: 13733

Custom authentication, authorization and session for WCF

I have read about various implementations of authentication and authorization for WCF, starting from reusing some built in .NET and WCF features and ending with completely custom implementations.

But there are so many factors to take into account, so I'm confused about how to implement it for my intranet business application project.

Here is what I need: - WCF .NET 4.5 services will be hosted in IIS 7 or newer.

Which would be the most straightforward way to implement my auth routines? Should I use a custom binding? Custom behavior? Some kind of a built-in request event handler (which one exactly, and will they work if ASP.NET compatibility is disabled)? Authorization policy (seems a bit overkill because I won't be using most of its built-in features anyway)? Something else?

Upvotes: 0

Views: 1213

Answers (1)

Jeric Cantos
Jeric Cantos

Reputation: 278

You can try making use of Message Inspectors. Your session ID can be passed like a token through SOAP or HTTP Headers and will be inspected by WCF through your defined behavior before it executes the actual service operation.

You can check the articles here and here, particularly focusing on the IDispatchMessageInspector interface which offers the "AfterReceiveRequest" and "BeforeReceiveReply" methods.

Upvotes: 1

Related Questions