mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-08-20 06:35:48 +02:00
197 lines
5.0 KiB
Python
197 lines
5.0 KiB
Python
"""
|
|
Django settings for jaeles project.
|
|
|
|
Generated by 'django-admin startproject' using Django 2.2.2.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/2.2/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/2.2/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from datetime import timedelta
|
|
|
|
from pathlib import Path
|
|
# turn this on when go live
|
|
import logging
|
|
logging.disable(logging.INFO)
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = '%#0q2v(m-gbls-4nf*hywb_c%yms&27k1yh(=pnn4qy^s@u@zv'
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
# SECURITY WARNING: You should put your VPS IP or domain here
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'rest_framework',
|
|
'corsheaders',
|
|
'api',
|
|
]
|
|
|
|
|
|
# CORS stuff
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
CORS_ALLOW_CREDENTIALS = True
|
|
CORS_ORIGIN_WHITELIST = (
|
|
'http://localhost:3000',
|
|
'http://127.0.0.1:3000',
|
|
)
|
|
|
|
MIDDLEWARE = [
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'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',
|
|
]
|
|
|
|
ROOT_URLCONF = 'rest.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [
|
|
'ui',
|
|
os.path.join(BASE_DIR, "ui"),
|
|
],
|
|
'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 = 'rest.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/2.2/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/2.2/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
|
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
|
],
|
|
## @NOTE enable this when go live
|
|
# 'EXCEPTION_HANDLER': 'rest.exception.custom_exception_handler',
|
|
|
|
}
|
|
|
|
SIMPLE_JWT = {
|
|
'ACCESS_TOKEN_LIFETIME': timedelta(days=90),
|
|
'REFRESH_TOKEN_LIFETIME': timedelta(days=120),
|
|
'ROTATE_REFRESH_TOKENS': False,
|
|
'BLACKLIST_AFTER_ROTATION': True,
|
|
|
|
'ALGORITHM': 'HS256',
|
|
'SIGNING_KEY': SECRET_KEY,
|
|
'VERIFYING_KEY': None,
|
|
|
|
'AUTH_HEADER_TYPES': ('Osmedeus',),
|
|
# 'AUTH_HEADER_TYPES': ('Bearer',),
|
|
'USER_ID_FIELD': 'id',
|
|
'USER_ID_CLAIM': 'user_id',
|
|
|
|
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
|
|
'TOKEN_TYPE_CLAIM': 'token_type',
|
|
|
|
'JTI_CLAIM': 'jti',
|
|
|
|
'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp',
|
|
'SLIDING_TOKEN_LIFETIME': timedelta(days=30),
|
|
'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=60),
|
|
}
|
|
|
|
# CELERY_BROKER_URL = 'redis://localhost:6379'
|
|
# CELERY_RESULT_BACKEND = 'redis://localhost:6379'
|
|
# CELERY_ACCEPT_CONTENT = ['application/json']
|
|
# CELERY_TASK_SERIALIZER = 'json'
|
|
# CELERY_RESULT_SERIALIZER = 'json'
|
|
# CELERY_TIMEZONE = TIME_ZONE
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
WORKSPACES_PATH = str(Path.home().joinpath('.osmedeus/workspaces'))
|
|
STATICFILES_DIRS = (
|
|
os.path.join(BASE_DIR, "ui", "static"),
|
|
WORKSPACES_PATH,
|
|
)
|
|
|
|
# adding place to store libraries
|
|
LIBS_DIR = os.path.join(os.path.dirname(BASE_DIR), 'lib')
|
|
sys.path.append(LIBS_DIR)
|