diff --git a/backend/network_inventory/settings/base.py b/backend/network_inventory/settings/base.py index 1ade96d..43358c5 100644 --- a/backend/network_inventory/settings/base.py +++ b/backend/network_inventory/settings/base.py @@ -50,7 +50,12 @@ INSTALLED_APPS = [ REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', - 'PAGE_SIZE': 10 + 'PAGE_SIZE': 10, + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework_simplejwt.authentication.JWTAuthentication' + 'rest_framework.authentication.SessionAuthentication', + 'rest_framework.authentication.BasicAuthentication', + ), } MIDDLEWARE = [ diff --git a/backend/network_inventory/urls.py b/backend/network_inventory/urls.py index d8374fd..6a14863 100644 --- a/backend/network_inventory/urls.py +++ b/backend/network_inventory/urls.py @@ -20,7 +20,10 @@ from django.conf import settings from django.conf.urls.static import static from rest_framework import routers - +from rest_framework_simplejwt.views import ( + TokenObtainPairView, + TokenRefreshView, +) from backups.urls import router as backups_router from computers.urls import router as computers_router from core.urls import router as core_router @@ -49,4 +52,6 @@ urlpatterns = [ path('api/', include(router.urls)), path('api/', include('rest_framework.urls')), path('api/admin/', admin.site.urls), + path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), + path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/backend/requirements/base.txt b/backend/requirements/base.txt index 5bbe62a..825f5be 100644 --- a/backend/requirements/base.txt +++ b/backend/requirements/base.txt @@ -1,6 +1,7 @@ wheel Django==3.1.4 djangorestframework +djangorestframework-simplejwt pyaml pytz django-guardian