While trying to update https://webauthn.io to use webauthn==2.0.0 I discovered I needed to write logic to map JSON-serialized registration and authentication options to instances of this library's PublicKeyCredentialCreationOptions and PublicKeyCredentialRequestOptions. Moving away from Pydantic lost me the ability to call .parse_obj() on these objects to parse instances of these objects I pulled out of Redis as plain dict's, so manual mapping was required.
In v2.0.0 of this library, though, I added parse_registration_credential_json() and parse_authentication_credential_json() helpers to do this for WebAuthn responses. Now I need to do the same for their corresponding options. I've already begun this work and will put it up as a PR shortly.
Refactor guidance
Taking an example from registration: imagine a pre-v2.0.0 scenario in which a project using this library wanted to retrieve output from generate_registration_options(), serialized to JSON using webauthn.helpers.options_to_json() and then stored out of a cache or DB, and turn it back into an instance of PublicKeyCredentialCreationOptions:
py_webauthn v2.0.0+ removed use of Pydantic, though, so .parse_obj() is no longer available on PublicKeyCredentialCreationOptions. It will become possible to refactor away use of .parse_obj() with one of the helpers in this PR:
While trying to update https://webauthn.io to use
webauthn==2.0.0
I discovered I needed to write logic to map JSON-serialized registration and authentication options to instances of this library'sPublicKeyCredentialCreationOptions
andPublicKeyCredentialRequestOptions
. Moving away from Pydantic lost me the ability to call.parse_obj()
on these objects to parse instances of these objects I pulled out of Redis as plaindict
's, so manual mapping was required.In v2.0.0 of this library, though, I added
parse_registration_credential_json()
andparse_authentication_credential_json()
helpers to do this for WebAuthn responses. Now I need to do the same for their corresponding options. I've already begun this work and will put it up as a PR shortly.Refactor guidance
Taking an example from registration: imagine a pre-v2.0.0 scenario in which a project using this library wanted to retrieve output from
generate_registration_options()
, serialized to JSON usingwebauthn.helpers.options_to_json()
and then stored out of a cache or DB, and turn it back into an instance ofPublicKeyCredentialCreationOptions
:py_webauthn v2.0.0+ removed use of Pydantic, though, so
.parse_obj()
is no longer available onPublicKeyCredentialCreationOptions
. It will become possible to refactor away use of.parse_obj()
with one of the helpers in this PR: