Closed P4sca1 closed 3 years ago
At first blush, userVerification: 'discouraged'
may not work with FaceID since it's a user-verifying authenticator by design. I'll investigate further but in the meantime can you try attestation without that option?
Hmm, I'm having trouble reproducing this on my end. I duplicated your exact attestation options via the example server I provide in this monorepo with server@0.10.1, but everything is working as expected. Safari prompted for Face ID on the first registration attempt, and the attestation verified correctly:
On a lark I tried downgrading to server@0.10.0 and it errored out as expected (this is what prompted the release of v0.10.1):
There's one more thing I can try...
I have no idea what's going on. I tried installing v0.10.0, confirmed it was broken, then upgraded in-place to v0.10.1. After upgrading (previously I had been running rm -rf node_modules
before trying installing either version), attestation verification for Face ID worked no problem. I have never experienced Safari requiring me to initiate attestation twice, either, so I have no advice for that problem.
Can you try clearing out node_modules, re-running npm install
, then retry attestation? Maybe you're suffering from JS package management oddities 😅
Also I noticed that you need to start the attestation 2 times to be able to use FaceID. In the first attempt, Safari only asks for a security key. Only when you cancel and restart the attestation, you can select from security key and FaceID. I don`t know whether this is an issue with the attestation options or with Safari.
This issue can be fixed by not using userVerification: 'discouraged'
. The problem is that I dont want YubiKeys to ask for a pin, because WebAuthn is a second factor in my authentication flow. Requiring a pin would result in 3 factors being required (password, physical key and pin), which would be too much. Do you know a solution to this problem?
Turning userVerification back on does not fix the error. I am using @simplewebauthn/server
version 0.10.1
:
"@simplewebauthn/server@0.10.1":
version "0.10.1"
resolved "https://registry.yarnpkg.com/@simplewebauthn/server/-/server-0.10.1.tgz#b31c8f9a0c74be43113b5fc7ae691b743301b11e"
integrity sha512-f0SZ/pRU+MyjLlLmY8epo+F5YFgSyMkyhRUZKxErkDrcpnOF5x3eFFkz0XKLFsqApUK4K/aqcs6k3VtRPhZTuA==
dependencies:
"@peculiar/asn1-android" "2.0.8"
"@peculiar/asn1-schema" "2.0.8"
"@peculiar/asn1-x509" "2.0.10"
"@simplewebauthn/typescript-types" "^0.10.0"
base64url "3.0.1"
cbor "5.0.2"
elliptic "6.5.3"
jsrsasign "8.0.20"
jwk-to-pem "2.0.4"
node-fetch "2.6.0"
node-rsa "1.1.1"
iOS Version: 14.0.1 (iPhone XR)
For face/touch ID to show up in the dialog, the webauthn create/get methods need to be called in a handler that is user initiated, e.g. in a click handler. If you call these methods automatically (on load) it will only show the security key option.
Thanks for the info, that’s good to know. I call them inside a vue @click
handler.
It also does not show up in the list when you discourage user verification.
It also does not show up in the list when you discourage user verification.
This assumption was wrong. I have set userVerification: 'discouraged'
and it shows FaceID everytime.
The issue was that I was using the vue @click
handler on my button and it seems like Safari was not always considering this as a user action. Changing the listener to @click.native
fixes the issue. Thanks for giving the hint @madwizard-thomas.
Using TouchID on iPad 6 (2018) or FaceID on iPhone xR both result in the error Cannot get schema for 'Certificate' target
.
However I can confirm that it works fine with the example project in this repo. I will continue to find out what causes the issue in my codebase and get back here.
Another reason why FaceID was not showing up in the list was because Apple does not support async event handlers completely.
They added support for asynx XHR / fetch requests in the listener though. More details can be found here: https://bugs.webkit.org/show_bug.cgi?id=213595
Because of that you cannot await promises other than XHR / fetch requests in the button event listener. I was using dynamic imports to only load @simplewebauthn/browser
when the button was clicked which caused Sign in with FaceID to only show up in the list after the 2nd time the button was pressed (as the import is no longer async then, because it has already been loaded).
After hours of debugging @MasterKale and I figured out that the root cause of the issue is using the yarn
package manager instead of npm
. This is because @simplewebauthn/server
requires @peculiar/asn1-schema
version 2.0.8 while @peculiar/asn1-x509
(which is also a dependency of @simplewebauthn/server
) uses version ^2.0.8 (2.0.23 as of now). Those 2 versions seem to be incompatible. The npm
and yarn
resolution algorithms differ in some way that causes this issue.
A temporary fix is to add a yarn resolution.
This is a dependency issue when using the yarn
package manager. For a temporary fix, add the following to your package.json
and then run yarn
.
"resolutions": {
"@peculiar/asn1-schema": "2.0.8"
},
startAttestation
in a native button click listener.Maybe it is worth adding those hints to the docs? @MasterKale
I don't use Yarn myself so this was certainly an interesting error to debug.
Regarding the "resolutions"
fix, I'm trying to figure out how to handle this in a dev-friendly manner. From what I'm reading on https://classic.yarnpkg.com/en/docs/selective-version-resolutions/#toc-limitations-Caveats, resolutions need to be declared in the root-level package.json and such declarations in third-party packages may not be respected:
- Nested packages may not work properly.
So maybe this becomes a documentation update? I'm still investigating.
As for the Safari issues, that knowledge can probably be captured in the docs site as you suggested @P4sca1. I'll start drafting something.
Issue 1 should be fixed with the new server@0.10.2 I just published. I went ahead and updated the ASN.1 parsing libraries so everything is using the same version, sub-dependencies included. No one should have to add "resolutions"
to their Yarn projects (for now).
Issue 2 will be addressed with an eventual docs update to the homepage.
The Safari-specific gotchas captured in @P4sca1's Issue 2 have been captured here: https://simplewebauthn.dev/docs/advanced/safari-browser
Thanks! Great new docs by the way :)
https://github.com/MasterKale/SimpleWebAuthn/pull/62#issuecomment-707351356
Unfortunately, this happened again. I'm getting the issue 1 error again, but I was able to solve it by adding a resolution and force it to install @peculiar/asn1-schema@2.0.26
@Ponjimon PR #68 restored the use of carets in versions in server's package.json, which means future versions of the asn1-
packages should now get updates without me having to update server . I haven't cut a release with that fix, though - once #67 gets in I'll publish a new release to NPM.
@Ponjimon (and maybe @P4sca1 too) I just published @simplewebauthn/server@v0.10.4 that un-pins its dependencies including the @peculiar/asn1-
packages. This should allow your projects to pick up the latest versions of these packages:
"@peculiar/asn1-android": "^2.0.26",
"@peculiar/asn1-schema": "^2.0.26",
"@peculiar/asn1-x509": "^2.0.26",
Can you try out your projects with this latest release and see if this more completely resolves Issue 1 without needing to resort to "resolutions"
?
I'm assuming no news is good news so I'm closing this issue.
Sorry, didn’t had time to test this. I will open a new issue if the issue occurs again. Thanks for your effort!
There is an error thrown in
verifyAssertionOptions
when using apple FaceID to solve the attestation request.Attestation options:
Attestation response (SimpleWebAuthn Debugger link)
Error:
Also I noticed that you need to start the attestation 2 times to be able to use FaceID. In the first attempt, Safari only asks for a security key. Only when you cancel and restart the attestation, you can select from security key and FaceID. I don`t know whether this is an issue with the attestation options or with Safari.