diff --git a/backend/wheretogo/authentication/__init__.py b/backend/wheretogo/authentication/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/wheretogo/authentication/admin.py b/backend/wheretogo/authentication/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/wheretogo/authentication/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/wheretogo/authentication/apps.py b/backend/wheretogo/authentication/apps.py new file mode 100644 index 0000000..27f63ad --- /dev/null +++ b/backend/wheretogo/authentication/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig +from django.utils.translation import gettext_lazy + + +class AuthConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "authentication" + verbose_name = gettext_lazy("authentication") diff --git a/backend/wheretogo/authentication/migrations/__init__.py b/backend/wheretogo/authentication/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/wheretogo/authentication/models.py b/backend/wheretogo/authentication/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/backend/wheretogo/authentication/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/backend/wheretogo/authentication/tests.py b/backend/wheretogo/authentication/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/wheretogo/authentication/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/wheretogo/authentication/urls.py b/backend/wheretogo/authentication/urls.py new file mode 100644 index 0000000..b66ac60 --- /dev/null +++ b/backend/wheretogo/authentication/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from rest_framework_simplejwt.views import TokenObtainPairView +from rest_framework_simplejwt.views import TokenRefreshView + +urlpatterns = [ + path("token", TokenObtainPairView.as_view(), name="token_obtain_pair"), + path("token/refresh", TokenRefreshView.as_view(), name="token_refresh"), +] diff --git a/backend/wheretogo/authentication/views.py b/backend/wheretogo/authentication/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/backend/wheretogo/authentication/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/backend/wheretogo/facilities/apps.py b/backend/wheretogo/facilities/apps.py index 52e2fe6..5d2a16d 100644 --- a/backend/wheretogo/facilities/apps.py +++ b/backend/wheretogo/facilities/apps.py @@ -1,8 +1,8 @@ from django.apps import AppConfig -from django.utils.translation import gettext_lazy as _ +from django.utils.translation import gettext_lazy class FacilitiesConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" name = "facilities" - verbose_name = _("facilities") + verbose_name = gettext_lazy("facilities") diff --git a/backend/wheretogo/wheretogo/settings.py b/backend/wheretogo/wheretogo/settings.py index 17cc76f..5ed536f 100644 --- a/backend/wheretogo/wheretogo/settings.py +++ b/backend/wheretogo/wheretogo/settings.py @@ -14,6 +14,7 @@ from pathlib import Path from wheretogo.settings_var import * # noqa:F401,F403 + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -43,8 +44,10 @@ INSTALLED_APPS = [ "django.contrib.staticfiles", "django.contrib.gis", "rest_framework", + "rest_framework_simplejwt", "rest_framework_gis", "corsheaders", + "authentication", "facilities", ] @@ -124,3 +127,10 @@ STATIC_URL = "static/" # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + + +REST_FRAMEWORK = { + "DEFAULT_AUTHENTICATION_CLASSES": ( + "rest_framework_simplejwt.authentication.JWTAuthentication", + ) +} diff --git a/backend/wheretogo/wheretogo/urls.py b/backend/wheretogo/wheretogo/urls.py index b970197..b57a035 100644 --- a/backend/wheretogo/wheretogo/urls.py +++ b/backend/wheretogo/wheretogo/urls.py @@ -19,5 +19,6 @@ from django.urls import include urlpatterns = [ path("admin/", admin.site.urls), + path("api/authentication", include("authentication.urls")), path("api/facilities", include("facilities.urls")), ]