【问题标题】:Add .Net Core 2 API to .Net 4.6 API Webfarm that uses machineKey encryption将 .Net Core 2 API 添加到使用 machineKey 加密的 .Net 4.6 API Webfarm
【发布时间】:2019-04-23 05:12:50
【问题描述】:

我们有一个由 .Net 4.6.1 Web API 组成的微服务架构,它们都在其 web.config 中使用相同的 machineKey,这是它们进行通信所必需的。它们都部署在公司内部服务器上。我们想开始将 .Net Core 2 用于新的 Web API,但 .Net Core Web API 使用新的数据保护 API,它不再使用 machineKey,而是使用共享密钥文件。所以我的问题是:

我们如何创建一个新的 .Net Core 2 Web API 并将其添加到我们现有的 .Net 4.6.1 微服务架构中,并让它们使用他们已经使用的 machineKey 进行通信?

【问题讨论】:

    标签: asp.net-web-api asp.net-core asp.net-web-api2 microservices asp.net-core-webapi


    【解决方案1】:

    经过大量研究,我得出的结论是,这是无法实现的,因为 .Net Core 2 API 不支持 machineKey 加密。因此,我使用 .Net Core Data Protection API 改造了我们的 .Net 4.6 API,并将它们配置为使用相同的密钥集。然后在我们的 .Net Core API 中,我将数据保护 API 配置为使用与 .Net 4.6 API 相同的密钥集。然后我为我们的 .Net Core 2.1 API 创建了身份验证中间件,用于解密访问令牌并创建声明。

    这是一篇关于将 ASP.NET 中的 machineKey 替换为 Data Protection API 的好文章: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey?view=aspnetcore-2.1

    这是一个关于创建 ASP.NET Core 2 中间件的好帖子: ASP.NET Core 2.0 authentication middleware

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多