Browse Source
Merge pull request #317 from CatalystCode/enhancement/api-auth
Enhancement/Enable token authorization for API calls
pull/344/head
Hiroki Nakayama
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
0 deletions
-
app/api/urls.py
-
app/app/settings.py
|
|
@ -1,4 +1,5 @@ |
|
|
|
from django.urls import path |
|
|
|
from rest_framework.authtoken.views import obtain_auth_token |
|
|
|
from rest_framework.urlpatterns import format_suffix_patterns |
|
|
|
|
|
|
|
from .views import Me, Features |
|
|
@ -11,6 +12,7 @@ from .views import StatisticsAPI |
|
|
|
|
|
|
|
|
|
|
|
urlpatterns = [ |
|
|
|
path('auth-token', obtain_auth_token), |
|
|
|
path('me', Me.as_view(), name='me'), |
|
|
|
path('features', Features.as_view(), name='features'), |
|
|
|
path('cloud-upload', CloudUploadAPI.as_view(), name='cloud_uploader'), |
|
|
|
|
|
@ -55,6 +55,7 @@ INSTALLED_APPS = [ |
|
|
|
'api.apps.ApiConfig', |
|
|
|
'widget_tweaks', |
|
|
|
'rest_framework', |
|
|
|
'rest_framework.authtoken', |
|
|
|
'django_filters', |
|
|
|
'social_django', |
|
|
|
'polymorphic', |
|
|
@ -210,6 +211,10 @@ REST_FRAMEWORK = { |
|
|
|
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', |
|
|
|
'rest_framework.permissions.IsAuthenticated', |
|
|
|
], |
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': ( |
|
|
|
'rest_framework.authentication.SessionAuthentication', |
|
|
|
'rest_framework.authentication.TokenAuthentication', |
|
|
|
), |
|
|
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', |
|
|
|
'PAGE_SIZE': 5, |
|
|
|
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',), |
|
|
|