def get(self, request, *args, **kwargs): challenge = os.urandom(32) request.session['webauthn_assert'] = webauthn_encode(challenge) data = webauthn.WebAuthnAssertionOptions( [ credential.webauthn_user for credential in request.profile. webauthn_credentials.select_related('user__user') ], challenge, ).assertion_dict return JsonResponse(data, encoder=WebAuthnJSONEncoder)
def get(self, request, *args, **kwargs): challenge = os.urandom(32) request.session['webauthn_attest'] = webauthn_encode(challenge) data = webauthn.WebAuthnMakeCredentialOptions( challenge=challenge, rp_id=settings.WEBAUTHN_RP_ID, rp_name=settings.SITE_NAME, user_id=request.profile.webauthn_id, username=request.user.username, display_name=request.user.username, user_verification='discouraged', icon_url=gravatar(request.user.email), attestation='none', ).registration_dict data['excludeCredentials'] = [{ 'type': 'public-key', 'id': { '_bytes': credential.cred_id }, } for credential in request.profile.webauthn_credentials.all()] return JsonResponse(data, encoder=WebAuthnJSONEncoder)