Setting Identifier / Principal from MessageInspector to WCF

I am developing a WCF service that gets user credentials in a SOAP header. These credentials are read on the server side using MessageInspector. So far so good.

I want to set Thread.CurrentPrincipal for a custom principal (CustomPrincipal), but when I do this from MessageInspector, it becomes overridden by the time the service starts. When is the best time to set up a principal? What is the best way to transfer the principal, ID, or credentials from the inspector to this place?

+4
source share
3 answers

Rory has a message that describes a solution to this problem. http://www.neovolve.com/2008/04/07/wcf-security-getting-the-password-of-the-user/

0
source

Just note that if you host WCF services in IIS, you can enable aspnet compatibility behavior for your service. In this case, you can install HttpConext.Current.User for the user you just authenticated in your message inspector.

0
source

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


All Articles