【发布时间】:2012-10-10 21:04:11
【问题描述】:
我正在尝试将我的 WCF 服务配置为通过 HTTP 和我的 ASP.NET 开发服务器使用自定义用户名验证器。以下是 serviceModel 的各个部分...
<basicHttpBinding>
<binding name="Authentication" >
<security mode="TransportCredentialOnly" >
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
<service behaviorConfiguration="ApiBehavior" name="CriticalWatch.AuthenticationAPI.AuthenticationAPI">
<endpoint address="/" binding="basicHttpBinding" bindingConfiguration="AuthenticationBinding" name="Authentication" contract="CriticalWatch.AuthenticationAPI.IAuthenticationAPI" />
</service>
然后我对验证器有一个行为...
<serviceBehaviors>
<behavior name="ApiBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Service.CustomUserNameValidator, MyService" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
我的 CustomUserNameValidator 继承自 UserNamePasswordValidator。验证器类被实例化,但从未调用 Validate 方法。另外,客户端可以在不传递任何用户名和密码的情况下调用该方法。
我错过了什么?
此时,我想要一个不需要 HTTPS 的解决方案。我想依赖随消息传递的用户名和密码。
【问题讨论】:
-
我刚刚发现这篇帖子,stackoverflow.com/questions/8259724/…,听起来很相似,但又有些不同。它指的是 HTTPS 和 IIS,而我是 HTTP 和 Dev Server。虽然,我希望它也能在 IIS 下工作,所以这可能适用。需要试验,对此有何想法?