将密码存储在Keycloak中 [英] Store password in Keycloak

查看:209
本文介绍了将密码存储在Keycloak中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义用户存储提供程序,它将根据需要将用户从旧系统迁移到keycloak的本地存储中.

I have created a custom user storage provider which will migrate users from legacy system to keycloak's local storage on demand basis.

已迁移用户的所有详细信息都存储在Keycloak中,密码除外.

All the details of the migrated user is being stored in Keycloak except password.

userModel.setEmail(email);
userModel.setEnabled(isEnabled);
userModel.setEmailVerified(isEmailVerified);
userModel.setFirstName(firstName);
userModel.setLastName(lastName);

我正在使用上面的代码存储用户的所有信息,但是我没有找到用于存储密码的任何方法/类.

I am using the above code to store all the information of the user, but I didn't find any method/class in which stores the password.

有人可以帮我吗?

P.S.我正在使用Keycloak-3.3.0-最终版.

P.S. I am using Keycloak-3.3.0-Final version.

推荐答案

您可以使用

session.userCredentialManager().updateCredential(realm, user, UserCredentialModel.password(passwordNew, false));

其中 session 是您可以在自定义用户存储提供程序中访问的当前 KeycloakSession .

where session is the current KeycloakSession which you have access to in your custom user storage provider.

这篇关于将密码存储在Keycloak中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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