switch JWT framework
This commit is contained in:
parent
f62e1498fd
commit
c583f4e9cc
@ -70,10 +70,10 @@ DATABASES = {
|
|||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.postgresql",
|
"ENGINE": "django.db.backends.postgresql",
|
||||||
"NAME": "logbook",
|
"NAME": "logbook",
|
||||||
"USER": os.environ.get("DJANGO_DB_NAME", ""),
|
"USER": os.environ.get("DJANGO_DB_USER", ""),
|
||||||
"PASSWORD": os.environ.get("DJANGO_DB_PASS", ""),
|
"PASSWORD": os.environ.get("DJANGO_DB_PASS", ""),
|
||||||
"HOST": "127.0.0.1",
|
"HOST": "127.0.0.1",
|
||||||
"PORT": "5433",
|
"PORT": os.environ.get("DJANGO_DB_PORT", "5432"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,6 @@ STATIC_URL = "/static/"
|
|||||||
CORS_ORIGIN_ALLOW_ALL = False
|
CORS_ORIGIN_ALLOW_ALL = False
|
||||||
CORS_ALLOW_CREDENTIALS = True
|
CORS_ALLOW_CREDENTIALS = True
|
||||||
CORS_ORIGIN_WHITELIST = (
|
CORS_ORIGIN_WHITELIST = (
|
||||||
# TODO - set this properly for production
|
|
||||||
"http://127.0.0.1:8080",
|
"http://127.0.0.1:8080",
|
||||||
"http://127.0.0.1:8000",
|
"http://127.0.0.1:8000",
|
||||||
"http://127.0.0.1:8001",
|
"http://127.0.0.1:8001",
|
||||||
@ -137,16 +136,9 @@ REST_FRAMEWORK = {
|
|||||||
"rest_framework.renderers.TemplateHTMLRenderer",
|
"rest_framework.renderers.TemplateHTMLRenderer",
|
||||||
),
|
),
|
||||||
"DEFAULT_AUTHENTICATION_CLASSES": (
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||||
"rest_framework_jwt.authentication.JSONWebTokenAuthentication",
|
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||||
"rest_framework.authentication.SessionAuthentication",
|
"rest_framework.authentication.SessionAuthentication",
|
||||||
),
|
),
|
||||||
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
|
||||||
"PAGE_SIZE": 20,
|
"PAGE_SIZE": 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JWT_AUTH = {
|
|
||||||
"JWT_ALLOW_REFRESH": True,
|
|
||||||
"JWT_EXPIRATION_DELTA": datetime.timedelta(hours=1),
|
|
||||||
"JWT_REFRESH_EXPIRATION_DELTA": datetime.timedelta(days=7),
|
|
||||||
}
|
|
@ -1,11 +1,15 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token
|
from rest_framework_simplejwt.views import (
|
||||||
|
TokenObtainPairView,
|
||||||
|
TokenRefreshView,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("api/v1/auth/obtain_token/", obtain_jwt_token),
|
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||||
path("api/v1/auth/refresh_token/", refresh_jwt_token),
|
path('api/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||||
# The rest of the endpoints
|
# The rest of the endpoints
|
||||||
path("api/v1/", include("flight.api")),
|
path("api/v1/", include("flight.api")),
|
||||||
]
|
]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Django==2.2.5
|
Django==2.2.5
|
||||||
django-cors-headers==3.1.0
|
django-cors-headers==3.1.0
|
||||||
djangorestframework==3.10.3
|
djangorestframework==3.10.3
|
||||||
djangorestframework-jwt==1.11.0
|
djangorestframework_simplejwt
|
||||||
psycopg2==2.8.3
|
psycopg2==2.8.3
|
||||||
PyJWT==1.7.1
|
PyJWT==1.7.1
|
||||||
pytz==2019.2
|
pytz==2019.2
|
||||||
|
Loading…
Reference in New Issue
Block a user