如何在iOS上启用指纹WebAuthn

4

阅读了有关WebAuth API的广泛 文档 内容后,我无法在iOS上成功启用平台认证。
我尝试将Authenticator Attachment设置为跨平台和平台,它们除了iOS外都产生了一致的结果:

╭────────────────┬───────────────────────┬────────────────────────────┬────────────────────────────┬───────────────────────────────────────────────╮
│   Attachment   │       Windows 10      │         Android 8          │       MacOS Catalina       │             iOS 13                            │
│                │       Edge/Chrome     │        Chrome/Opera        │        Chrome/Safari       │      Webkit(Everything else is this anyways)  │
╞════════════════╬═══════════════════════╬════════════════════════════╬════════════════════════════╬═══════════════════════════════════════════════╡
│ cross-platform ║        USB Key        │     USB/Bluetooth Key      │      USB/Bluetooth Key     │                 USB/Bluetooth Key             │
│ platform       ║  Fingerprint/Face/Pin │ Fingerprint/USB/Bluetooth  │         Fingerprint        │               "Insert security key"           │
└────────────────┴───────────────────────┴────────────────────────────┴────────────────────────────┴───────────────────────────────────────────────┘
4个回答

4
2020年10月19日,苹果公司发布了有关WebAuthn的解释:https://webkit.org/blog/11312/meet-face-id-and-touch-id-for-the-web/
从iOS 14和macOS Big Sur开始,支持FaceID和TouchID。为使其正常工作,对于每个allowCredentials条目,如果它是平台认证器,则需要添加transport: ["internal"],否则将继续提示插入USB/NFC令牌。
总之,需要这样做:
const publicKeyCredentialRequestOptions = {
    challenge: challengeBuffer,
    allowCredentials: [{
        id: 'credentialsIdentifierOne', // Windows Hello
        type: 'public-key'
    }, {
        id: 'credentialsIdentifierTwo', // iOS FaceID
        type: 'public-key'
    }],
    timeout: 60000
}

变成这个样子:

const publicKeyCredentialRequestOptions = {
    challenge: challengeBuffer,
    allowCredentials: [{
        id: 'credentialsIdentifierOne', // Windows Hello
        type: 'public-key',
        transports: ["internal"]
    }, {
        id: 'credentialsIdentifierTwo', // iOS FaceID
        type: 'public-key',
        transports: ["internal"]
    }],
    timeout: 60000
}

总体而言,这与规格一致,您可以通过在AuthenticatorResponse上调用.getTransports()来检索认证器的传输列表。这在教程中没有广泛记录,甚至支持得更少,因此要谨慎:

在设置跨平台认证器时,返回的值通常只包含已使用的传输方式,而不是认证器支持的所有传输方式。例如,插入YubiKey 5 NFC时仅返回["usb"]

因此,您应该完全避免为这些认证器设置 transports,或将它们设置为所有“非内部”传输方式:["usb", "nfc", "ble"]

至于调用.getTransports(),请检查其是否可用(2020年12月,Safari仍未具备该功能)。如果不可用,则根据您是请求平台认证器还是跨平台认证器,回退到适当的transports

另一个非常重要的点:如果您要在应用程序中启动SFSafariWebView处理此问题,无论是PWA、Cordova还是本机应用程序,它都会意外地失败。原因?苹果公司决定在向用户提供FaceID选项之前需要用户激活(点击/轻敲)。更糟糕的是,您不知道认证是否保证失败- iOS让其似乎一切正常运行,并提示用户插入其认证器,同时却知道不存在这样的认证器(凭据ID指向iOS已知的FaceID)。

解决上述问题的方法是添加一个额外的步骤,并要求用户在调用WebAuthn代码之前按下按钮中断认证流程。


3

是的,在iOS 13.3中,Safari/Chrome仍未支持指纹和面容ID。 - Thang Le

0
对我来说,使用 .Net 进行 WebAuthn 的编码转换真是一场噩梦!不过最终我还是解决了这个问题,但接着又遇到了 iOS 的问题。最后,在我弄清楚问题所在后,解决方案却非常简单。原来无论是 Mac 还是 iOS,都不喜欢我设置 AuthenticatorAttachment。因此,我最终通过一个函数检测操作系统并进行修复。这个函数我从这里得到的:getOS()
然后我按照以下方式编写了代码:
   var os = getOS();
   if (os == 'iOS' || os =='Mac OS') {
      credentialOptions.authenticatorSelection.authenticatorAttachment = undefined;
   }

0

Chrome将不再支持任何扩展程序:

https://bugs.chromium.org/p/chromium/issues/detail?id=1097972

有一个请求发送给chromium团队,希望他们能够为iOS 13、14提供WebAuth支持

https://bugs.chromium.org/p/chromium/issues/detail?id=1101804


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接