2020-02-20 15:52:50 +00:00
|
|
|
"""
|
|
|
|
Django settings for uncloud project.
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 3.0.3.
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
https://docs.djangoproject.com/en/3.0/topics/settings/
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
https://docs.djangoproject.com/en/3.0/ref/settings/
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2020-02-23 16:17:08 +00:00
|
|
|
|
2020-02-23 15:52:30 +00:00
|
|
|
# Uncommitted file with secrets
|
|
|
|
import uncloud.secrets
|
|
|
|
|
2020-02-22 10:49:00 +00:00
|
|
|
import stripe
|
|
|
|
import ldap
|
|
|
|
|
|
|
|
import uncloud.secrets as secrets
|
|
|
|
|
|
|
|
from django_auth_ldap.config import LDAPSearch
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-23 15:52:30 +00:00
|
|
|
|
2020-02-20 15:52:50 +00:00
|
|
|
# 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/3.0/howto/deployment/checklist/
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
2020-02-23 15:52:30 +00:00
|
|
|
SECRET_KEY = uncloud.secrets.SECRET_KEY
|
2020-02-20 15:52:50 +00:00
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
DEBUG = True
|
|
|
|
|
|
|
|
ALLOWED_HOSTS = []
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2020-02-21 09:41:22 +00:00
|
|
|
'rest_framework',
|
2020-02-21 10:32:41 +00:00
|
|
|
'uncloud_api',
|
2020-02-21 15:33:37 +00:00
|
|
|
'uncloud_auth',
|
|
|
|
'opennebula'
|
2020-02-20 15:52:50 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
MIDDLEWARE = [
|
|
|
|
'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 = 'uncloud.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 = 'uncloud.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
# https://docs.djangoproject.com/en/3.0/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',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2020-02-21 10:32:41 +00:00
|
|
|
################################################################################
|
|
|
|
# AUTH/LDAP
|
|
|
|
|
2020-02-23 15:52:30 +00:00
|
|
|
AUTH_LDAP_SERVER_URI = uncloud.secrets.LDAP_SERVER_URI
|
2020-02-21 10:32:41 +00:00
|
|
|
|
2020-02-23 15:52:30 +00:00
|
|
|
AUTH_LDAP_USER_ATTR_MAP = {
|
|
|
|
"first_name": "givenName",
|
|
|
|
"last_name": "sn",
|
|
|
|
"email": "mail"
|
|
|
|
}
|
2020-02-20 17:58:07 +00:00
|
|
|
|
2020-02-23 16:20:28 +00:00
|
|
|
|
2020-02-23 15:52:30 +00:00
|
|
|
AUTH_LDAP_BIND_DN = uncloud.secrets.LDAP_ADMIN_DN
|
|
|
|
AUTH_LDAP_BIND_PASSWORD = uncloud.secrets.LDAP_ADMIN_PASSWORD
|
2020-02-22 10:49:00 +00:00
|
|
|
|
2020-02-20 17:58:07 +00:00
|
|
|
AUTH_LDAP_USER_SEARCH = LDAPSearch(
|
2020-02-23 15:52:30 +00:00
|
|
|
"dc=ungleich,dc=ch", ldap.SCOPE_SUBTREE, "(uid=%(user)s)"
|
2020-02-20 17:58:07 +00:00
|
|
|
)
|
|
|
|
|
2020-02-23 15:52:30 +00:00
|
|
|
|
2020-02-21 10:32:41 +00:00
|
|
|
################################################################################
|
|
|
|
# AUTH/Django
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
|
|
"django_auth_ldap.backend.LDAPBackend",
|
|
|
|
"django.contrib.auth.backends.ModelBackend"
|
|
|
|
]
|
|
|
|
|
|
|
|
AUTH_USER_MODEL = 'uncloud_auth.User'
|
|
|
|
|
|
|
|
|
2020-02-20 17:58:07 +00:00
|
|
|
################################################################################
|
|
|
|
# AUTH/REST
|
|
|
|
REST_FRAMEWORK = {
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
|
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-20 15:52:50 +00:00
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/3.0/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
|
|
|
|
|
|
|
STATIC_URL = '/static/'
|
2020-02-20 18:38:30 +00:00
|
|
|
|
2020-02-22 10:49:00 +00:00
|
|
|
stripe.api_key = secrets.STRIPE_KEY
|
2020-02-20 18:38:30 +00:00
|
|
|
|
2020-02-23 16:17:08 +00:00
|
|
|
# FIXME: not sure if we really need this
|
2020-02-25 13:12:23 +00:00
|
|
|
# LOGGING = {
|
|
|
|
# 'version': 1,
|
|
|
|
# 'disable_existing_loggers': False,
|
|
|
|
# 'handlers': {
|
|
|
|
# 'file': {
|
|
|
|
# 'level': 'DEBUG',
|
|
|
|
# 'class': 'logging.FileHandler',
|
|
|
|
# 'filename': 'debug.log',
|
|
|
|
# },
|
|
|
|
# },
|
|
|
|
# 'loggers': {
|
|
|
|
# 'django': {
|
|
|
|
# 'handlers': ['file'],
|
|
|
|
# 'level': 'DEBUG',
|
|
|
|
# 'propagate': True,
|
|
|
|
# },
|
|
|
|
# 'django_auth_ldap': {
|
|
|
|
# 'handlers': ['file'],
|
|
|
|
# 'level': 'DEBUG',
|
|
|
|
# 'propagate': True
|
|
|
|
# }
|
|
|
|
# },
|
|
|
|
# }
|
2020-02-20 18:38:30 +00:00
|
|
|
|
2020-02-23 10:42:15 +00:00
|
|
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
|
|
'NAME': uncloud.secrets.POSTGRESQL_DB_NAME,
|
|
|
|
}
|
|
|
|
}
|