IdentityServerV4参考令牌自省

问题描述 投票:0回答:1

我已经使用授权代码+ PKCE与客户端建立了IdentityServerV4,并将访问令牌类型设置为引用。

new Client
{
    ClientId = "app",
    ClientName = "My Application",
    AllowedGrantTypes = GrantTypes.Code,
    RequireClientSecret = false,
    RedirectUris = { "http://site.example.com:3000/callback" },
    AllowedCorsOrigins = { "http://site.example.com:3000" },
    AllowedScopes = { "openid", "profile", "email" },
    AccessTokenType = AccessTokenType.Reference,
    RequireConsent = false,
    RequirePkce = true
}

我现在想在客户端应用程序和服务之间建立反向代理网关,该代理服务器将在转发请求之前将参考令牌交换为常规签名的JWT。甚至在设置网关之前,我都尝试使用登录时获得的参考令牌通过调用自省端点来手动执行交换。]

我向身份服务器as described here添加了一个称为“网关”的API,为其提供了一个秘密,并使用带有API的ID和密钥的IntrospectionClient成功调用了此端点,但是我得到了活动的响应:false ,并且身份服务器日志显示错误,指示令牌缺少预期的作用域“网关”。日志中显示的令牌信息仅显示openid范围。

new ApiResource("gateway"){
    ApiSecrets = { new Secret("test".Sha256()) }
}

这将导致来自IdentityServer的两条日志消息:

fail: IdentityServer4.ResponseHandling.IntrospectionResponseGenerator[0]
      Expected scope gateway is missing in token
info: IdentityServer4.Endpoints.IntrospectionEndpoint[0]
      Success token introspection. Token active: True, for API name: gateway

因此,我可以避免的是,API和颁发的令牌之间缺少一些链接,但是我尝试了我能想到的Client和ApiResource定义之间的范围和允许范围的所有排列,但是我似乎无法获得预期的结果。我已经阅读并重读了几次文档,在这种情况下,我还不太清楚API和客户端之间的关系。要支持这种类型的设置,需要哪种配置?

我已经使用授权代码+ PKCE与客户端建立了IdentityServerV4,并将访问令牌类型设置为引用。新客户端{ClientId =“ app”,ClientName =“我的应用程序,...

oauth-2.0 jwt identityserver4 oidc
1个回答
0
投票

似乎您的代理正在将gateway范围用于自省端点,并且问题是您的令牌没有此gateway范围,因此您总是会得到active: false作为响应。

© www.soinside.com 2019 - 2024. All rights reserved.