I have developed REST WCF and set binding following way in web.config
<bindings>
<webHttpBinding>
<binding name="secureBasic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None" />
</security>
</binding>
&开发者_JS百科lt;/webHttpBinding>
</bindings>
<serviceBehaviors>
<behavior name="ServiceBehaviour" >
<serviceCredentials>
<userNameAuthentication customUserNamePasswordValidatorType="RestService.CustomUsernamePasswordValidator, RestService"
userNamePasswordValidationMode="Custom" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
And in CustomUsernamePasswordValidator.cs file i have authenticate user by following way
namespace RestService
{
public class CustomUsernamePasswordValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (!AuthenticateUser(userName, password))
throw new SecurityTokenValidationException("Invalid Username or Password");
}
private bool AuthenticateUser(string userName, string password)
{
if (userName == "myaddon" && password == "mypassword")
{
return true;
}
else
return false;
}
}
}
Now problem is that it is running nice when i will use this service from same project but confused that why this call would not occurred for validation?
Also when i test my heroku manifest addon file from ruby commnad propmpt it give me error of Failed Authentication !! I think this is issue of my REST WCF Application.
Please anyone can help me to solve this issue if anyone know very well about WCF and authentication.
Thanks Arun.
Finally i have handle custom authentication using WebOperationContext directly and skip the Web.Config settings.
精彩评论