darkedges / capacitor-native-webauthn

capacitor webauthn
7 stars 8 forks source link

Got "NoCredentialException" When using startAuthentication #2

Open waggyman opened 11 months ago

waggyman commented 11 months ago

DESCRIPTION

I forked this project because I want to use it in my ionic project (using capacitor 5). Actually it's working well on startRegistration method. It show me the Biometric Pop Up.

After registering passkey and store it in my server.

I want to authenticate with this flow:

  1. Getting the passkey JSON Request:
    
    GET: /api/generate_passkey?origin=android:key

{ "challenge": "generatedString", "allowCredentials": [ { "id": "same as the register passkey response" } ], "rpId": "my domain", "userVerification": "required" }



2. use the response when calling `startAuthentication()` method.
3. But in the response I got the error "NoCredentialException"

#### QEUSTION
Do you know what causing that NoCredentialException error?
darkedges commented 10 months ago

Apologies for the delay in replying, have not been monitoring.

Have you tried sending a request with a blank list of existing credentials?

{
  "challenge": "T1xCsnxM2DNL2KdK5CLa6fMhD7OBqho6syzInk_n-Uo",
  "allowCredentials": [],
  "timeout": 1800000,
  "userVerification": "required",
  "rpId": "credential-manager-app-test.glitch.me"
}

It feels like it cannot find the credentials in the allowCredentials array.

Take a look at https://simplewebauthn.dev/docs/packages/server#1-generate-authentication-options on how to create a responses that is more compliant.

Spec here https://www.w3.org/TR/webauthn-2/#dictdef-publickeycredentialdescriptor