Jen*_*nan 5 scope claims identityserver4
ResourceApi我在我的东西中创建了一个IndetityServer4这样的东西:
我定义了一个名为 的 ApiResourceAPI 1并直接指定声明 -name, sub对于此 api 资源,我扩展了此资源并指定了两个名为Api1.Read和 的范围Api1.Write,并为每个范围指定了 API 特定部分所需的特定声明,但我不这样做了解 ApiResource 和 Scopes 中使用的 Claims 有什么不同?
Claims直接连接在ApiResource和 中使用的声明是什么意思Scope?
我已尝试仅限制 ApiResource 中的 UserClaims,sub and name但如果我想Api1.Write声明role它是在访问令牌中发送的,但 Api1仅在定义中指定name and sub- 为什么 UserClaims 在 ApiResource 中定义?
var apiResource = new ApiResource
{
Name = "Api1",
UserClaims = new List<string> { "name", "sub" },
Scopes = new List<Scope>
{
new Scope
{
Name = "Api1.Read",
UserClaims = new List<string> {"sub", "name"}
},
new Scope
{
Name = "Api1.Write",
UserClaims = new List<string> {"sub", "name", "role"}
}
}
};
Run Code Online (Sandbox Code Playgroud)
根据ApiResource 的文档,其UserClaims本身ApiResource将始终包含在访问令牌中。如果将该 api 分成多个Scope,则其中列出的UserClaimsAPI 将添加到.UserClaimsApiResource