如何在Keycloak中创建脚本映射器? [英] How to create a Script Mapper in Keycloak?

查看:254
本文介绍了如何在Keycloak中创建脚本映射器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Keycloak中创建脚本映射器"类型的协议映射器.该脚本应获取用户属性,检查其大小,并将其放在令牌上.我没有找到有关如何创建脚本的文档或示例.从我可以收集的点点滴滴来看,我想我的脚本需要看起来像这样:

I need to create a Protocol Mapper of type Script Mapper in Keycloak. The script should get a user attribute, check its size, and put it on the token. I found no documentation or examples of how a script should be created. From the bits and pieces I could gather, I guess I the script would need to look something like:

var value = user.getAttribute("myAttribute");
if (value.length > LIMIT) {
    value = value.substring(0,LIMIT);
}
token.setOtherClaims("myAttribute",value);

  • 这是对的吗?我组成了user.getAttribute("myAttribute").是否有文档来源可以找到如何获取Keycloak用户属性?
  • 脚本是否需要返回任何内容? 任何帮助都将受到欢迎.
查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆