Keycloak & WebAuthn - 在用户注册期间设置可选步骤

Keycloak & WebAuthn - Set up optional step during user registration

我的网站将被 2 类用户使用,

  1. 只能通过密码登录的用户(例如Windows8/Windows7个用户)
  2. 可以通过指纹或密码登录的用户(例如Mac用户/Android 7+用户)

我正在使用 Keycloak 作为 IAM/OAuth 提供商 - 即 Keycloak 负责用户注册、登录、配置文件管理等

对于仅通过密码登录的用户:(Windows 7/8 用户) 注册页面应显示输入用户名和密码的选项。启用 WebAuthn 无密码/使用指纹注册的选项必须不可用

对于可以通过指纹登录的用户:(Mac 用户 / Android 7+ 用户) 注册页面应显示 2 个选项:使用指纹注册 + 使用 username/password 注册 用户可以选择设置两个选项或其中一个

问题1:Keycloak是否可以检测系统是否可用WebAuthn Passwordless?

问题2:新用户注册页面如何显示可选步骤?我怎么说选择输入密码还是使用指纹?

当前状态: 我已将 WebAuthn Passwordless 设置为必需的操作,但它在 Windows 7 / 8 系统上失败。我不想强迫我的用户购买 KeyFob。

请帮我解决这个问题。

Question 1: Is there anyway Keycloak can detect if WebAuthn Passwordless is available on the system or not?

“无密码”WebAuthn 是一种特殊的实现方式,当您为 navigator.credentials.create() 准备选项时,您让用户在 authenticatorSelection 中设置 userVerification: "required" 的同时注册身份验证器。如果浏览器支持 WebAuthn,那么无密码 可用,只要您需要用户验证。

关于 the WebAuthn spec has an interesting paragraph 用户需要哪些身份验证器功能才能通过 WebAuthn 完成无密码注册 API:

User-verifying platform authenticators and first-factor roaming authenticators enable passwordless multi-factor authentication. In addition to the proof of possession of the credential private key, these authenticators support user verification as a second authentication factor, typically a PIN or biometric recognition. The authenticator can thus act as two kinds of authentication factor, which enables multi-factor authentication while eliminating the need to share a password with the Relying Party.

至于检测 WebAuthn 支持,最好的办法是确保 window.PublicKeyCredential 存在于浏览器中。

Question 2: On the new user registration page how do I display optional step? How do I say choose to either enter a password or use your fingerprint?

无密码用户注册需要在 为用户创建帐户后进行。这意味着您应该从用户名+密码注册开始,然后在他们登录后,您为他们提供 升级 无密码身份验证的选项。如果用户接受,则继续 WebAuthn 注册仪式。

从那时起,当用户回来进行身份验证时,您可以只输入用户名,然后检查他们提供的用户名是否包含任何凭据。如果是这样,您然后要求用户使用您传递给 navigator.credentials.get() 的选项中 allowCredentials 数组中指定的任何关联凭据执行 WebAuthn 身份验证仪式。如果用户成功,则让他们进入,无需输入密码,从而实现“无密码”身份验证愿景。

How do I say choose to either enter a password or use your fingerprint?

如果您真的想在新用户来找您创建帐户时完全取消密码,那么您将需要研究“无用户名”。这类似于无密码,除了在 WebAuthn 注册期间,您必须要求用户验证(如前所述无密码) 通过在中设置 residentKey: "required" 来创建可发现的凭据authenticatorSelection 当您为 navigator.credentials.create().

准备选项时

Check out the API spec for more information about discoverable credentials - 在开始依赖它们之前,您应该注意它们的一些问题。