I have a RESTful WCF application that is hosted in a WebProject. I am using a HttpModule to authenticate a header on incoming requests, and if the header and URL are valid, I set both
System.Threading.Thread.CurrentPrincipal = myCustomPrincipal;
This works perfectly for GET requests, but when I do a POST, and check the Thread.CurrentPrincipal, it is set to an instance of the WindowsPrincipal class. I have read on a few blog posts that both the HttpContext.Current.User AND the Thread.CurrentPrincipal should both be set to the same IPrincipal object, but when I assign
HttpContext.Current.User = myCurrentPrincipal;
my service is never getting hit, and a 401 UnAuthorized message is being sent back that I never actually assigned.
note I am assigning these principals in my context_PostAuthorizeRequest method that I have attached to the context's like named handler.
Please help. What am I doing wrong? below is an example of my webconfig's httpModules configuration:
<httpModules>
<add name="PublicServiceSecurity" type="Company.PublicService.PublicServiceSecurity,PublicService" />
<add name="ErrorModule" type="Company.Web.ErrorModule,WebComponentLibrary" />
<add name="HbnSessionModule" type="Company.Web.HbnSessionModule,WebComponentLibrary" />
</httpModules>