Keycloak:实现“重置密码"(以管理员身份)的流程与“忘记密码"的流程相同(以用户身份) [英] Keycloak : implement "reset password" (as admin) flow same as "forgot password" (as user)

查看:124
本文介绍了Keycloak:实现“重置密码"(以管理员身份)的流程与“忘记密码"的流程相同(以用户身份)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Keycloak中实现此身份验证流程:

I would like to implement this authentication flow in Keycloak:

  1. 用户仅通过输入电子邮件来创建帐户
  2. 用户已登录并可以访问我的服务2'.同时,向他发送了一封电子邮件,使他可以完成"邮件.他的帐户
  3. 用户离开他的会话->要重新使用我的服务,他必须单击收到的电子邮件
  4. 通过单击收到的电子邮件,用户定义他的第一个密码
  5. 然后用户自动登录(无需通过登录页面).

此流程的目标是最简单,吸引不习惯使用Web应用程序的用户.

The objective of this flow is to be the simplest, to hook users who are not used to webapps.

我会做的实现:

  • 创建没有密码请求的帐户:我通过禁用密码验证 Profile Validation 规则
  • 来定制Keycloak Registration 流程
  • 以编程方式,在我的Web应用程序中,通过REST Admin API在用户的首次连接时,我触发了电子邮件操作 UPDATE_PASSWORD
  • Create an account without password request: I customize the Keycloak Registration flow by disabling the Password Validation and Profile Validation rules
  • Programmatically, in my webapp, at the first connection of a user, via the REST Admin API, I trigger the email action UPDATE_PASSWORD

我得到了一些有用的东西,但是:

I get something that works, but:

A.电子邮件接收的链接重定向到一个中间页面,以确认操作的执行(执行以下操作")-(类似于 Keycloak实施与忘记密码流程相同的重置密码流程)

A. The link received by email redirects to an intermediary page confirming the execution of actions ("Perform the following action (s)") - (similar to Keycloak Implement Reset password flow same as forgot password flow)

B.然后,用户将被重定向到登录页面,而不是直接连接到应用程序.

B. The user is then redirected to a login page, and not directly connected to the application.

当我以普通用户身份(通过忘记密码"功能)触发重置密码请求时,该过程就是我想要的过程:通过单击电子邮件链接,我直接转到允许我输入的页面并确认新密码,然后我就通过了身份验证.

When, as a normal user, I trigger a reset password request (through 'forget password' feature), the process is the one I want: by clicking on the email link, I go directly to the page allowing me to enter and confirm a new password, then I'm authenticated.

我的问题:您看到一种实现这种简化"流程的方法吗?

我的密钥斗篷版本:11.0.2

My keycloak version : 11.0.2

谢谢!

推荐答案

作为问题A的解决方法,我自定义了 info.ftl 模板页面.我在链接上的 click 上添加了一个难看的内联脚本,自动重定向到更新密码页面.

As a workaround for problem A, I customize info.ftl template page. I add an ugly inline script to click on the link, redirecting automatically to the update password page.

<#import "template.ftl" as layout>
(...)
            <#elseif actionUri?has_content>
              <p><a id="yolo" href="${actionUri}">${kcSanitize(msg("proceedWithAction"))?no_esc}</a></p>
              <script>document.getElementById('yolo').click()</script>
(...)

在找到更干净的解决方案之前,它会继续工作.

It'll do the job until I found a cleaner solution.

目前,B问题仍然存在.

At the moment, B problem remains.

这篇关于Keycloak:实现“重置密码"(以管理员身份)的流程与“忘记密码"的流程相同(以用户身份)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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