Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

djangorestframework-simplejwt Add JWT authentication support on the backend #73

Merged
merged 3 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ django-heroku = "*"
djangorestframework = "*"
pillow = "*"
whitenoise = "*"
djangorestframework-simplejwt = "*"
django-cors-headers = "*"

[requires]
python_version = "3.7"
31 changes: 27 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions server/tutvwebsite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
},
]

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
}

# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
Expand Down
2 changes: 0 additions & 2 deletions server/tutvwebsite/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@
# TODO: set MEDIA_URL to something?
# https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.FileField.storage
# https://docs.djangoproject.com/en/3.0/ref/models/fields/#imagefield

INSTALLED_APPS = ['whitenoise.runserver_nostatic'] + INSTALLED_APPS
6 changes: 6 additions & 0 deletions server/tutvwebsite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

from django.contrib import admin
from django.urls import include, path, re_path
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
)

import api.views as views

urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include('api.urls')),
path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
re_path(r'^', views.FrontendAppView.as_view())
]