Skip to content

Commit

Permalink
Fix WebAuthN registration
Browse files Browse the repository at this point in the history
  • Loading branch information
np5 committed Feb 29, 2024
1 parent e9463d8 commit b424d2e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/accounts/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from django.urls import reverse_lazy
from django.views.generic import DetailView, FormView, TemplateView
from webauthn import generate_registration_options, options_to_json, verify_registration_response
from webauthn.helpers.structs import PublicKeyCredentialDescriptor, RegistrationCredential
from webauthn.helpers import parse_registration_credential_json
from webauthn.helpers.structs import PublicKeyCredentialDescriptor
from accounts.events import post_verification_device_event
from accounts.forms import AddTOTPForm, CheckPasswordForm, RegisterWebAuthnDeviceForm, UpdateProfileForm
from accounts.models import UserTOTP, UserWebAuthn
Expand Down Expand Up @@ -132,7 +133,7 @@ def get_context_data(self, **kwargs):
def form_valid(self, form):
webauthn_challenge = self.request.session["webauthn_challenge"]
try:
credential = RegistrationCredential.parse_raw(form.cleaned_data["token_response"])
credential = parse_registration_credential_json(form.cleaned_data["token_response"])
verification = verify_registration_response(
credential=credential,
expected_challenge=trimmed_urlsafe_b64decode(webauthn_challenge["challenge"]),
Expand Down

0 comments on commit b424d2e

Please sign in to comment.