Stormbase / django-otp-webauthn

Passkey support for Django. Currently in early stages of development and not ready for production use!
BSD 3-Clause "New" or "Revised" License
10 stars 2 forks source link

Fixed exception raised in as_credential_descriptors() when testing for valid AuthenticatorTransport enum values. #6

Closed jmichalicek closed 2 months ago

jmichalicek commented 2 months ago

This resolves https://github.com/Stormbase/django-otp-webauthn/issues/5

Prior to python 3.12 trying to use "foo" in SomeEnum raises an exception. This was added in 3.12.

Since trying to access an enum member using SomeEnum("a_value") raises a ValueError when that is not a valid value but returns the enum member when it exists, I have updated models.as_credential_descriptors() to just directly try to append AuthenticatorTransport(t) to the list of transports in a try/except block and pass on a ValueError.

With the way the code has been re-organized it looks like the problem code may only get called when registering a passkey on the current main branch rather than when logging in as it does with version 0.1.2 on pypi.

After making this change I can both register a passkey and log in with the created passkey on the main branch code on python 3.11 and 3.12.