【问题标题】:Web Services + Windows Authentication QuestionsWeb 服务 + Windows 身份验证问题
【发布时间】:2012-02-28 22:49:22
【问题描述】:

我有一个使用表单身份验证的 Web 项目。我有支持 Windows 身份验证的新要求。这个项目包含两个 Web 服务,一个用于 Silverlight 页面 (MapService),另一个用于各种 ajax 调用 (AsyncService) 现在一切正常,但有两件事我不太明白。

Web.Config 中的配置如下:

<bindings>
      <basicHttpBinding>
        <binding name="WindowsClientOverTcp">
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="AsyncWindowsOverTcp">
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service name="Project.MapService.MapService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="WindowsClientOverTcp" name="WindowsClientOverTcp" contract="Project.MapService.MapService" />
      </service>
      <service name="Project.AsyncService.AsyncService">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="AsyncWindowsOverTcp" name="AsyncWindowsOverTcp" behaviorConfiguration="Project.AsyncService.AsyncServiceAspNetAjaxBehavior" contract="Project.AsyncService.AsyncService" />
      </service>
  </services>
  1. 有了这个设置,基本上需要使用 SSL 吗?我已经读过将传输安全性与 Windows ClientCredentialType 一起使用会强制使用 HTTPS 端点,这似乎是这种情况。我只是想知道向客户或管理层一般性声明“如果他们想要 Windows 身份验证,我们的应用程序必须使用 https”是否合理

  2. 对于 AsyncService,它显然需要来自客户端的 Windows 凭据,但我根本不需要更改我的 JS/Ajax 代码,它仍然可以正常工作。客户端浏览器有什么魔力吗?由于没有客户端配置,我不知道调用是如何进行身份验证的。

谢谢

【问题讨论】:

    标签: asp.net wcf web-services windows-authentication


    【解决方案1】:
    1. 不,您不需要 HTTPS 即可使用 Windows 身份验证。您确实需要将 IIS 配置为使用集成安全性,如果调用者来自同一个 Windows 域或受信任的 Windows 域,则 IIS 将能够对用户进行身份验证。

    2. 如果浏览器正在使用您的 Windows 域或受信任域的凭据运行,并且您的 Web 应用程序配置为使用 Windows 身份验证,则浏览器会将其运行时使用的凭据包含在 IIS 中。

    编辑: 一些额外的信息。如果您使用上述 BasicHttpBinding 并希望对其进行保护,则一个不错的选择是使用 TransportWithMessageCredential 作为您的安全模式。这使用传输层 (HTTPS) 保护消息并在消息中包含 Windows 凭据。另请参阅http://msdn.microsoft.com/en-us/library/ms731925.aspx 上的“编程 WCF 安全性”。

    【讨论】:

    • 关于 1. 不使用 https 使用 Windows 身份验证是否不安全?
    • 不,不是。我建议使用 NTLM 协商,然后肯定不会通过网络发送密码。另请参阅technet.microsoft.com/en-us/library/cc754628(WS.10).aspx
    • 好吧,现在我很困惑。 OP 中的设置导致服务仅存在于 https://..... 特别是,传输安全模式不适用于 http。
    • 这似乎支持我所说的stackoverflow.com/questions/4481131/…
    • 当然,传输安全意味着 IP 层的安全——即 HTTPS(HTTPS = HTTP + 加扰 IP 层)。我对 (1) 的回答驳斥了您提到的 “如果他们想要 Windows 身份验证,我们的应用程序必须使用 https” 声明。
    猜你喜欢
    • 2012-04-18
    • 2016-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多