我在IndetityServer4
像这样创造了一个ResourceApi
之间的不同:什么是IdentityServer4在ApiResource和范围使用索赔
我已经定义了一个ApiResource称为API 1
和指定直接宣称 - 此API资源和我name, sub
我已经扩展了这个资源,并指定了两个名为Api1.Read
和Api1.Write
的作用域,并为每个作用域指定了我对API的特定部分所需的特定声明,但我不明白ApiResource和作用域中使用的声明有什么区别?
是什么意思Claims
直接连接在ApiResource
和Scope
中使用的声明?
我曾尝试限制ApiResource UserClaims只为sub and name
但如果我想在Api1.Write
要求role
它在访问令牌,但在Api1
定义发送的情况下,只name and sub
- 为什么在ApiResource定义UserClaims?
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"}
}
}
};
你说得对,那是对的。 – Jenan