I am trying (desperately) to get a customer authentication provider working for my WCF service. So far I have the following code;
web.config
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNamespace.CustomUserNameValidator, MyNamespace" />
</serviceCredentials>
<wsHttpBinding>
<binding name="wsHttpBindingConfig" >
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
Custom authenticator class;
public class CustomUserNameValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
// have security details been provided?
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
// authenticate user
if (!(userName == "test" && password == "test"))
{
// This throws an informative fault to the client.
throw new FaultException("SecurityFailed");
}
}
}
Everything compiles ok, but when I use the WCF test client from visual studio to call a method called Ping (below), the custom authenticator never gets used. The Ping method just executes and any breakpoint I have in my CustomUserNameValidator class.
Why would this be? All help appreciated.