Problem/Motivation
There used to be a jsonSerialize() method on the PublicKeyCredentialCreationOptions but now that is gone.
json_encode should not be used as in 5.0.+ the objects do not implement the JsonSerializable interface.
But it looks like the serializePublicKeyCredential() method could be modified to accept PublicKeyCredentialCreationOptions.
I have tried this with a quick test by hacking the module and while it did serialize my object:
{"challenge":"1rdlxMvJcwva-KAWBVGp7Q","rp":{"id":"localhost","name":"Drupal","icon":""},"user":{"id":"MjkzZTE0NjQtZWU2Yy00NWEwLWFmM2UtNGI2ODlmNWFkYWRj","name":"goat@meals.com","displayName":"goat@meals.com"},"pubKeyCredParams":[{"type":"public-key","alg":-7},{"type":"public-key","alg":-257}],"authenticatorSelection":{"userVerification":"preferred","residentKey":"preferred"},"excludeCredentials":[]}
Passing that into simplewebauthn/browser startRegistration() resulted in "TypeError: base64URLString is undefined"
This used to work so I have confidence I'm not doing anything else stupid, but I'm unable to find why this is not working at the moment.
Proposed resolution
Add PublicKeyCredentialCreationOptions as allowed option to pass into Webauthn::serializePublicKeyCredential()
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3490555__Allow_serialization_of_PublicKeyCredentialCreationOptions.patch | 2.76 KB | dahousecat |
Issue fork webauthn_framework-3490555
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dahousecat commentedI did try and create an MR but I'm having some issues with permissions when pushing and it's late so will just attach a patch for now.
Comment #6
ptmkenny commentedThanks for this issue. For the serializer, I think it will be safe to accept PublicKeyCredentialOptions, so I created an MR to do that.
Please review and let me know if this solves your issue.
I'm guessing that's because webauthn-lib 5 no longer serializes to JSON objects, so that's not "supposed" to work anymore? I do not know why this change was made, but this module is attempting to follow the underlying library as closely as possible.
Here's the relevant page from the docs: https://webauthn-doc.spomky-labs.com/pure-php/authenticator-registration
Comment #7
ptmkenny commentedComment #8
dahousecat commentedHi, thanks for the swift reply :)
The MR looks good to me, better than my patch as simpler.
Yes, it's a shame this update has so many breaking changes but thanks for the pointer - I'll review the updated documentation.
Comment #9
dahousecat commentedComment #11
ptmkenny commentedThanks for the review!
Yes, there are a lot of breaking changes; I need to do more testing before I make a new release with 5.x support.