Java KeyClope无法使用服务帐户令牌获取具有权限的RPT
我正在使用keydepot:4.8.3.Final 我有以下客户在keydepeat中Java KeyClope无法使用服务帐户令牌获取具有权限的RPT,java,keycloak,Java,Keycloak,我正在使用keydepot:4.8.3.Final 我有以下客户在keydepeat中 用户服务 库存服务 InventoryService在KeyClope中定义了一些资源并启用了授权 用户服务(作为服务帐户)在服务帐户角色选项卡中分配了必要的客户端角色 每当有人试图访问InventoryService的API时,我都会执行以下操作: 从授权标头获取访问令牌 获取RPT(如上所述) 如果所需的权限存在或不存在,请反省RPT 当UserService尝试访问InventoryServic
- 用户服务
- 库存服务
- 从授权标头获取访问令牌
- 获取RPT(如上所述)
- 如果所需的权限存在或不存在,请反省RPT
{
"error": "invalid_resource",
"error_description": "Resource with id [item] does not exist."
}
AuthorizationResource authResource = authzClient.authorization(at);
AuthorizationRequest request = new AuthorizationRequest();
request.addPermission(resourceId, scopes);
AuthorizationResponse authResponse = authResource.authorize(request);
String rpt = authResponse.getToken();
下面是java中的代码片段
当UserService尝试访问InventoryService的API时,我得到以下错误响应
{
"error": "invalid_resource",
"error_description": "Resource with id [item] does not exist."
}
AuthorizationResource authResource = authzClient.authorization(at);
AuthorizationRequest request = new AuthorizationRequest();
request.addPermission(resourceId, scopes);
AuthorizationResponse authResponse = authResource.authorize(request);
String rpt = authResponse.getToken();
当我拆下线路时
request.addPermission(资源ID、作用域)强>
我能够获得一份RPT,其中包含所有权限列表。但是如果我包含它,就会抛出上面的错误
顺便说一句,还有一个观察结果:当令牌属于用户(而不是服务帐户)时,上述代码片段可以正常工作
有人能告诉我发生了什么事吗?这是keydove中的一个bug吗?这个问题在keydove 11.0.2中仍然存在。服务帐户位于授权令牌服务中 但是,您可以通过在客户端上通过协议映射器将
azp
声明设置为您的client\u id
之外的内容来解决此问题
.您是否尝试添加要请求权限的资源的实际资源id?