【问题标题】:WCF Service with Basic Auth over HTTP基于 HTTP 的具有基本身份验证的 WCF 服务
【发布时间】:2016-04-28 09:47:15
【问题描述】:

我正在开发一个 WCF 服务应用程序

  • 托管应用的服务器在域中
  • 使用基本身份验证授权客户端
  • 将用户名和密码映射到 AD 用户
  • HTTP
  • IIS 仅允许基本身份验证

我找到了 this MSDN article,但这是 HTTPS 的示例。

已经在 web.config 上进行了大量的挂载尝试,但我不知道如何配置。

任何帮助将不胜感激:)

谢谢

【问题讨论】:

  • 本教程与 HTTPS 相关,因为您不应通过 HTTP 传递凭据
  • 一般来说,是的。但在内部和受保护的网络中,HTTP 将是一种选择。

标签: c# wcf iis


【解决方案1】:

您可以将绑定更改为基本绑定而不是 wsBining

<basicHttpBinding>
        <binding name="BasicBinding" receiveTimeout="00:01:00"
          sendTimeout="00:01:00">
          <security mode="None">
            <transport clientCredentialType="Basic"/>
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </basicHttpBinding>

另一个选项,您可以将自定义用户验证方法(类)添加到您的应用程序并在其中创建您的身份验证

<serviceBehaviors>
<behavior name="ServiceBehaviour">
<useRequestHeadersForMetadataAddress />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication customCertificateValidatorType="WCFServices.clsCertificateValidator, App_Code/WCFServices" certificateValidationMode="Custom" revocationMode="NoCheck" />
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom"              customUserNamePasswordValidatorType="WCFServices.clsUserValidator, App_Code/WCFServices" />
<peer>
<peerAuthentication customCertificateValidatorType="WCFServices.clsCertificateValidator, App_Code/WCFServices" certificateValidationMode="Custom" revocationMode="NoCheck" />
<messageSenderAuthentication customCertificateValidatorType="WCFServices.clsCertificateValidator, App_Code/WCFServices" certificateValidationMode="Custom" revocationMode="NoCheck" />
</peer>
<issuedTokenAuthentication audienceUriMode="Never" customCertificateValidatorType="WCFServices.clsCertificateValidator, App_Code/WCFServices" certificateValidationMode="Custom" revocationMode="NoCheck" allowUntrustedRsaIssuers="true" />
</serviceCredentials>
</behavior>
</serviceBehaviors>

并且在这个类中如果需要停止用户抛出异常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    • 2011-06-10
    • 1970-01-01
    • 2011-08-17
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多