我一直在开发一款使用webauthn-ruby gem for 2FA的rails 7应用程序.在前端,我们使用WebAuthnJSON.登录时,首先有一个使用邮箱/密码的步骤,之后我们会找到现有的凭据,用户将需要使用WebAuthn进行身份验证.

我遇到的问题是,无论我使用什么设置,在Windows(Chrome)中,用户在进行身份验证时,总是会被提示输入安全密钥(USB)或其他设置,提示他们登录Windows Hello.取消该步骤后,您将进入正常的Chrome模式,在该模式下您可以 Select 要进行身份验证的设备.我们想跳过Windows的步骤,或者更确切地说,让用户可以设置Android设备,但不知道如何设置.

这个问题可以在https://webauthn.cedarcode.com/上转载.

但是,如果您在https://webauthn.io上测试,则不会出现此问题.

这是因为这个gem,还是与WebAuthnJSON有关,还是设置不正确?

使用默认设置和几乎任何其他设置都会发生这种情况.

服务器注册:

create_options = WebAuthn::Credential.options_for_create(
  exclude:                 @authenticatable.webauthn_credentials.pluck(:external_id),
  user:                    {
    id:           @authenticatable.webauthn_id,
    display_name: @authenticatable.email,
    name:         @authenticatable.full_name
  },
  pub_key_cred_params: [
    {
      type: 'public-key',
      alg:  -7 # "ES256" as registered in the IANA COSE 算法rithms registry
    },
    {
      type: 'public-key',
      alg:  -257 # Value registered by this specification for "RS256"
    }
  ],
  authenticator_selection: {
    resident_key:      'required', # This setting specifically makes windows hello not pop-up
    user_verification: 'preferred'
  },
  attestation: 'none'
)

客户端注册:

WebAuthnJSON.get({ "publicKey": data }).then(async function(credential) {
  const request = new FetchRequest("post", _this.callbackValue, { body: JSON.stringify(credential) })
  const response = await request.perform()

  if (response.ok) {
    const data = await response.json
    window.Turbo.visit(data.redirect, { action: 'replace' })
  } else {
    console.log("An error occured while authenticating Webauthn", response);
  }
}).catch(function(error) {
  console.log("An error occured while authenticating Webauthn", error);
});

服务器身份验证:

get_options = WebAuthn::Credential.options_for_get(
  allow:             @authenticatable.webauthn_credentials.pluck(:external_id),
  user_verification: 'discouraged'
)

客户端身份验证:

WebAuthnJSON.get({ "publicKey": data }).then(async function(credential) {
  const request = new FetchRequest("post", _this.callbackValue, { body: JSON.stringify(credential) })
  const response = await request.perform()

  if (response.ok) {
    const data = await response.json
    window.Turbo.visit(data.redirect, { action: 'replace' })
  } else {
    console.log("An error occured while authenticating Webauthn", response);
  }
}).catch(function(error) {
  console.log("An error occured while authenticating Webauthn", error);
});

具体地说,在注册时将服务器中的Resident_Key设置为Required会从注册流程中删除该步骤,但不会删除身份验证中的Windows Hello或安全密钥步骤,因此我的问题仍然存在.

推荐答案

Windows上的Chrome有一个问题,因为与手机的交互必须由Chrome来处理(因为Windows直到最新的Windows 11更新才实现这一点,我认为它还处于预览阶段).但与安全密钥和Windows Hello的交互必须由Windows自己处理.

因此,Chrome不得不猜测在大多数Windows版本上调用哪个用户界面.

主控件是authenticator_selection中的authenticatorAttachment,它看起来不像是您当前正在设置的.值resident_key也会产生影响,并且该值当前未在您引用的站点上设置.

我今天没有Windows机器,但试着将authenticatorAttachment设置为cross-platform,将residentKey设置为required.

(在https://webauthn.io/上,你可以点击"高级设置"来设置这些选项.)

WebAuthn第三级将有一个hints参数,允许网站更好地控制这一点,但它还没有准备好.

Javascript相关问答推荐

如何获取同名dis部分的dis元素值中的增量和减量

如何确保滚动时响应式图像保持在文本图像布局中的顶部?

使用jsPDF添加Image JPEG将p5.js草图画布下载为PDF

在类型脚本中使用浏览器特定属性的正确方法是什么?

复合密钥查找在mongoDB中未按预期工作

为什么在react js中没有调用加载器函数?

reaction useEffect KeyDown for each 条目配音输出

是否有方法在OpenWeatherMap API中获取过go 的降水数据?

仅圆角的甜甜圈图表

如何在Connect 4游戏中 for each 玩家使用位板寻找7形状?

为什么我的列表直到下一次提交才更新值/onChange

在react js中使用react—router—dom中的Link组件,分配的右侧不能被 destruct ''

如何调用名称在字符串中的实例方法?

当Redux提供程序访问Reduxstore 时,可以安全地从Redux提供程序外部调用钩子?

类构造函数不能在没有用With Router包装的情况下调用

Web Crypto API解密失败,RSA-OAEP

400 bad request error posting through node-fetch

无法避免UV:flat的插值:非法使用保留字"

在验证和提交表单后使用useNavigate()进行react 重定向,使用带有加载器和操作的路由

构建器模式与参数对象输入