mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Fixed warnings reported by drf-speculator
- Unable to guess serializer of AccountViewSet, IdentityViewSet and ParametersViewSet - There was no OpenApiAuthenticationExtension registered for the subclass JWTAuthenticationWith2FA
This commit is contained in:
@@ -183,6 +183,7 @@ class IdentityViewSet(viewsets.ViewSet):
|
||||
"""Viewset for identities."""
|
||||
|
||||
permission_classes = (permissions.IsAuthenticated, )
|
||||
serializer_class = None
|
||||
|
||||
def list(self, request, **kwargs):
|
||||
"""Return all identities."""
|
||||
|
||||
@@ -19,6 +19,7 @@ class AccountViewSet(viewsets.ViewSet):
|
||||
"""
|
||||
|
||||
permission_classes = (permissions.IsAuthenticated, )
|
||||
serializer_class = None
|
||||
|
||||
@action(methods=["post"], detail=False, url_path="tfa/setup")
|
||||
def tfa_setup(self, request):
|
||||
|
||||
@@ -4,6 +4,7 @@ from django.urls import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from django_otp.models import Device
|
||||
from drf_spectacular.contrib.rest_framework_simplejwt import SimpleJWTScheme
|
||||
from rest_framework import status
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||
@@ -44,3 +45,8 @@ class JWTAuthenticationWith2FA(JWTAuthentication):
|
||||
if user.tfa_enabled:
|
||||
self.verify_user(request, user)
|
||||
return user, token
|
||||
|
||||
|
||||
class SimpleJWTWith2FAScheme(SimpleJWTScheme):
|
||||
target_class = 'modoboa.core.drf_authentication.JWTAuthenticationWith2FA'
|
||||
name = 'jwt2FAAuth'
|
||||
|
||||
@@ -12,6 +12,7 @@ class ParametersViewSet(viewsets.ViewSet):
|
||||
"""Parameter viewset."""
|
||||
|
||||
lookup_value_regex = r"\w+"
|
||||
serializer_class = None
|
||||
|
||||
@extend_schema(responses=serializers.ApplicationSerializer(many=True))
|
||||
@action(methods=["get"], detail=False)
|
||||
|
||||
Reference in New Issue
Block a user