IDDRS_API/iddrs_api/settings.py

209 lines
6.0 KiB
Python
Raw Permalink Normal View History

2023-05-12 11:41:17 +00:00
"""
Django settings for iddrs_api project.
Generated by 'django-admin startproject' using Django 4.1.3.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
2023-07-31 07:58:36 +00:00
from datetime import timedelta
from pathlib import Path
import os
2023-05-12 11:41:17 +00:00
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-t7_=(ogb*qe%wll00g&*tr#7542!qe*jxwg#2t*bw0!4pm&vi='
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
2023-12-01 10:24:57 +00:00
ALLOWED_HOSTS = ['dev-iddrs.bicc.de']
2023-05-12 11:41:17 +00:00
# In this particular case, it is allowing cross-origin requests from
# the specified origin http://localhost:3000, which is the default origin
# for a locally served React application during development.
2023-07-31 07:58:36 +00:00
#CORS_ALLOWED_ORIGINS = [
# 'http://localhost:3000',
#]
2023-05-12 11:41:17 +00:00
2023-07-07 10:46:00 +00:00
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
2023-05-12 11:41:17 +00:00
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
2023-11-20 14:31:13 +00:00
'rest_framework.authtoken',
2023-07-31 07:58:36 +00:00
'rest_framework_simplejwt.token_blacklist',
2023-05-12 11:41:17 +00:00
'django_filters',
'search_tfidf',
2023-11-20 14:31:13 +00:00
'data_api',
2023-05-12 11:41:17 +00:00
'corsheaders',
]
2023-07-31 07:58:36 +00:00
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
}
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=5),
"REFRESH_TOKEN_LIFETIME": timedelta(days=90),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,
"UPDATE_LAST_LOGIN": False,
"ALGORITHM": "HS256",
"VERIFYING_KEY": "",
"AUDIENCE": None,
"ISSUER": None,
"JSON_ENCODER": None,
"JWK_URL": None,
"LEEWAY": 0,
"AUTH_HEADER_TYPES": ("Bearer",),
"AUTH_HEADER_NAME": "HTTP_AUTHORIZATION",
"USER_ID_FIELD": "id",
"USER_ID_CLAIM": "user_id",
"USER_AUTHENTICATION_RULE": "rest_framework_simplejwt.authentication.default_user_authentication_rule",
"AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
"TOKEN_TYPE_CLAIM": "token_type",
"TOKEN_USER_CLASS": "rest_framework_simplejwt.models.TokenUser",
"JTI_CLAIM": "jti",
"SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp",
"SLIDING_TOKEN_LIFETIME": timedelta(minutes=5),
"SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1),
"TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainPairSerializer",
"TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSerializer",
"TOKEN_VERIFY_SERIALIZER": "rest_framework_simplejwt.serializers.TokenVerifySerializer",
"TOKEN_BLACKLIST_SERIALIZER": "rest_framework_simplejwt.serializers.TokenBlacklistSerializer",
"SLIDING_TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainSlidingSerializer",
"SLIDING_TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSlidingSerializer",
}
2023-05-12 11:41:17 +00:00
MIDDLEWARE = [
2023-07-31 07:58:36 +00:00
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
2023-05-12 11:41:17 +00:00
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
2023-07-31 07:58:36 +00:00
2023-05-12 11:41:17 +00:00
]
ROOT_URLCONF = 'iddrs_api.urls'
2023-07-31 07:58:36 +00:00
print(BASE_DIR)
2023-05-12 11:41:17 +00:00
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
2023-07-31 07:58:36 +00:00
'DIRS': [os.path.join(BASE_DIR,'templates')],
2023-05-12 11:41:17 +00:00
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'iddrs_api.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
2023-07-31 07:58:36 +00:00
## User model
## AUTH_USER_MODEL = 'user_auth.AppUser'
##
## REST_FRAMEWORK = {
## 'DEFAULT_AUTHENTICATION_CLASSES': (
## 'rest_framework.authentication.SessionAuthentication',
## ),
## 'DEFAULT_PERMISSION_CLASSES': (
## 'rest_framework.permissions.IsAuthenticated',
## )}
2023-05-12 11:41:17 +00:00
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
2023-11-30 14:06:43 +00:00
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
2023-05-12 11:41:17 +00:00
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'