我使用 ASP.NET Core 成功设置了 IdentityServer4。
作为默认配置,我有这个:
IdentityServerAuthenticationOptions options = new IdentityServerAuthenticationOptions()
{
Authority = "http://localhost:5000",
ScopeName = "scope",
ScopeSecret = "ScopeSecret",
AutomaticAuthenticate = true,
AutomaticChallenge = true,
RequireHttpsMetadata = false,
};
现在,使用本指南,我配置为从配置文件中读取,因此它们可以是生产中的任何数字。
例如,如果我将 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 配置为具有动态权限的正确方法是什么?
更新
似乎问题出在发行者身上,对此有什么想法吗?
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)