diff --git a/logbook/logbook/settings.py b/logbook/logbook/settings.py index 7bd415e..157f3bd 100644 --- a/logbook/logbook/settings.py +++ b/logbook/logbook/settings.py @@ -70,10 +70,10 @@ DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": "logbook", - "USER": os.environ.get("DJANGO_DB_NAME", ""), + "USER": os.environ.get("DJANGO_DB_USER", ""), "PASSWORD": os.environ.get("DJANGO_DB_PASS", ""), "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_ALLOW_CREDENTIALS = True CORS_ORIGIN_WHITELIST = ( - # TODO - set this properly for production "http://127.0.0.1:8080", "http://127.0.0.1:8000", "http://127.0.0.1:8001", @@ -137,16 +136,9 @@ REST_FRAMEWORK = { "rest_framework.renderers.TemplateHTMLRenderer", ), "DEFAULT_AUTHENTICATION_CLASSES": ( - "rest_framework_jwt.authentication.JSONWebTokenAuthentication", + 'rest_framework_simplejwt.authentication.JWTAuthentication', "rest_framework.authentication.SessionAuthentication", ), "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", "PAGE_SIZE": 20, -} - - -JWT_AUTH = { - "JWT_ALLOW_REFRESH": True, - "JWT_EXPIRATION_DELTA": datetime.timedelta(hours=1), - "JWT_REFRESH_EXPIRATION_DELTA": datetime.timedelta(days=7), -} +} \ No newline at end of file diff --git a/logbook/logbook/urls.py b/logbook/logbook/urls.py index 248f0a9..281f8b9 100644 --- a/logbook/logbook/urls.py +++ b/logbook/logbook/urls.py @@ -1,11 +1,15 @@ from django.contrib import admin 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 = [ path("admin/", admin.site.urls), - path("api/v1/auth/obtain_token/", obtain_jwt_token), - path("api/v1/auth/refresh_token/", refresh_jwt_token), + path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), + path('api/refresh/', TokenRefreshView.as_view(), name='token_refresh'), # The rest of the endpoints path("api/v1/", include("flight.api")), ] diff --git a/requirements.txt b/requirements.txt index c40e769..f78b36e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Django==2.2.5 django-cors-headers==3.1.0 djangorestframework==3.10.3 -djangorestframework-jwt==1.11.0 +djangorestframework_simplejwt psycopg2==2.8.3 PyJWT==1.7.1 pytz==2019.2