【问题标题】:Allow access to windows service hosted WCF services only to one ASP MVC app in Azure仅允许 Azure 中的一个 ASP MVC 应用访问 Windows 服务托管的 WCF 服务
【发布时间】:2016-05-24 13:33:19
【问题描述】:
我有:
如何使 WCF 服务只能由 ASP MVC 应用程序访问?换句话说:只允许 ASP MVC 应用程序使用我的 WCF 服务。
很抱歉没有任何代码示例,但 WCF 安全性是一个非常大的话题,我发现的大多数示例仅涵盖 Windows 域 WCF 授权。没有什么特别针对我的情况。
非常感谢
【问题讨论】:
标签:
c#
asp.net-mvc
wcf
azure
【解决方案1】:
我找到了解决问题的方法。
在从ClientBase<T> 派生的 WCF 代理类中,我在运行 WCF 服务的 PC 中使用用户凭据覆盖了基本构造函数。
base.ClientCredentials.Windows.ClientCredential.UserName = "localhost\\myUsername";
base.ClientCredentials.Windows.ClientCredential.Password = "myPassword";
在 WCF 服务 app.config 中:
<security mode="Transport">
<message clientCredentialType="Windows" />
</security>
所以现在我的服务需要来自任何消费者的凭据。