Web服务+ Windows身份验证问题

时间:2012-02-07 13:52:11

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

我有一个曾经使用表单身份验证的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的Transport Security会强制使用HTTPS端点,这似乎就是这种情况。我只想知道向客户或管理层说明一般情况是否合理“如果他们想要Windows身份验证,我们的应用程序必须使用https”

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

  3. 由于

1 个答案:

答案 0 :(得分:3)

  1. 不,您不需要HTTPS才能使用Windows身份验证。您需要将IIS配置为使用集成安全性,如果调用者来自同一Windows域或受信任的Windows域,则IIS将能够对用户进行身份验证。

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

  3. 修改 一些额外的信息。如果你正在使用如上所述的BasicHttpBinding并想要保护它,一个很好的选择是使用TransportWithMessageCredential作为你的安全模式。这将使用传输层(HTTPS)保护邮件,并在邮件中包含Windows凭据。另请参阅http://msdn.microsoft.com/en-us/library/ms731925.aspx上的“编程WCF安全性”。