139 lines
3.8 KiB
Python
139 lines
3.8 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
import sentry_sdk
|
|
from sentry_sdk.integrations.django import DjangoIntegration
|
|
|
|
from app.openv import OnePassword
|
|
|
|
SCOPE = os.environ['SCOPE']
|
|
OP_ITEM_TITLE = os.environ.get('OP_ITEM_TITLE', 'mines')
|
|
|
|
op_env = OnePassword(SCOPE, OP_ITEM_TITLE)
|
|
|
|
sentry_sdk.init(
|
|
dsn=op_env.get('SENTRY_DSN'),
|
|
integrations=[DjangoIntegration()],
|
|
environment=SCOPE,
|
|
send_default_pii=False,
|
|
traces_sample_rate=1.0,
|
|
)
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = op_env.get('SECRET_KEY')
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = op_env.get('DEBUG', '0') in ['1', 'true']
|
|
|
|
ALLOWED_HOSTS = op_env.get('ALLOWED_HOSTS', '127.0.0.1,localhost').split(',')
|
|
|
|
# Application definition
|
|
INSTALLED_APPS = [
|
|
'rest_framework',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'corsheaders',
|
|
'core',
|
|
'api',
|
|
'game',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'app.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [],
|
|
'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 = 'app.wsgi.application'
|
|
|
|
AUTH_USER_MODEL = 'core.User'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
'NAME': op_env.get('database.name'),
|
|
'USER': op_env.get('database.user'),
|
|
'PASSWORD': op_env.get('database.password'),
|
|
'HOST': op_env.get('database.host'),
|
|
'PORT': op_env.get('database.port'),
|
|
'OPTIONS': {'charset': 'utf8mb4'},
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.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/3.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'America/Sao_Paulo'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
# Some Django Rest Framework parameters
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.AllowAny'],
|
|
'DEFAULT_AUTHENTICATION_CLASSES': ['rest_framework.authentication.TokenAuthentication'],
|
|
'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',),
|
|
}
|
|
|
|
if DEBUG is True:
|
|
CORS_ALLOW_ALL_ORIGINS = True
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|