我想使用 Keycloak 来授权访问我的 API。
我已经定义了相关范围,并且这些范围按预期返回到访问令牌中:
{
... claims ...
"scope": "openid profile user/Patient.write user/Patient.read",
... etc ...
}
Run Code Online (Sandbox Code Playgroud)
但托管 API 的服务器需要以数组表示的访问令牌中的范围,如下所示:
{
... claims ...
"scope": [
"openid",
"profile",
"user/Patient.read",
"user/Patient.write"
],
...etc...
}
Run Code Online (Sandbox Code Playgroud)
我在 Keycloak 中看不到任何可以更改行为以将范围输出为数组的地方?
我已经考虑过使用自定义令牌映射器脚本来执行此操作,但范围似乎在映射器脚本中不可用,因此看起来我无法以这种方式重新映射它们。有什么方法可以将 Keycloak 中令牌的范围转换为这种形式吗?