From d38b5378b0c6ceb7b743bbb476ff6a65084d86ac Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Feb 2019 01:06:21 +0100 Subject: [PATCH] More logging --- otpauth/serializer.py | 5 ++++- otpauth/views.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/otpauth/serializer.py b/otpauth/serializer.py index 2b7e74e..691e5a5 100644 --- a/otpauth/serializer.py +++ b/otpauth/serializer.py @@ -47,13 +47,16 @@ class TokenSerializer(serializers.Serializer): # 1. Verify that the connection might authenticate try: + logger.debug("Checking in db for name:{} & realm:{}".format( + auth_name, auth_realm + )) db_instance = otpauth.models.OTPSeed.objects.get(name=auth_name, realm=auth_realm) except (OTPSeed.MultipleObjectsReturned, OTPSeed.DoesNotExist): logger.error("OTPSeed name: {}, realm: {} does not exist".format( auth_name, auth_realm )) raise exceptions.AuthenticationFailed() - + logger.debug("Found seed: {}".format(db_instance.seed)) totp = pyotp.TOTP(db_instance.seed) logger.debug("calculated token = {}".format(totp.now())) diff --git a/otpauth/views.py b/otpauth/views.py index 10e7351..4134bc3 100644 --- a/otpauth/views.py +++ b/otpauth/views.py @@ -7,6 +7,11 @@ from rest_framework.response import Response from django.http import JsonResponse from otpauth.serializer import VerifySerializer, OTPSerializer, TokenSerializer from otpauth.models import OTPSeed +import json +import logging + +logger = logging.getLogger(__name__) + class OTPVerifyViewSet(viewsets.ModelViewSet): serializer_class = OTPSerializer @@ -20,7 +25,7 @@ class OTPVerifyViewSet(viewsets.ModelViewSet): Now we inspect the payload and return ok, if they also verify """ - + logger.debug("in verify {}".format(json.dumps(request.data))) serializer = VerifySerializer(data=request.data) if serializer.is_valid(): serializer.save()