Commit fa256b5b authored by Lukas Burgey's avatar Lukas Burgey

Expand the example configuration

parent 9ca1dcad
.secret.key
feudal/settings.py
env
static
deploy
......
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
Type=notify
ExecStart=/usr/local/bin/uwsgi --ini /etc/uwsgi/feudal.ini --uid www-data --gid www-data
RuntimeDirectory=uwsgi
KillSignal=SIGQUIT
StandardError=syslog
User=hdf
Restart=on-failure
[Install]
WantedBy=multi-user.target
......@@ -19,3 +19,5 @@ socket = /home/feudal/backend/feudal.sock
chmod-socket = 666
# clear environment on exit
vacuum = true
env = DJANGO_SETTINGS_MODULE=/home/feudal/configs/dango_settings.py
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = [
'hdf-portal.data.kit.edu',
]
AUTH_USER_MODEL = 'backend.User'
# cookie settings
SESSION_COOKIE_AGE = 3600
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = False
CSRF_HEADER_NAME = 'HTTP_X_CSRFTOKEN'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
with open('.secret.key') as f:
SECRET_KEY = f.read().strip()
# Application definition
ROOT_URLCONF = 'feudal.urls'
STATIC_URL = '/backend/static/'
STATIC_ROOT = 'static'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'polymorphic',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'feudal.backend',
'corsheaders',
'django_mysql',
]
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',
]
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 = 'feudal.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': os.path.expanduser('~/.my.cnf'),
'init_command': "SET innodb_strict_mode=1; SET sql_mode='STRICT_TRANS_TABLES';",
'charset': 'utf8mb4'
},
'TEST': {
'NAME': 'scc-hdfmysql0001_portal_dev_test',
}
}
}
CORS_ORIGIN_ALLOW_ALL = True
# AUTHENTICATION AND AUTHORIZATION
AUTHENTICATION_BACKENDS = [
'feudal.backend.auth.v1.models.OIDCTokenAuthBackend',
'django.contrib.auth.backends.ModelBackend',
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'feudal.backend.auth.v1.auth_class.CsrfExemptSessionAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}
# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# LOGGING
LOGGING_ROOT = os.path.expanduser('~/logs')
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
},
},
'handlers': {
'django': {
'class': 'logging.FileHandler',
'filename': LOGGING_ROOT + '/django.log',
'formatter': 'standard',
},
'debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': LOGGING_ROOT + '/debug.log',
'formatter': 'standard',
},
'info': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': LOGGING_ROOT + '/info.log',
'formatter': 'standard',
},
'error': {
'level': 'ERROR',
'class': 'logging.FileHandler',
'filename': LOGGING_ROOT + '/error.log',
'formatter': 'standard',
},
'console': {
'class': 'logging.StreamHandler',
'formatter': 'standard',
},
},
'loggers': {
'feudal': {
'handlers': ['debug', 'info', 'error'],
'level': 'DEBUG',
},
'django': {
'handlers': ['debug', 'info', 'error'],
'level': 'INFO',
},
},
}
#!/bin/bash
echo 'generating secret'
dd if=/dev/urandom bs=64 count=1 | base64 > .secret.key
mkdir -p logs
config_dir=${config_dir-~/config}
echo "Using config dir: $config_dir"
mkdir -p ~/logs $config_dir
cp ./example-config/home/feudal/* $config_dir/
ln -s ./feudal/settings.py $config_dir/django_settings.py
echo
echo "Generating secret at ./.secret.key"
dd if=/dev/urandom bs=64 count=1 | base64 > ./.secret.key
echo
virtualenv -p /usr/bin/python3.5 ./env
source env/bin/activate
pip install Django django-cors-headers django-mysql django-polymorphic django-rest-polymorphic djangorestframework oic urllib3 mysqlclient pika
echo "Starting database migration (is your database configured?)"
./manage.py makemigrations backend
./manage.py migrate
./manage.py collectstatic
echo creating django super user
echo "Creating django super user"
./manage.py createsuperuser
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment