在keycloak中创建用户时指定用户ID [英] specify user id when creating user in keycloak

查看:283
本文介绍了在keycloak中创建用户时指定用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究从旧系统到密钥斗篷的迁移过程.基于此处的一些想法: https://github.com/Smartling/keycloak-user -migration-provider ,我们希望通过从旧系统上一些专用端点中查找用户凭据来在登录时在keycloak中创建用户帐户.

I'm investigating a migration process from a legacy system into keycloak. Based on some of the ideas here: https://github.com/Smartling/keycloak-user-migration-provider we're looking to create user accounts in keycloak at the point of login by looking up user credentials from some dedicated endpoints on our legacy system.

为此,我需要用户ID保持与旧系统相同.

As part of this, I need the user ID to remain the same as it was in the legacy system.

是否可以创建具有指定ID的用户,而不是依靠密钥斗篷自动生成用户?

谢谢.

推荐答案

在尝试通过API创建用户时遇到此问题,我调查了users服务的代码.由于用户的创建方式,当前似乎无法设置用户ID.

Running into this issue when attempting to create users via the API, I looked into the code for the users service. It looks like it is currently not possible to set the user id due to how the user is created.

https://github.com/keycloak/keycloak/blob/master/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java 专门在线 https://github.com/keycloak/keycloak/blob/7cfe6addf01676939206e034a87c791460031032/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java#L115 首先使用创建用户的方法用户名,然后更新.我认为id不是可更新的字段.因此,目前尚不可能.

From the code in https://github.com/keycloak/keycloak/blob/master/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java specifically on line https://github.com/keycloak/keycloak/blob/7cfe6addf01676939206e034a87c791460031032/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java#L115 the user is first created using the username, then updated. I believe id is not an updatable field. Thus it is not currently possible.

这篇关于在keycloak中创建用户时指定用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆