最近,我在玩keylock服务器。我有一个应用程序的注册流程有点复杂,我需要更改 keycloak 的基本流程。这可能吗?例如,当用户填写所需数据时, 点击注册,我想将他直接重定向到我的网站而不是keycloak服务器(配置文件管理器)。
此外,我正在尝试使用“node.js”通过 API 添加用户,这将是最简单的方法。然而,我似乎无法完成它。有谁有或知道某种教程可以帮助我,或者为我指明正确的方向?
编辑:
我尝试的是创建bash脚本并通过休息添加用户
#!/bin/bash
export TKN=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin" \
-d 'password=admin' \
-d 'grant_type=password' \
-d 'client_id=admin-cli' | jq -r '.access_token')
curl -X POST 'http://localhost:8080/auth/admin/realms/demo/users' \
-H "Accept: application/json" \
-d "username=abc
-H "Authorization: Bearer $TKN" | jq .
它不会抛出任何错误。但在 keycloak 中我看不到任何新用户。
最佳答案
Is this possible? For example, when a user fills the needed data, and clicks to register, I want to redirect him directly to my site and not to keycloak server ( profile manager ).
是的。您可以通过 REST API 添加用户。
Also, I am trying to add a user via API, using 'node.js', which would be the easiest way. However, it seems I can't get it done. Does anyone have or know of some kind of tutorial, that can help me, or point me in the right direction?
这是如何使用 Keycloak REST API 创建用户的示例: https://github.com/v-ladynev/keycloak-nodejs-example/blob/master/lib/adminClient.js#L35
It doesn't throw any error. But in keycloak I can't see any new user.
看来您提供了不正确的参数,或者没有提供强制参数。
关于node.js - Keycloak更改注册流程/创建用户API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48037603/