Given:
IdentityServer v3 JavaSCript客户端Asp核心Api客户端
JavaScript客户端使用标识服务器进行身份验证,并使用api的承载令牌发出请求。
api被配置为使用重新源所有者工作流。
问题:现在我得到:
观众:“http://localhost/identity/resources”。不匹配: validationParameters.ValidAudience:'MyApi‘或validationParameters.ValidAudiences:'null’
很明显观众的情况不匹配。我遗漏了什么?
Config
身份服务器中的ApiClient:
return new Client
{
Enabled = true,
ClientId = "MyApi",
ClientName = "The client for the Groupl Api",
ClientSecrets = new List<Secret>
{
new Secret("foo".Sha256())
},
Flow = Flows.ResourceOwner,
AllowedScopes = ClientConstants.AllowedGrouplScopes()
};
在要连接到标识服务器的api中:
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
var authority = config["identity:authority:url"];
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = authority,
RequireHttpsMetadata = false,
EnableCaching = false,
ApiName = "myApi", //Correct that this is the client id?
ApiSecret = "foo"
});
在这里,请求(Access_token省略)
GET /api/values HTTP/1.1
Host: localhost:59364
Content-Type: application/json
Authorization: Bearer {access_token}
更新
当我设置LegacyAudienceValidation = true
时,一切都很好,但是我不知道如何正确地处理这个问题?
发布于 2017-03-13 07:15:53
原因是身份验证行为发生了变化。IdentityServer 3不支持多个观众。Identityserver 4有。因此,对于旧的处理,LegacyAudienceValidation
必须设置为true
https://stackoverflow.com/questions/42670034
复制相似问题