【问题标题】:Custom UserName/Password authentication in IIS6IIS6 中的自定义用户名/密码身份验证
【发布时间】:2012-04-17 13:20:55
【问题描述】:

我在 IIS6 中托管了一个 WCF 服务。我正在尝试使用传输级安全性设置自定义用户名/密码身份验证。我已经设置了一个测试证书并让一个客户端通过 SSL 连接而没有指定身份验证,即:

      <security mode="Transport">
        <transport clientCredentialType="Basic" />
      </security>

我已经设置了一个具有消息安全性和客户端凭据类型“用户名”的自定义验证器,但我现在想将它与传输级安全性结合起来。当我设置了 web.config 时,当我尝试查看 WSDL 时,出现错误: “此服务的安全设置需要‘基本’身份验证,但托管此服务的 IIS 应用程序未启用它。”

这是我的 web.config 的重要部分:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="UserNameBinding">
          <security mode="Transport">
            <transport clientCredentialType="Basic" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="ServiceAuthenticationBehavior"
        name="Service.WebServices.MyService">
        <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
          name="mexBinding" contract="IMetadataExchange" />
        <endpoint binding="wsHttpBinding" bindingConfiguration="UserNameBinding"
          name="wsHttpBindingWithAuth" contract="Service.WebServices.IMyService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceAuthenticationBehavior">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceCredentials>
            <serviceCertificate findValue="TestCert01" storeLocation="LocalMachine"
              storeName="TrustedPeople" x509FindType="FindBySubjectName" />
            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="Service.WebServices.ClientCredentialsValidator, Service.WebServices" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>

我应该在 IIS6 中设置什么来启用它吗? 在 IIS 中,我一开始是启用了“启用匿名访问”选项。我还尝试启用“基本身份验证(密码以明文形式发送)”复选框,但没有成功。

【问题讨论】:

  • 你试过 anon [off] 和 basic [on] 一起吗?做这样的事情你永远不确定 iisreset 是否有帮助,所以我还是做一个

标签: wcf iis-6 transport-security


【解决方案1】:

这篇文章似乎暗示 Basic 仅适用于 Windows 帐户,并带有第 3 方解决方案...

Basic Authentication with WCF REST service to something other than windows accounts?

我自己也来过这里,最后选择了 1-legged openauth,效果很好。

编辑 这篇文章很好地让我找到了解决方案http://www.cleancode.co.nz/blog/523/oauth-dot-net

值得一提的是 1 和 2 腿 OAuth 之间的差异。 1-leg 是客户端和服务都知道客户端帐户名的客户端密码(密码)的地方,该帐户名用于加密和解密身份验证请求(所有这些都添加到查询字符串中)。对于 2-legged,这是由 google、facebook 等第三方生成的。

【讨论】:

  • 你能描述一下“1-legged openauth”吗?不确定这是什么。听起来我正在使用消息级别安全性进行的自定义身份验证不起作用。我想我可以像以前一样在消息传输上进行传输 + 消息安全、匿名 SSL 和自定义身份验证?
  • 此链接暗示您可以使用 SSL 进行自定义用户/通过身份验证。无法解决上述问题。 leastprivilege.com/…
猜你喜欢
  • 2021-06-30
  • 1970-01-01
  • 2011-10-23
  • 2020-10-10
  • 1970-01-01
  • 2012-11-13
  • 1970-01-01
  • 1970-01-01
  • 2020-12-02
相关资源
最近更新 更多