访问令牌不包括在 Identity Server 4 中声明的范围

Access token does not include scopes declared in Identity Server 4

大致如下 Scott's guide, I got it to work with authorization code flow. However, When I investigate the well-known, I see that junky_scope is listed as supported. My client and API scope/resource are declared as follows. The claims in the access token are to be based on the API scopes according to IDS4's GitHub.

public static IEnumerable<ApiScope> Obtain()
{
  yield return new ApiScope("junky_scope", "Junky Scope"); ...
}

yield return new ApiResource
{
  Name = "blopp", ...
  Scopes = new List<string> { "awesome_scope", "junky_scope", ... }
};

yield return new Client
{
  ClientId = "spa_client",
  AllowOfflineAccess = true,
  AllowedGrantTypes = GrantTypes.Code, ...
  AllowedScopes = new List<string> { "openid", "awesome_scope", "junky_scope" }
};

调用调用以将我的代码交换为令牌,生成有效的访问令牌,但仅包含 openidoffline_access范围,虽然。使用刷新令牌请求新令牌时也是如此。主体中传递的有效载荷如下所示。我已经尝试在没有指定 scope 的情况下获取所有支持的令牌(如承诺的 in the docs)但没有成功。

client_id=spa_client
&scope=junky_scope
&redirect_uri=http://localhost:44304/beep
&code=205D...EDBF
&grant_type=authorization_code

设置与 this question as well as 中的设置非常相似,尽管它们考虑的问题不同。不过,声明的范围显示为包含在响应中。

起初我认为这可能与我的测试用户的定义有关,但那里没有关于声明的内容,我能看到的最接近的是声明。但我不依赖我的范围内的声明,所以这是一个死胡同。

我迷路了,不确定如何进一步解决问题。 ids4 访问令牌范围的谷歌搜索变体不包含产生的很少。

不太喜欢回答我自己的问题,但有时需要这样做。

显然,IDS4 中有一个错误(或者,至少 the documentation 中有一个非常不清楚的地方)。内容如下。

scope
One or more registered scopes. If not specified, a token for all explicitly allowed scopes will be issued.

这是不正确的,因此我的困惑导致了这个问题。


现在,如果我要为 IDS4 文档辩护,it is said 还需要参数来请求授权(不是交换也不是更新)。

scope
One or more registered scopes (required).

现在,除了这是一个明显的差异并且在不同的页面上列出之外,如果我们将明确允许的范围解释为授权期间引用的范围而不是在服务器的客户端中引用的范围, API scopes/resources,那么是的,文档没有错。但从我的立场来看,这是对 spagat 的深入研究,以使其看起来合理。