Skip to content
Snippets Groups Projects
Commit 5d08b429 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

adding token authentication to ATDB-LDV

parent eea1f497
No related branches found
No related tags found
2 merge requests!209adding token authentication to ATDB-LDV,!208adding token authentication to ATDB-LDV
...@@ -24,6 +24,7 @@ INSTALLED_APPS = [ ...@@ -24,6 +24,7 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'rest_framework', 'rest_framework',
'rest_framework.authtoken',
'corsheaders', 'corsheaders',
'django_filters', 'django_filters',
'django_extensions', 'django_extensions',
...@@ -72,6 +73,9 @@ REST_FRAMEWORK = { ...@@ -72,6 +73,9 @@ REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
], ],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_FILTER_BACKENDS': ( 'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend', 'django_filters.rest_framework.DjangoFilterBackend',
), ),
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 1.0.0 (11 feb 2021 - 15:00) <p class="footer"> Version 1.0.0 (4 mar 2021 - 11:00)
</div> </div>
......
...@@ -92,4 +92,6 @@ urlpatterns = [ ...@@ -92,4 +92,6 @@ urlpatterns = [
path('tasks/<int:pk>/hold/<hold_it>/<page>', views.Hold, name='task-hold-resume'), path('tasks/<int:pk>/hold/<hold_it>/<page>', views.Hold, name='task-hold-resume'),
path('tasks/<int:pk>/hold/<hold_it>', views.Hold, name='task-hold-resume'), path('tasks/<int:pk>/hold/<hold_it>', views.Hold, name='task-hold-resume'),
path('tasks/<int:pk>/query-hold/<hold_it>/<query_params>', views.HoldQuery, name='query-hold-resume'), path('tasks/<int:pk>/query-hold/<hold_it>/<query_params>', views.HoldQuery, name='query-hold-resume'),
path('hello/', views.HelloView.as_view(), name='hello'),
] ]
...@@ -10,6 +10,9 @@ from django.http import QueryDict ...@@ -10,6 +10,9 @@ from django.http import QueryDict
from rest_framework import generics, pagination from rest_framework import generics, pagination
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
import django_filters import django_filters
from django_filters import rest_framework as filters from django_filters import rest_framework as filters
...@@ -522,7 +525,6 @@ class TaskListViewAPI(generics.ListCreateAPIView): ...@@ -522,7 +525,6 @@ class TaskListViewAPI(generics.ListCreateAPIView):
""" """
model = Task model = Task
queryset = Task.objects.all().order_by('-priority', 'id') queryset = Task.objects.all().order_by('-priority', 'id')
# serializer_class = TaskSerializer
# using the Django Filter Backend - https://django-filter.readthedocs.io/en/latest/index.html # using the Django Filter Backend - https://django-filter.readthedocs.io/en/latest/index.html
filter_backends = (filters.DjangoFilterBackend,) filter_backends = (filters.DjangoFilterBackend,)
...@@ -1004,3 +1006,13 @@ class GetUniqueValuesForKey(generics.ListAPIView): ...@@ -1004,3 +1006,13 @@ class GetUniqueValuesForKey(generics.ListAPIView):
return Response({ return Response({
'error': str(error) 'error': str(error)
}) })
# 4 mar 2022
# this is a test class to test token authentication
# can be removed if it all also works in production
class HelloView(APIView):
permission_classes = (IsAuthenticated,)
queryset = Task.objects.all()
def get(self, request):
content = {'message': 'Hello, World!'}
return Response(content)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment