【发布时间】:2021-09-30 15:12:09
【问题描述】:
我正在 Linux 容器中的 Docker 中运行我的 .net core 5 应用程序,即 Authentication Server 和 API Gateway。 API GateWay 中的控制器类包含一个[Authorize] 属性来验证用户。尽管用户是有效的(例如注册和登录成功),API Gate 无法允许用户访问 API。这是我日志中抱怨的一部分:
Failed to validate the token.Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException: IDX10501: Signature validation failed. Unable to match key:
kid: '6B7ACC520305BFDB4F7252DAEB2177CC091FAAE1'.
Exceptions caught:''.
我说得对吗,是因为身份服务 4 生成的 cookie 吗? idsrv.session 和 .netcore related cookies 共享失败。
这是因为根据我的观察,当我的微服务在 IIS 中运行时。当用户成功登录时,身份验证服务器将生成两个提到的 cookie。并且提到的 cookie 在其他微服务之间“共享”,部分原因是它们位于相同的 localhost 但端口号不同。
当我的应用程序迁移到 Docker 时; Authentication Server 能够生成相关的 cookie,其余的 contains 获取 cookie 失败。
结果,我猜,这就是 API Gateway 无法授权有效用户的结果。
因此,我想知道我对授权的理解是否正确以及我应该如何解决有效用户的问题。
【问题讨论】:
标签: docker .net-core asp.net-identity identityserver4