diff --git a/backend/apps/accounts/urls.py b/backend/apps/accounts/urls.py new file mode 100644 index 0000000..91345e9 --- /dev/null +++ b/backend/apps/accounts/urls.py @@ -0,0 +1,12 @@ +from django.urls import path +from rest_framework_simplejwt.views import ( + TokenObtainPairView, + TokenRefreshView, + TokenVerifyView, +) + +urlpatterns = [ + path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"), + path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"), + path("token/verify/", TokenVerifyView.as_view(), name="token_verify"), +] diff --git a/backend/apps/api/urls.py b/backend/apps/api/urls.py index 990ddcb..277dd3f 100644 --- a/backend/apps/api/urls.py +++ b/backend/apps/api/urls.py @@ -1,6 +1,6 @@ -from django.urls import include, path -from django.contrib.auth import views as auth_views from apps.mailer.views import mailing_admin +from django.contrib.auth import views as auth_views +from django.urls import include, path urlpatterns = [ path("", include("apps.core.urls")), @@ -11,4 +11,5 @@ path("mailer/", include("apps.mailer.urls")), path("api/mailing-admin/", mailing_admin, name="mailing-admin"), path("api/mailing-admin/logout/", auth_views.LogoutView.as_view(), name="logout"), + path("users/", include("apps.accounts.urls")), ] diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 992722c..031d30b 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -47,6 +47,7 @@ "rest_framework_swagger", "drf_yasg", "whitenoise.runserver_nostatic", + "rest_framework_simplejwt.token_blacklist", # Celery "django_celery_results", # Custom @@ -181,16 +182,23 @@ REST_FRAMEWORK = { # "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", # "PAGE_SIZE": 10, - # "DEFAULT_AUTHENTICATION_CLASSES": ( - # "rest_framework_simplejwt.authentication.JWTAuthentication", - # ), + "DEFAULT_AUTHENTICATION_CLASSES": ( + "rest_framework_simplejwt.authentication.JWTAuthentication", + ), # 'COERCE_DECIMAL_TO_STRING': False, } -# SIMPLE_JWT = { -# "TOKEN_OBTAIN_SERIALIZER": "apps.users.serializers.CustomTokenObtainPairSerializer", -# "ACCESS_TOKEN_LIFETIME": timedelta(days=7), -# } +SIMPLE_JWT = { + # "TOKEN_OBTAIN_SERIALIZER": "apps.users.serializers.CustomTokenObtainPairSerializer", + "ACCESS_TOKEN_LIFETIME": timedelta(days=7), + "REFRESH_TOKEN_LIFETIME": timedelta(days=1), + "AUTH_HEADER_TYPES": ("Bearer",), + "USER_ID_FIELD": "id", + "USER_ID_CLAIM": "user_id", + # "SIGNING_KEY": os.getenv("DJANGO_SIGNING_KEY"), + "ROTATE_REFRESH_TOKENS": True, + "BLACKLIST_AFTER_ROTATION": True, +} # CELERY CELERY_BROKER_URL = "redis://" + os.getenv("REDIS_HOST") + ":" + os.getenv("REDIS_PORT") diff --git a/backend/requirements.txt b/backend/requirements.txt index ec6ff07..1777188 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,6 +1,7 @@ amqp==5.2.0 asgiref==3.8.1 async-timeout==4.0.3 +beautifulsoup4==4.12.3 billiard==4.2.0 boto3==1.34.126 botocore==1.34.126 @@ -22,9 +23,11 @@ django-celery-results==2.5.1 django-cors-headers==4.3.1 django-jazzmin==3.0.0 django-rest-swagger==2.2.0 +django-selectel-storage==1.0.2 django-storages==1.14.3 djangorestframework==3.15.1 djangorestframework-gis==1.0 +djangorestframework-simplejwt==5.3.1 drf-yasg==1.21.7 icalendar==5.0.12 idna==3.7 @@ -41,6 +44,7 @@ packaging==24.1 pillow==10.3.0 prompt_toolkit==3.0.46 psycopg2-binary==2.9.9 +PyJWT==2.8.0 pypng==0.20220715.0 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 @@ -54,6 +58,7 @@ requests==2.32.3 s3transfer==0.10.1 simplejson==3.19.2 six==1.16.0 +soupsieve==2.5 sqlparse==0.5.0 typing_extensions==4.12.2 tzdata==2024.1 @@ -65,5 +70,3 @@ whitenoise==6.6.0 wrapt==1.16.0 x-wr-timezone==0.0.7 yookassa==3.1.0 - -beautifulsoup4~=4.12.3 \ No newline at end of file