[backend]: Добавлена базовая JWT аутентификация

This commit is contained in:
2022-09-10 15:46:03 +03:00
parent c0141bc79d
commit ea9cde238e
11 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@@ -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")

View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -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"),
]

View File

@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@@ -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")

View File

@@ -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",
)
}

View File

@@ -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")),
]