From d706e164df554b01614af81f391f0dec7d7d145f Mon Sep 17 00:00:00 2001 From: EvilPug <3608690@gmail.com> Date: Fri, 19 Apr 2024 16:00:28 +0300 Subject: [PATCH 1/4] fix(djoser): Added empty serializer_class for correct schema generation --- djoser/views.py | 2 ++ djoser/webauthn/views.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/djoser/views.py b/djoser/views.py index c0de757c..09b9e46a 100644 --- a/djoser/views.py +++ b/djoser/views.py @@ -5,6 +5,7 @@ from rest_framework.decorators import action from rest_framework.exceptions import NotFound from rest_framework.response import Response +from rest_framework.serializers import Serializer from djoser import signals, utils from djoser.compat import get_user_email @@ -30,6 +31,7 @@ def _action(self, serializer): class TokenDestroyView(views.APIView): """Use this endpoint to logout user (remove user authentication token).""" + serializer_class = Serializer permission_classes = settings.PERMISSIONS.token_destroy def post(self, request): diff --git a/djoser/webauthn/views.py b/djoser/webauthn/views.py index 255105d7..9bb201f0 100644 --- a/djoser/webauthn/views.py +++ b/djoser/webauthn/views.py @@ -3,6 +3,7 @@ from rest_framework import status from rest_framework.permissions import AllowAny from rest_framework.response import Response +from rest_framework.serializers import Serializer from rest_framework.settings import api_settings from rest_framework.views import APIView from webauthn import ( @@ -31,6 +32,7 @@ class SingupRequestView(APIView): permission_classes = (AllowAny,) + serializer_class = Serializer def post(self, request): serializer = WebauthnSignupSerializer(data=request.data) @@ -95,6 +97,7 @@ def post(self, request, ukey): class LoginRequestView(APIView): permission_classes = (AllowAny,) + serializer_class = Serializer def post(self, request): serializer = WebauthnLoginSerializer(data=request.data) From 84a4d88ab94d77e12de0c79b85bb81a60a8d6ac3 Mon Sep 17 00:00:00 2001 From: EvilPug <3608690@gmail.com> Date: Fri, 19 Apr 2024 16:13:54 +0300 Subject: [PATCH 2/4] fix(webauthn): Fixed a typo (SignupRequestView) --- djoser/webauthn/urls.py | 2 +- djoser/webauthn/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/djoser/webauthn/urls.py b/djoser/webauthn/urls.py index 0f9c4095..86ff63af 100644 --- a/djoser/webauthn/urls.py +++ b/djoser/webauthn/urls.py @@ -5,7 +5,7 @@ urlpatterns = [ re_path( r"^signup_request/$", - views.SingupRequestView.as_view(), + views.SignupRequestView.as_view(), name="webauthn_signup_request", ), re_path( diff --git a/djoser/webauthn/views.py b/djoser/webauthn/views.py index 9bb201f0..ae475d38 100644 --- a/djoser/webauthn/views.py +++ b/djoser/webauthn/views.py @@ -30,7 +30,7 @@ User = get_user_model() -class SingupRequestView(APIView): +class SignupRequestView(APIView): permission_classes = (AllowAny,) serializer_class = Serializer From 646c25104ab9721992a37db6f8d26c58cce165fe Mon Sep 17 00:00:00 2001 From: EvilPug <3608690@gmail.com> Date: Thu, 25 Apr 2024 21:42:00 +0300 Subject: [PATCH 3/4] chore(webauthn): replaced Serializer with Webauthn Serializers --- djoser/webauthn/views.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/djoser/webauthn/views.py b/djoser/webauthn/views.py index ae475d38..ab7b725d 100644 --- a/djoser/webauthn/views.py +++ b/djoser/webauthn/views.py @@ -3,7 +3,6 @@ from rest_framework import status from rest_framework.permissions import AllowAny from rest_framework.response import Response -from rest_framework.serializers import Serializer from rest_framework.settings import api_settings from rest_framework.views import APIView from webauthn import ( @@ -32,7 +31,7 @@ class SignupRequestView(APIView): permission_classes = (AllowAny,) - serializer_class = Serializer + serializer_class = WebauthnSignupSerializer def post(self, request): serializer = WebauthnSignupSerializer(data=request.data) @@ -97,7 +96,7 @@ def post(self, request, ukey): class LoginRequestView(APIView): permission_classes = (AllowAny,) - serializer_class = Serializer + serializer_class = WebauthnLoginSerializer def post(self, request): serializer = WebauthnLoginSerializer(data=request.data) From d6dba8a0f26366c6a2ee042aae68e884d689ac37 Mon Sep 17 00:00:00 2001 From: EvilPug <3608690@gmail.com> Date: Sun, 5 May 2024 23:03:27 +0300 Subject: [PATCH 4/4] chore(webauthn): Fixed serializer reassignments --- djoser/webauthn/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/djoser/webauthn/views.py b/djoser/webauthn/views.py index ab7b725d..c57a3399 100644 --- a/djoser/webauthn/views.py +++ b/djoser/webauthn/views.py @@ -34,7 +34,7 @@ class SignupRequestView(APIView): serializer_class = WebauthnSignupSerializer def post(self, request): - serializer = WebauthnSignupSerializer(data=request.data) + serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) co = serializer.save() @@ -99,7 +99,7 @@ class LoginRequestView(APIView): serializer_class = WebauthnLoginSerializer def post(self, request): - serializer = WebauthnLoginSerializer(data=request.data) + serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) co = CredentialOptions.objects.get( username=serializer.validated_data["username"]