【问题标题】:WCF Security - how to allow all callers to this url?WCF 安全 - 如何允许所有调用者访问此 url?
【发布时间】:2010-02-01 15:40:46
【问题描述】:

我有一个在 Windows 服务环境中自托管的 WCF 服务,可以通过 http 正常工作;通过 https 在运行 silverlight 应用程序(或仅在 IE 中打开页面)时,我无法在没有看到 Windows 登录提示的情况下访问一个 URL。我正在使用 IPolicyRetriever 接口来确保为 Silverlight 应用程序找到 ClientAccessPolicy.xml 文件。这工作正常。

相关服务定义了两个端点:

<service behaviorConfiguration="defaultBehavior" name="WCFServices.Scheduler">
<endpoint address="WCFServices/Scheduler/" binding="wsHttpBinding" bindingConfiguration="dBinding" contract="WCFServices.IScheduler" />
<endpoint address="" binding="webHttpBinding" contract="WCFServices.IPolicyRetriever" behaviorConfiguration="PolicyBehavior" bindingConfiguration="dBinding" />
    <host>
      <baseAddresses>
        <add baseAddress="https://myservername.org/" />
      </baseAddresses>
    </host>
  </service>

如果我访问https://myservername.org/,我会看到测试服务前端(带有指向 wsdl 的链接)。这将公开 Silverlight 应用程序用于下拉策略文件的根 IPolicyRetriever 实例。我可以在没有任何登录提示的情况下加载这个和其他公开 WCF 服务的 URL。但是,如果我在 IE 8 中转到 https://myservername.org/WCFServices/Scheduler/,我会收到 Windows 登录。如果我将服务和客户端上的安全设置重置为使用 http,我可以在没有登录提示的情况下转到后一个 url,并且 silverlight 应用程序按预期运行。我怀疑它与这个 WCF 服务有关,它是唯一一个定义了两个端点的服务(这个 Windows 服务托管了 5 个其他 WCF 服务,所有这些服务都只定义了 1 个端点)。我是否缺少一些授权规则?我不明白这是怎么回事,因为所有其他服务都在没有提示的情况下加载。

如果有任何帮助,我将不胜感激。我需要完整的https://myservername.org/WCFServices/Scheduler/ 来提供 WCF 服务而不要求登录。感谢您抽出宝贵时间阅读本文。

就安全性而言,我只有这个作为我的绑定:

<binding name="dBinding" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600">
      <security mode="Transport">
      </security>
    </binding>

【问题讨论】:

    标签: wcf security ssl authorization


    【解决方案1】:

    通过将这些行添加到我的安全绑定中解决了这个问题:

    <security mode="Transport">
       <transport clientCredentialType="None" proxyCredentialType="None"/>
    </security>
    

    ...但这导致了许多其他问题,感谢 WCF 日志记录,我能够处理所有这些问题。如果您在调试 WCF 服务时遇到 NOT FOUND (400) 错误,请不要相信。打开服务器端调试并仔细查看生成的日志文件——您将深入了解它。

    我还应该注意,我发现在 Web 浏览器中打开时返回错误请求 (400) 的第二个端点,这是 BY DESIGN。第一个端点将在其 wsdl 中列出所有其他端点,您仍然可以在代理生成工具中使用它们中的任何一个。如果您在尝试直接在浏览器中访问它们时遇到错误的请求,请不要担心。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-19
      • 2012-08-26
      • 1970-01-01
      • 2018-05-25
      • 2014-09-24
      • 2017-10-16
      • 2017-03-09
      • 2016-06-28
      相关资源
      最近更新 更多