提问者:小点点

使用keydape userinfoendpoint获取用户角色


如何在keydape中获取userinfoendpoint回复中包含的角色。我在keydove中为用户定义了一个“角色映射”。当我调用userinfoendpoint时,我会得到诸如email name等字段,但是回复中不包括角色。当我调用authendpoint时,我获得了access_令牌,并且在字段范围中包含了角色。以下是来自身份验证endpoint的答复:

access_token" QJsonValue(string, "eyJhb...")
"expires_in" QJsonValue(double, 300)
"not-before-policy" QJsonValue(double, 0)
"refresh_expires_in" QJsonValue(double, 1800)
"refresh_token" QJsonValue(string, "eyJhb...")
"scope" QJsonValue(string, "profile email roles")
"session_state" QJsonValue(string, "20b48536-4b38-4aa6-9072-e8309833402e")
"token_type" QJsonValue(string, "bearer")

我还尝试使用属性“scope=roles”调用userinfoendpoint,但没有成功。


共3个答案

匿名用户

正如有人已经提到的,这是一个bug。我听说它在最新版本的钥匙斗篷中被修复了。

我最终修复了这个设置,而没有升级到KeyClope的固定版本。

添加用户域角色时,它将具有“Realm\u access.roles”作为令牌声明名称。您需要将其更改为“角色”。然后它将在userinfo中正确显示。

匿名用户

这个问题应该是:https://keycloak.discourse.group/t/resource-access-claim-missing-from-userinfo-until-i-change-the-name/1238

当在Client Scopes中重命名索赔时-

匿名用户

在KeyClope上的mapper页面中,有一个名为“添加到用户信息”的设置,必须启用该设置。