asbiin / laravel-webauthn

Webauthn adapter for Laravel
MIT License
266 stars 37 forks source link

Webauthn\AuthenticatorSelectionCriteria::createFromArray(): Argument #1 ($json) must be of type array, Webauthn\AuthenticatorSelectionCriteria given #452

Closed lewislarsen closed 12 months ago

lewislarsen commented 12 months ago

Hi there,

I am using your demo application as a guide to get webauthn working inside my project but I've run into a bit of an issue when adding a key. Please let me know if you need additional information, I'd be more than happy to provide.

A snippet of the error is below alongside the full error on pastebin due to its length.

Versions: laravel-webauthn - 4.1.1 laravel - 10.22.0 @simplewebauthn/browser - 8.0.2 PHP 8.2.10 (using Valet)

[2023-09-25 00:35:22] local.INFO: The data has been loaded  
[2023-09-25 00:35:22] local.DEBUG: Public Key Credential {"publicKeyCredential":{"Webauthn\\PublicKeyCredential":"{\"type\":\"public-key\",\"id\":\"NyRMIrAWYpN_2_gdDq8QhxgzAjamKI4MYW6ulpSznrA\",\"transports\":[\"internal\"]}"}} 
[2023-09-25 00:35:22] local.ERROR: Webauthn\AuthenticatorSelectionCriteria::createFromArray(): Argument #1 ($json) must be of type array, Webauthn\AuthenticatorSelectionCriteria given, called in /Users/lewislarsen/sites/tabship/vendor/web-auth/webauthn-lib/src/PublicKeyCredentialCreationOptions.php on line 275 {"userId":"2d55b8ba-4688-4351-8826-5402f513ad8e","exception":"[object] (TypeError(code: 0): Webauthn\\AuthenticatorSelectionCriteria::createFromArray(): Argument #1 ($json) must be of type array, Webauthn\\AuthenticatorSelectionCriteria given, called in /Users/lewislarsen/sites/tabship/vendor/web-auth/webauthn-lib/src/PublicKeyCredentialCreationOptions.php on line 275 at /Users/lewislarsen/sites/tabship/vendor/web-auth/webauthn-lib/src/AuthenticatorSelectionCriteria.php:180)
[stacktrace]
#0 /Users/lewislarsen/sites/tabship/vendor/web-auth/webauthn-lib/src/PublicKeyCredentialCreationOptions.php(275): Webauthn\\AuthenticatorSelectionCriteria::createFromArray(Object(Webauthn\\AuthenticatorSelectionCriteria))

Full log: https://pastebin.com/Q8LUjbSA

Thank you!

willbrowningme commented 12 months ago

It is caused by the latest version of webauthn-framework v4.7.1.

A temporary fix is to add:

"web-auth/webauthn-lib": "4.7.0"

to your composer.json to lock it to v4.7.0.

lewislarsen commented 12 months ago

It is caused by the latest version of webauthn-framework v4.7.1.

A temporary fix is to add:

"web-auth/webauthn-lib": "4.7.0"

to your composer.json to lock it to v4.7.0.

That did the job, thank you! :)

willbrowningme commented 11 months ago

I think perhaps this should be reopened as the above isn't a long term solution. https://github.com/web-auth/webauthn-framework/issues/483 has some more details and a potential fix.

Edit: manged to get it working on the latest versions.