diff --git a/config/settings/base.py b/config/settings/base.py index 0ab1b206..c49a0379 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -75,6 +75,7 @@ "django_celery_beat", "rest_framework_datatables", "rest_framework", + "rest_framework_simplejwt.token_blacklist", ] CORS_ALLOWED_ORIGINS = [ @@ -333,6 +334,9 @@ "DEFAULT_PAGINATION_CLASS": "rest_framework_datatables.pagination.DatatablesPageNumberPagination", "PAGE_SIZE": 50, "EXCEPTION_HANDLER": "sde_indexing_helper.utils.exceptions.custom_exception_handler", + "DEFAULT_AUTHENTICATION_CLASSES": ( + "rest_framework_simplejwt.authentication.JWTAuthentication", + ), } GITHUB_ACCESS_TOKEN = env("GITHUB_ACCESS_TOKEN") diff --git a/feedback/urls.py b/feedback/urls.py index 63ee219c..500cbf39 100644 --- a/feedback/urls.py +++ b/feedback/urls.py @@ -1,4 +1,5 @@ from django.urls import path +from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView from .views import ContactFormModelView, ContentCurationRequestView @@ -10,4 +11,12 @@ ContentCurationRequestView.as_view(), name="content-curation-request-api", ), + path( + "contact-us-api/token/", TokenObtainPairView.as_view(), name="token-obtain-pair" + ), + path( + "content-curation-request-api/token/refresh/", + TokenRefreshView.as_view(), + name="token-refresh", + ), ] diff --git a/feedback/views.py b/feedback/views.py index 6e4b0174..592bc8be 100644 --- a/feedback/views.py +++ b/feedback/views.py @@ -1,4 +1,5 @@ from rest_framework import generics +from rest_framework.permissions import IsAuthenticated from .models import ContentCurationRequest, Feedback from .serializers import ContentCurationRequestSerializer, FeedbackSerializer @@ -7,8 +8,10 @@ class ContactFormModelView(generics.CreateAPIView): queryset = Feedback.objects.all() serializer_class = FeedbackSerializer + permission_classes = [IsAuthenticated] class ContentCurationRequestView(generics.CreateAPIView): queryset = ContentCurationRequest.objects.all() serializer_class = ContentCurationRequestSerializer + permission_classes = [IsAuthenticated] diff --git a/requirements/base.txt b/requirements/base.txt index ef72e942..4e9686b5 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -29,3 +29,4 @@ scrapy==2.11.0 tqdm==4.65.0 xmltodict==0.13.0 django-cors-headers==4.3.1 +djangorestframework-simplejwt==5.3.1