5

http://blogs.msdn.com/drnick/archive/2007/03/23/preventing-anonymous-access.aspx

有人可以澄清是否可以在 WCF 中使用 wsHttpBinding 并在 IIS 中禁用匿名访问而不需要传输(ssl)或消息安全性?

4

2 回答 2

3

你是对的,在你描述 wsHttpBinding 的场景中,afaik 要求我们使用内部 WCF 安全堆栈。所以你通常会做的是

  • 启用匿名访问
  • 使用 <serviceAuthorization principalPermissionMode="UseWindowsGroups" /> 创建一个 serviceBehavior
  • 使用 PrincipalPermissionAttribute 注释服务方法的每个具体实现,这是一个非常强大的工具,具有许多不同的选项来控制访问

这对您来说是一个可以接受的解决方案,还是有其他需要考虑的事情?

基本示例:

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>
于 2008-11-05T17:13:04.757 回答
0

我们要使用windows集成安全。如果您在 IIS 中禁用匿名访问并只允许窗口,则您似乎无法在不使用某些安全模式(例如需要 ssl 的 transprot 安全)的情况下将 wsHttpBinding 与 WCF 一起使用。

我们只想使用 windows 身份验证,不一定要使用 ssl 来保证传输安全。

我有点惊讶这不可能开箱即用(我的链接似乎证实了这一点),因为这对于实习生申请来说似乎很常见。

我们不想降级到仅支持 Windows 身份验证的 basicHttpBinding。

于 2008-10-24T01:01:01.893 回答