【发布时间】:2021-08-15 03:24:48
【问题描述】:
我在 IIS 10 中托管了一个独立的 WCF 服务。我想将对该 Web 服务的访问限制为一组选定的用户。通过在 IIS 中执行以下操作,我能够为 Web 应用程序执行此操作:
- 身份验证:仅 Windows 身份验证(禁用匿名身份验证)
- 授权规则:允许预定义的组(即角色)
但是,当我为 Web 服务执行上述步骤并在其 web.config 中更改 clientCredentialType="Windows" 时,它仍然允许域中的任何用户与其交谈。我错过了一些明显的东西吗?在配置授权方面,Web 服务的功能是否与 Web 应用程序不同?鉴于我的设置,我希望只有 MyTestGroup 中的用户能够与 Web 服务对话,而所有其他用户都会得到 401 - Unauthorized。
顺便说一句,我尝试设置“拒绝所有人”规则,但域用户仍然可以与 Web 服务对话,所以我觉得授权设置没有以某种方式生效。寻找对此的任何见解。
以下是相关的 web.config 内容:
<system.serviceModel>
<services>
<service name="StudyManagement.StudyManagement">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" name="StudyManagement" contract="StudyManagement.IStudyManagement" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="1048576" />
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" minFreeMemoryPercentageToActivateService="0" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="false" />
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="" roles="MyAllowGroup" />
</authorization>
</security>
</system.webServer>
【问题讨论】:
-
额外的侦查发现了另一个 Stack Overflow 问题,该问题似乎与我的相同,或者至少在性质上非常相似。几年前问过,没有任何有用的回答。不会让我对寻求洞察力抱有希望! stackoverflow.com/questions/39829002/…
标签: wcf authorization web-config windows-authentication iis-10