我在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