I’m working on custom WCF authentication and authorization and found some articles about UserNamePasswordValidator and ServiceAuthorizationManager.
I also found clues about using a custom System.ServiceModel.ServiceAuthenticationManager (dead link ), but msdn does not tell a lot about it ( http://msdn.microsoft.com/en-us/library/system.servicemodel.serviceauthenticationmanager.aspx ).
So here I am: anyone knows more about ServiceAuthenticationManager ?
In general, how would you set up custom WCF authentication ?
You’re right, the documentation on this is no help at all.
The way I have used this class is as follows. Override the Authenticate() method to:
You can’t just set the thread principal at this point as it is changed later on by WCF.
The code in the ServiceAuthenticationManager.Authenticate() methods would look something like this:
Then you add a custom authorization policy that
The code in the IAuthorizationPolicy() method would look like
In the service behaviour configuration, you need to set principalPermissionMode=”Custom” in order for WCF to set the IPrincipal as the principal on the executing thread for the actual service operation invocation.