Skip to content

Commit

Permalink
Upgrading to FIDO2==1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalioby committed Jun 13, 2022
1 parent d8b10bc commit 1ebc5bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,5 @@
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"
10 changes: 6 additions & 4 deletions mfa/FIDO2.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)


Expand All @@ -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(
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1ebc5bf

Please sign in to comment.