【问题标题】:wcf wsHttpBinding and disabling anonymous accesswcf wsHttpBinding 和禁用匿名访问
【发布时间】:2010-09-18 16:49:35
【问题描述】:

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

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

【问题讨论】:

    标签: wcf iis-6


    【解决方案1】:

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

    • 启用匿名访问
    • 使用 创建一个 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>
    

    【讨论】:

      【解决方案2】:

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

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

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多