You've already forked WhereToGoRedux
mirror of
https://github.com/Llloooggg/WhereToGoRedux.git
synced 2026-03-06 04:56:23 +03:00
[backend]: Добавлена базовая JWT аутентификация
This commit is contained in:
0
backend/wheretogo/authentication/__init__.py
Normal file
0
backend/wheretogo/authentication/__init__.py
Normal file
3
backend/wheretogo/authentication/admin.py
Normal file
3
backend/wheretogo/authentication/admin.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
8
backend/wheretogo/authentication/apps.py
Normal file
8
backend/wheretogo/authentication/apps.py
Normal 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")
|
||||||
3
backend/wheretogo/authentication/models.py
Normal file
3
backend/wheretogo/authentication/models.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
3
backend/wheretogo/authentication/tests.py
Normal file
3
backend/wheretogo/authentication/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
9
backend/wheretogo/authentication/urls.py
Normal file
9
backend/wheretogo/authentication/urls.py
Normal 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"),
|
||||||
|
]
|
||||||
3
backend/wheretogo/authentication/views.py
Normal file
3
backend/wheretogo/authentication/views.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy
|
||||||
|
|
||||||
|
|
||||||
class FacilitiesConfig(AppConfig):
|
class FacilitiesConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "facilities"
|
name = "facilities"
|
||||||
verbose_name = _("facilities")
|
verbose_name = gettext_lazy("facilities")
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from wheretogo.settings_var import * # noqa:F401,F403
|
from wheretogo.settings_var import * # noqa:F401,F403
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
@@ -43,8 +44,10 @@ INSTALLED_APPS = [
|
|||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
"django.contrib.gis",
|
"django.contrib.gis",
|
||||||
"rest_framework",
|
"rest_framework",
|
||||||
|
"rest_framework_simplejwt",
|
||||||
"rest_framework_gis",
|
"rest_framework_gis",
|
||||||
"corsheaders",
|
"corsheaders",
|
||||||
|
"authentication",
|
||||||
"facilities",
|
"facilities",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -124,3 +127,10 @@ STATIC_URL = "static/"
|
|||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
|
|
||||||
|
|
||||||
|
REST_FRAMEWORK = {
|
||||||
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||||
|
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ from django.urls import include
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
path("api/authentication", include("authentication.urls")),
|
||||||
path("api/facilities", include("facilities.urls")),
|
path("api/facilities", include("facilities.urls")),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user