From d3136bb4e9e69606810bc0d540bbcdf2bc9068c3 Mon Sep 17 00:00:00 2001 From: Uskov4 Date: Wed, 28 Jul 2021 10:28:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B1=D1=8D=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app/settings.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/app/app/settings.py b/app/app/settings.py index 624eede..24b8ccd 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -1,6 +1,7 @@ from pathlib import Path import os import environ +from datetime import timedelta BASE_DIR = Path(__file__).resolve().parent.parent @@ -13,7 +14,7 @@ SECRET_KEY = env('SECRET_KEY') -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = env('ALLOWED_HOSTS').split(',') # Application definition @@ -26,6 +27,7 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'django_createsuperuser', + 'rest_framework', 'corsheaders', 'drf_yasg', @@ -69,6 +71,10 @@ } AUTH_USER_MODEL = 'users.User' +AUTHENTICATION_BACKENDS = [ + 'django.contrib.auth.backends.ModelBackend', +] + AUTH_PASSWORD_VALIDATORS = [ { @@ -101,3 +107,35 @@ CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True + +REST_FRAMEWORK = { + 'DEFAULT_FILTER_BACKENDS': ( + 'django_filters.rest_framework.DjangoFilterBackend', + ), + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticatedOrReadOnly', + ), + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', + ) +} + +JWT_AUTH = { + 'JWT_EXPIRATION_DELTA': timedelta(days=14), + 'JWT_REFRESH_EXPIRATION_DELTA': timedelta(days=21), + 'JWT_ALLOW_REFRESH': True, +} + +SWAGGER_SETTINGS = { + 'SECURITY_DEFINITIONS': { + 'Bearer': { + 'type': 'apiKey', + 'name': 'Authorization', + 'in': 'header' + } + } +} + +USE_X_FORWARDED_HOST = True +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')