From 1ebc5bfd2bb84940179379f1158505b18632a827 Mon Sep 17 00:00:00 2001 From: Mohamed ElKalioby Date: Mon, 13 Jun 2022 17:18:00 +0300 Subject: [PATCH] Upgrading to FIDO2==1.0.0 --- example/example/settings.py | 4 ++-- mfa/FIDO2.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/example/example/settings.py b/example/example/settings.py index cc9633c..6c1b772 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -146,5 +146,5 @@ MFA_SUCCESS_REGISTRATION_MSG="Go to Home" TOKEN_ISSUER_NAME="PROJECT_NAME" #TOTP Issuer name U2F_APPID="https://localhost" #URL For U2F -FIDO_SERVER_ID=u"local.mkalioby.com" # Server rp id for FIDO2, it the full domain of your project -FIDO_SERVER_NAME=u"TestApp" +FIDO_SERVER_ID="localhost" # Server rp id for FIDO2, it the full domain of your project +FIDO_SERVER_NAME="TestApp" diff --git a/mfa/FIDO2.py b/mfa/FIDO2.py index 576c0df..dcdf9f2 100644 --- a/mfa/FIDO2.py +++ b/mfa/FIDO2.py @@ -1,6 +1,6 @@ from fido2.client import Fido2Client from fido2.server import Fido2Server, PublicKeyCredentialRpEntity -from fido2.webauthn import AttestationObject, AuthenticatorData +from fido2.webauthn import AttestationObject, AuthenticatorData, CollectedClientData from django.template.context_processors import csrf from django.views.decorators.csrf import csrf_exempt from django.shortcuts import render @@ -28,7 +28,7 @@ def recheck(request): def getServer(): """Get Server Info from settings and returns a Fido2Server""" - rp = PublicKeyCredentialRpEntity(settings.FIDO_SERVER_ID, settings.FIDO_SERVER_NAME) + rp = PublicKeyCredentialRpEntity(id=settings.FIDO_SERVER_ID, name=settings.FIDO_SERVER_NAME) return Fido2Server(rp) @@ -51,7 +51,7 @@ def complete_reg(request): try: data = cbor.decode(request.body) - client_data = Fido2Client(data['clientDataJSON']) + client_data = CollectedClientData(data['clientDataJSON']) att_obj = AttestationObject((data['attestationObject'])) server = getServer() auth_data = server.register_complete( @@ -68,6 +68,8 @@ def complete_reg(request): uk.save() return HttpResponse(simplejson.dumps({'status': 'OK'})) except Exception as exp: + import traceback + print(traceback.format_exc()) try: from raven.contrib.django.raven_compat.models import client client.captureException() @@ -112,7 +114,7 @@ def authenticate_complete(request): credentials = getUserCredentials(username) data = cbor.decode(request.body) credential_id = data['credentialId'] - client_data = Fido2Client(data['clientDataJSON']) + client_data = CollectedClientData(data['clientDataJSON']) auth_data = AuthenticatorData(data['authenticatorData']) signature = data['signature'] try: