启用 LDAP 的 Keycloak 电子邮件 "UPDATE_PASSWORD" 机制 (15.0.2)

Keycloak email "UPDATE_PASSWORD" mechanism with LDAP enabled(15.0.2)

我有一个密钥斗篷服务器和使用它进行身份验证的服务。 我想允许用户更改他们的密码。 但是从文档中不清楚电子邮件操作“更新密码”如何在启用 LDAP 的情况下工作。 https://www.keycloak.org/docs/latest/server_admin/#_user-storage-federation

"By default, Keycloak will import users from LDAP into the local Keycloak user database. This copy of the user is either synchronized on demand, or through a periodic background task. The single exception to this is the synchronization of passwords. Passwords are never imported. Their validation is always delegated to the LDAP server"

并在“编辑模式”部分

"WRITABLE Username, email, first name, last name, and other mapped attributes and passwords can all be updated and will be synchronized automatically with your LDAP store."

我在“用户联合”选项卡 -> LDAP 中的设置是:

"Import Users": "ON",
"Edit Mode": "None"

Sync Settings
"Periodic Full Sync": "Off",
"Peroidic Changed Users Sync": "On"

In the Section "Mappers"
"password" param is not listed.

那么,如果我们应用到用户电子邮件操作“UPDATE_PASSWORD”并且用户将设置新密码,那么结果将保存到 Keycloak 和 openldap 之后是否正确? 但前提是 ldap 上的“编辑模式”将设置为 “WRITABLE”?如果现在没有这种模式,我将更改 keycloak 中的密码,由于与 ldap 不一致,数据将被破坏。 另外,我没有创建这个 keycloak-server,在 LDAP 上将编辑模式设置为“WRITABLE”被认为是错误的 practice/vulnerability? 在那种情况下,解决方法是将密码直接写入 openldap?

现在我以这种方式更新密码,但在未启用 ldap 的情况下进行了测试

 public void updatePassword(String id){
            UserResource userResource = keycloak.realm(keycloakProperties.getRealm())
                    .users().get(id);
            userResource.executeActionsEmail(List.of("UPDATE_PASSWORD"));
        }

服务使用 Spring 和“keycloak-admin-client”依赖项(v. 15.0 .2)

原来就像文档说的那样简单。如果 LDAP 上的“编辑模式”设置为 WRITABLE,新密码将自动与您的 LDAP 存储同步。我决定直接在 openldap 中更新“userPassword”,并且没有同时读取和写入用户数据的 keycloak 实例。同样在我的例子中,更新后的密码格式是“纯文本”。使用本指南中的证书启用编码 https://github.com/osixia/docker-openldap/issues/208

policy.ldif

dn: cn=module{0},cn=config
changetype: modify
add: olcModuleLoad
olcModuleLoad: ppolicy 

overlay.ldif

dn: olcOverlay={2}ppolicy,olcDatabase={1}mdb,cn=config
objectClass: olcOverlayConfig
objectClass: olcPPolicyConfig
olcOverlay: {2}ppolicy
olcPPolicyHashCleartext: TRUE