Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

jmichalicek
Copy link
Contributor

This resolves #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.

…r valid AuthenticatorTransport enum values.

This resolves Stormbase#5
Copy link
Member

@Stormheg Stormheg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I wasn't aware this was a Python 3.12+ feature.

I'll make a release out of this soon.

@Stormheg Stormheg merged commit 2872746 into Stormbase:main Jul 1, 2024
@jmichalicek jmichalicek deleted the issue-5-fix-enum-test branch July 3, 2024 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

TypeError at /webauthn/authentication/begin/ unsupported operand type(s) for 'in': 'str' and 'EnumType'
2 participants