http://blogs.msdn.com/drnick/archive/2007/03/23/preventing-anonymous-access.aspx
有人可以澄清是否可以在 WCF 中使用 wsHttpBinding 并在不需要传输 (ssl) 或消息安全性的情况下禁用 IIS 中的匿名访问?
最佳答案
你是对的,afaik 在你描述的场景中 wsHttpBinding 要求我们使用内部 WCF 安全堆栈。所以你通常会做的是
这对您来说是一个可以接受的解决方案吗,或者还有其他需要考虑的事情吗?
基本示例:
public class TestService : ITestService
{
[PrincipalPermission(SecurityAction.Demand, Name = "testdomain\\administrator")]
public string DoWork()
{
return "Hello World " + Thread.CurrentPrincipal.Identity.Name;
}
}
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfSecurity.Www.TestServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceAuthorization principalPermissionMode="UseWindowsGroups" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="WcfSecurity.Www.TestServiceBehavior" name="WcfSecurity.Www.TestService">
<endpoint address="" binding="wsHttpBinding" contract="WcfSecurity.Www.ITestService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
关于wcf wsHttpBinding 和禁用匿名访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/228268/