diff --git a/apiserver/apiserver/settings.py b/apiserver/apiserver/settings.py index 8d3e872..825ce5a 100644 --- a/apiserver/apiserver/settings.py +++ b/apiserver/apiserver/settings.py @@ -47,6 +47,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', + 'rest_framework.authtoken', 'apiserver.api', ] @@ -139,10 +140,20 @@ if DEBUG: 'rest_framework.renderers.BrowsableAPIRenderer', ) +DEFAULT_AUTHENTICATION_CLASSES = ( + 'rest_framework.authentication.TokenAuthentication', + ) + +if DEBUG: + DEFAULT_AUTHENTICATION_CLASSES += ( + 'rest_framework.authentication.SessionAuthentication', + ) + REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': 20, 'DEFAULT_RENDERER_CLASSES': DEFAULT_RENDERER_CLASSES, + 'DEFAULT_AUTHENTICATION_CLASSES': DEFAULT_AUTHENTICATION_CLASSES, } LOGGING = { diff --git a/apiserver/apiserver/urls.py b/apiserver/apiserver/urls.py index 503f081..e7cdd3b 100644 --- a/apiserver/apiserver/urls.py +++ b/apiserver/apiserver/urls.py @@ -10,4 +10,5 @@ router.register(r'users', views.UserViewSet) urlpatterns = [ path('', include(router.urls)), path('admin/', admin.site.urls), + path('api-auth/', include('rest_framework.urls')), ]