webauthn - 如何检查 WebAuthn 平台类型的身份验证器?
问题描述
所以试图整合WebAuthN。如果与平台无关(FIDO2 安全密钥)检查更容易(一般是否支持 webauthN - 我们继续,也许用户稍后插入 USB 密钥),我找不到检查平台相关的方法(Windows Hello,指纹扫描仪等)身份验证器。isUserVerifyingPlatformAuthenticatorAvailable()
看起来就像我所需要的,但
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()
.then(() => true)
.catch(() => false)
.then((x) => console.log(x))
我的 MacBook(Chrome、Firefox、Safari)总是返回 true。此外 MacBook 没有任何身份验证器并试图继续使用参数
"authenticatorSelection": {
"authenticatorAttachment" : "platform",
"requireResidentKey":false,
"userVerification":"preferred"
}
以“此设备不支持此网站请求的安全密钥类型”结尾。消息(我的 MacBook 肯定没有指纹扫描仪,所以这是合理的!)
看到了类似的问题,但只有使用这个的建议isUserVerifyingPlatformAuthenticatorAvailable()
。
解决方案
isUserVerifyingPlatformAuthenticatorAvailable()
返回一个 Promise of boolean 所以你的代码应该看起来更像:
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()
.then(isAvailable => isAvailable)
.catch(err => false)
.then(result => console.log("Platform authenticator is available: " + result));
推荐阅读
- html - 在 ngx-scrollreveal 中,ngsReveal 是隐藏组件,应该在滚动时进行动画处理
- c# - 如何洗牌datagridview?
- django - Django - 将模型 CharField 值设置为来自另一个模型的字段名称
- nested - Powerbuilder 获取嵌套数据窗口的对象
- python - 如何从行中获取 strptime 并与当前时间进行比较?
- javascript - 使用带有多个图像目标的 8th Wall SDK 进行增强
- swift - 将通用对象存储在异构数组中并将对象参数检索为正确的类型
- java - 无法从 hashmap 和 gson 获取正确的 json
- javascript - 无法导入 JavaScript 类
- python - 如何使用 python opencv 和 ffmpeg 同步视频和音频?