使用 kcadm.sh 将协议映射器添加到 keycloak

Dav*_*son 5 keycloak

我一直在尝试使用 kcadmin cli 在 keycloak 中设置我的完整测试系统,但是在创建协议映射器时遇到了一些问题:

HTTP 错误 - 400 错误请求

我一直在尝试使用以下方法实现请求:

http://www.keycloak.org/docs-api/3.3/rest-api/index.html http://blog.keycloak.org/2017/01/administer-keycloak-server-from-shell.html

我在请求中遗漏了什么:

/opt/jboss/keycloak/bin/kcadm.sh create \
clients/7e8ef93b-0d0f-487d-84a5-5cfaee7ddf13/protocol-mappers/models \
-r $test_realm \
-s config.user.attribute=tenants \
-s config.claim.name=tenants \
-s config.jsonType.label=String \
-s config.id.token.claim=true \
-s config.access.token.claim=true \
-s config.userinfo.token.claim=true \
-s config.multivalued=true \
-s name=tenants \
-s protocolMapper=oidc-usermodel-attribute-mapper
Run Code Online (Sandbox Code Playgroud)

这有效:

/opt/jboss/keycloak/bin/kcadm.sh create \
clients/7e8ef93b-0d0f-487d-84a5-5cfaee7ddf13/protocol-mappers/models \
-r $test_realm \
-s name=tenants1 \
-s protocol=openid-connect \
-s protocolMapper=oidc-usermodel-attribute-mapper
Run Code Online (Sandbox Code Playgroud)

Osc*_*car 7

您需要在 Linux 中指定这样的嵌套配置值:

-s 'config."id.token.claim"=true'
-s 'config."included.client.audience"=theclient'
Run Code Online (Sandbox Code Playgroud)

  • 但为什么......只是为什么:D 你救了我生命的几个小时,谢谢! (2认同)

Boo*_*mer 5

在失败的示例中,缺少以下值:
-s protocol=openid-connect