Set authentication to webapp DRF

This commit is contained in:
Aarni Halinen
2018-07-24 19:09:42 +03:00
parent 0ce6af8f7c
commit ac8fb0bfe3
3 changed files with 11 additions and 2 deletions
+2
View File
@@ -14,6 +14,8 @@ requests==2.11.1
django-nocaptcha-recaptcha==0.0.19 django-nocaptcha-recaptcha==0.0.19
django-cors-headers==2.0.1 django-cors-headers==2.0.1
djangorestframework==3.8.2 djangorestframework==3.8.2
PyJWT==1.6.4
djangorestframework-jwt==1.11.0
coverage==4.3.4 coverage==4.3.4
django-nose==1.4.5 django-nose==1.4.5
nose-exclude==0.5.0 nose-exclude==0.5.0
+2 -1
View File
@@ -96,6 +96,7 @@ INSTALLED_APPS = [
'kaehmy', 'kaehmy',
'ohlhafv', 'ohlhafv',
'rest_framework', 'rest_framework',
'rest_framework_jwt',
'django_nose', 'django_nose',
'bootstrap3', 'bootstrap3',
'django_tables2', 'django_tables2',
@@ -221,7 +222,7 @@ REST_FRAMEWORK = {
'rest_framework.permissions.IsAdminUser', 'rest_framework.permissions.IsAdminUser',
), ),
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication', 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
), ),
'DEFAULT_THROTTLE_CLASSES': ( 'DEFAULT_THROTTLE_CLASSES': (
'members.throttles.BurstRateThrottle', 'members.throttles.BurstRateThrottle',
+7 -1
View File
@@ -10,7 +10,7 @@ from django.views.decorators.http import require_http_methods
# from django.conf import settings # from django.conf import settings
# from django.utils import timezone # from django.utils import timezone
from rest_framework import viewsets from rest_framework import viewsets
# from rest_framework import permissions, authentication from rest_framework.permissions import IsAuthenticatedOrReadOnly
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.reverse import reverse from rest_framework.reverse import reverse
@@ -29,31 +29,37 @@ from members.views.utils import *
class EventViewSet(viewsets.ModelViewSet): class EventViewSet(viewsets.ModelViewSet):
queryset = Event.objects.all() queryset = Event.objects.all()
serializer_class = EventSerializer serializer_class = EventSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
class SignupFormViewSet(viewsets.ModelViewSet): class SignupFormViewSet(viewsets.ModelViewSet):
queryset = SignupForm.objects.all() queryset = SignupForm.objects.all()
serializer_class = SignupFormSerializer serializer_class = SignupFormSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
class SignupViewSet(viewsets.ModelViewSet): class SignupViewSet(viewsets.ModelViewSet):
queryset = Signup.objects.all() queryset = Signup.objects.all()
serializer_class = SignupSerializer serializer_class = SignupSerializer
permission_classes = []
class SavedQuestionsViewSet(viewsets.ModelViewSet): class SavedQuestionsViewSet(viewsets.ModelViewSet):
queryset = TemplateQuestion.objects.all() queryset = TemplateQuestion.objects.all()
serializer_class = SavedQuestionsSerializer serializer_class = SavedQuestionsSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
class FeedViewSet(viewsets.ModelViewSet): class FeedViewSet(viewsets.ModelViewSet):
queryset = Feed.objects.all() queryset = Feed.objects.all()
serializer_class = FeedSerializer serializer_class = FeedSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
class ContactsViewSet(viewsets.ReadOnlyModelViewSet): class ContactsViewSet(viewsets.ReadOnlyModelViewSet):
queryset = Official.objects.all() queryset = Official.objects.all()
serializer_class = ContactsSerializer serializer_class = ContactsSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
# -- OLD CODEBASE -- # # -- OLD CODEBASE -- #