asp.net - 托管 WCF 应用程序 IIS 身份验证

标签 asp.net wcf authentication iis

我已经编写了一个 WCF 服务并需要托管它,我可以在 IIS 中托管或自行托管,并且我想通过在下面的 web.config 文件中设置绑定(bind)来使用 Windows 身份验证:

<bindings>
  <netHttpBinding>
    <binding>
      <security mode="Transport">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </netHttpBinding>
</bindings>

我试图了解 IIS 在身份验证方面正在做什么并将其传递给 Web 应用程序,具体来说:

  • 如果我在 IIS 中托管,我是否需要为该服务器启用 Windows 身份验证 IIS 管理设置中的服务站点?

  • 如果是这样,为什么服务不能简单地执行Windows身份验证 就像自主机一样从配置文件中 - 为什么 IIS 需要参与?自托管 除了 web.config 文件之外不需要任何其他内容。

  • IIS 中有没有办法让应用程序(ASP MVC、WCF 等) 处理身份验证类型(表单、Windows 身份验证、基本) 而不启用它们(原因是如果站点未配置 正确地,如果代码处理,这可能是一个安全风险 身份验证,然后安全意图变得明确)?

最佳答案

If I host in IIS, do I need to enable Windows Authentication for the service site in IIS administration settings?

是的。

If so, why can the service not perform Windows Authentication simply from the config file just like self host - why does IIS need to get involved? Self host doesn't need anything other than the web.config file.

因为 Windows 身份验证是一项功能。安装后,您可以为特定站点或服务启用或禁用此功能。请注意,Windows Vista® 和 Windows® 7 的家庭版或入门版不支持 Windows 身份验证。

IIS WCF 主机实现与 SelfHost 实现完全不同。并且需要 Windows 身份验证功能来获取诸如设置安全上下文身份 (ServiceSecurityContext.Current.WindowsIdentity) 或模拟调用者 ( http://msdn.microsoft.com/en-us/library/ms788971(v=vs.110).aspx ) 之类的内容才能在 IIS WCF 主机上工作。

Is there a way in IIS for the application (ASP MVC, WCF etc) to handle authentication types (Forms, Windows Authentication, Basic) without enabling them (reason being if the site is not configured correctly it could be a security risk, if the code handles authentication then the security intent becomes explicit)?

您必须先安装该功能才能使用它。不存在安全风险,因为它根本行不通。例如,如果您将站点或服务配置为使用 Windows 身份验证,则匿名用户将无法访问该站点或服务。

关于asp.net - 托管 WCF 应用程序 IIS 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24983967/

相关文章:

jquery - jquery调用wcf服务时获取异常信息

javascript - MSAL Angular 7 : Password Reset Implementation

javascript - 在javascript中抓取文本框

c# - 从 Web 应用程序访问注册表

c# - 当它在asp.net中没有图像时如何使图像框不可见

c# - 如果您限制输入的最大长度,是否存在验证文本框输入的安全原因?

wcf - WSHttp 绑定(bind)和 ReliableSession/MaxRetryCount

c# - WCF WebInvoke POST - 方法不允许错误

security - 如何在 Tomcat 5.5 中实现加盐密码

java - Spring Security 记住我身份验证