adding simple jwt

This commit is contained in:
2025-07-30 23:41:11 +03:30
parent 5a49800967
commit 27c1fb04c8
6 changed files with 255 additions and 7 deletions

View File

@@ -44,6 +44,7 @@ INSTALLED_APPS = [
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"rest_framework_simplejwt",
"field",
]
@@ -115,7 +116,19 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
),
}
from datetime import timedelta
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=30),
"REFRESH_TOKEN_LIFETIME": timedelta(days=7),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,
}
# Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/

View File

@@ -17,5 +17,11 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
urlpatterns = [path("admin/", admin.site.urls), path("", include("field.urls"))]
urlpatterns = [
path("admin/", admin.site.urls),
path("", include("field.urls")),
path("api/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
]