【发布时间】:2018-09-14 17:31:04
【问题描述】:
场景
- localhost & 192.168.0.10 指的是同一台名为 MyPC 的机器
- 身份服务器正在该“MyPC”上运行
- UI 使用“localhost”与 Identity Server 通信
- 受保护的 API 使用“192.168.0.10”与 Identity Server 通信
- UI 和 API 相互通信并由 Identity Server 进行身份验证
在上述场景中,如果我使用 Identity Server 3,一切都很好;但是,当我切换到 Identity Server 4(最新版本)时,问题就开始了。我在 API 中遇到了这个错误
System.IdentityModel.Tokens.SecurityTokenInvalidIssuerException:IDX10205:颁发者验证失败。发行者:'localhost:9987'......
如果我为 UI 和 API 使用相同的 IP 地址(localhost 或 192.168.0.10)与身份服务器通信,该错误就会消失。
谁能给我指出解决这个问题的方向?我确实需要能够使用 127.0.0.1、localhost、Lan 地址、Wan 地址访问 Identity Server?
这是我在 API 启动中使用的代码:
services.AddAuthentication(o =>
{
o.DefaultScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
o.DefaultAuthenticateScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
})
.AddIdentityServerAuthentication(x =>
{
x.Authority = Configuration.GetSection("URL").GetSection("IdentityServerURL").Value;
x.ApiSecret = Configuration.GetSection("Resource").GetSection("APISecrets").Value;
x.ApiName = Configuration.GetSection("Resource").GetSection("APIName").Value;
x.SupportedTokens = SupportedTokens.Both;
x.RequireHttpsMetadata = false;
});
P/S:我对此进行了研究,但没有任何明确的答案。
【问题讨论】:
标签: identityserver4