【发布时间】:2016-08-30 15:58:32
【问题描述】:
我使用 ASP.NET Core 成功设置了 IdentityServer4。
作为默认配置,我有这个:
IdentityServerAuthenticationOptions options = new IdentityServerAuthenticationOptions()
{
Authority = "http://localhost:5000",
ScopeName = "scope",
ScopeSecret = "ScopeSecret",
AutomaticAuthenticate = true,
AutomaticChallenge = true,
RequireHttpsMetadata = false,
};
现在,使用这个 guide 我配置为从配置文件中读取,因此它们可以是生产中的任何数字。
例如,如果我将 API 设置为在 http://*:5000 运行,那么客户端可以通过服务 IP 地址连接到它,例如 http://192.168.1.100:5000。
一旦客户端获得 Bearer 令牌并尝试使用它,就会出现 Internal Server Error 并出现以下异常:
Unable to obtain configuration from:
'http://*:5000/.well-known/openid-configuration'.
---> System.IO.IOException: IDX10804: Unable to retrieve document from: 'http://*:5000/.well-known/openid-configuration'.
---> System.UriFormatException: Invalid URI: The hostname could not be parsed.
将IdS4配置为具有动态权限的正确方法是什么?
更新
似乎问题出在 Issuer 上,有什么想法吗?
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException:
IDX10205: Issuer validation failed. Issuer: 'http://192.168.1.100:5000'. Did not match: validationParameters.ValidIssuer: 'http://localhost:5000' or validationParameters.ValidIssuers: 'null'.
at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuer(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters)
【问题讨论】:
标签: identityserver4 asp.net-core-webapi