2017-10-22 17:52:16 -04:00
|
|
|
"""
|
|
|
|
Django settings for lemoncurry project.
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 1.11.6.
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
https://docs.djangoproject.com/en/1.11/topics/settings/
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
https://docs.djangoproject.com/en/1.11/ref/settings/
|
|
|
|
"""
|
|
|
|
|
2018-06-03 19:32:47 -04:00
|
|
|
from os import environ, path
|
2018-05-28 19:37:28 -04:00
|
|
|
from typing import List
|
2017-10-22 17:52:16 -04:00
|
|
|
|
2018-05-07 08:28:48 -04:00
|
|
|
APPEND_SLASH = False
|
2017-10-24 22:25:58 -04:00
|
|
|
|
2018-04-25 20:27:11 -04:00
|
|
|
ADMINS = [
|
|
|
|
('dani', 'dani@00dani.me'),
|
|
|
|
]
|
|
|
|
|
2018-04-23 23:05:25 -04:00
|
|
|
BASE_DIR = path.dirname(path.dirname(path.dirname(path.abspath(__file__))))
|
2017-10-22 17:52:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
# 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!
|
|
|
|
SECRET_KEY = '6riil57g@r^wprf7mdy((+bs&(6l*phcn9&fd$l0@t-kzj+xww'
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
DEBUG = True
|
|
|
|
|
2018-05-28 19:37:28 -04:00
|
|
|
ALLOWED_HOSTS = [] # type: List[str]
|
2017-10-26 17:05:50 -04:00
|
|
|
INTERNAL_IPS = ['127.0.0.1', '::1']
|
2017-10-22 17:52:16 -04:00
|
|
|
|
2017-10-23 02:46:26 -04:00
|
|
|
# Settings to tighten up security - these can safely be on in dev mode too,
|
|
|
|
# since I dev using a local HTTPS server.
|
|
|
|
|
|
|
|
# Strict-Transport-Security: max out everything, we never want to serve
|
|
|
|
# anything over insecure HTTP.
|
|
|
|
SECURE_HSTS_SECONDS = 31536000
|
|
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
|
|
SECURE_HSTS_PRELOAD = True
|
|
|
|
|
|
|
|
# Only allow cookies to be sent from the client over secure HTTP.
|
|
|
|
SESSION_COOKIE_SECURE = True
|
|
|
|
CSRF_COOKIE_SECURE = True
|
|
|
|
|
|
|
|
# Miscellanous headers to protect against attacks.
|
|
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
|
|
X_FRAME_OPTIONS = 'DENY'
|
|
|
|
|
|
|
|
# This technically isn't needed, since nginx doesn't let the app be accessed
|
|
|
|
# over insecure HTTP anyway. Just for completeness!
|
|
|
|
SECURE_SSL_REDIRECT = True
|
|
|
|
|
|
|
|
# We run behind nginx, so we need nginx to tell us whether we're using HTTPS or
|
|
|
|
# not.
|
|
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
2017-10-22 17:52:16 -04:00
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
2018-04-25 20:40:11 -04:00
|
|
|
'lemoncurry',
|
2018-05-09 07:00:30 -04:00
|
|
|
'pyup_django',
|
2018-04-25 20:40:11 -04:00
|
|
|
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.contrib.admin',
|
2018-04-19 21:21:00 -04:00
|
|
|
'django.contrib.admindocs',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
2017-10-24 21:01:52 -04:00
|
|
|
'django.contrib.humanize',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.contrib.sessions',
|
2017-10-28 21:12:39 -04:00
|
|
|
'django.contrib.sites',
|
2017-10-24 06:14:17 -04:00
|
|
|
'django.contrib.sitemaps',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2017-10-22 18:04:59 -04:00
|
|
|
|
2017-11-01 01:18:48 -04:00
|
|
|
'analytical',
|
2017-10-28 21:41:33 -04:00
|
|
|
'annoying',
|
2017-10-22 19:29:12 -04:00
|
|
|
'compressor',
|
2018-03-22 21:56:13 -04:00
|
|
|
'computed_property',
|
2018-01-10 17:32:45 -05:00
|
|
|
'corsheaders',
|
2017-10-26 17:05:50 -04:00
|
|
|
'debug_toolbar',
|
2017-10-24 09:40:38 -04:00
|
|
|
'django_activeurl',
|
2017-10-24 10:46:18 -04:00
|
|
|
'django_agent_trust',
|
2018-04-25 23:35:31 -04:00
|
|
|
'django_extensions',
|
2017-10-24 10:25:03 -04:00
|
|
|
'django_otp',
|
2018-05-10 00:20:09 -04:00
|
|
|
'django_otp.plugins.otp_static',
|
2017-10-24 10:25:03 -04:00
|
|
|
'django_otp.plugins.otp_totp',
|
2017-11-05 19:04:22 -05:00
|
|
|
'django_rq',
|
2017-10-23 23:46:32 -04:00
|
|
|
'favicon',
|
2017-10-24 06:57:07 -04:00
|
|
|
'meta',
|
2017-10-22 19:29:12 -04:00
|
|
|
|
2017-10-24 21:01:52 -04:00
|
|
|
'entries',
|
2017-10-22 18:37:24 -04:00
|
|
|
'home',
|
2017-10-24 08:50:57 -04:00
|
|
|
'lemonauth',
|
2018-03-21 06:50:40 -04:00
|
|
|
'lemonshort',
|
2017-11-03 05:45:29 -04:00
|
|
|
'micropub',
|
2017-10-22 18:04:59 -04:00
|
|
|
'users',
|
2018-03-19 06:11:04 -04:00
|
|
|
'webmention',
|
2017-10-23 23:39:16 -04:00
|
|
|
'wellknowns',
|
2017-10-22 17:52:16 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
MIDDLEWARE = [
|
2017-10-26 17:05:50 -04:00
|
|
|
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
2018-05-28 03:52:24 -04:00
|
|
|
'django.middleware.http.ConditionalGetMiddleware',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2018-04-19 21:21:00 -04:00
|
|
|
'django.contrib.admindocs.middleware.XViewMiddleware',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
2018-01-10 17:32:45 -05:00
|
|
|
'corsheaders.middleware.CorsMiddleware',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
2017-10-24 10:25:03 -04:00
|
|
|
'django_otp.middleware.OTPMiddleware',
|
2017-10-24 10:46:18 -04:00
|
|
|
'django_agent_trust.middleware.AgentMiddleware',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
2017-10-28 21:12:39 -04:00
|
|
|
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
2017-10-22 17:52:16 -04:00
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
2018-07-02 19:41:00 -04:00
|
|
|
'lemoncurry.middleware.ResponseExceptionMiddleware',
|
2017-10-22 17:52:16 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'lemoncurry.urls'
|
|
|
|
|
2017-10-24 06:17:38 -04:00
|
|
|
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
|
|
|
|
|
2017-10-22 17:52:16 -04:00
|
|
|
TEMPLATES = [
|
2018-05-28 07:15:02 -04:00
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.jinja2.Jinja2',
|
|
|
|
'APP_DIRS': True,
|
|
|
|
'OPTIONS': {
|
|
|
|
'environment': 'lemoncurry.jinja2.environment',
|
|
|
|
},
|
|
|
|
},
|
2017-10-22 17:52:16 -04:00
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'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 = 'lemoncurry.wsgi.application'
|
|
|
|
|
2017-10-23 02:49:11 -04:00
|
|
|
# Cache
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-CACHES
|
|
|
|
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
2018-04-23 22:45:05 -04:00
|
|
|
'BACKEND': 'django_redis.cache.RedisCache',
|
|
|
|
'LOCATION': 'redis://127.0.0.1:6380/0',
|
2017-11-09 17:17:32 -05:00
|
|
|
'KEY_PREFIX': 'lemoncurry',
|
|
|
|
'OPTIONS': {
|
|
|
|
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
2018-05-28 07:18:18 -04:00
|
|
|
'SERIALIZER': 'lemoncurry.msgpack.MSGPackModernSerializer',
|
2017-11-09 17:17:32 -05:00
|
|
|
},
|
2018-04-23 22:46:36 -04:00
|
|
|
'VERSION': 2,
|
2017-10-23 02:49:11 -04:00
|
|
|
}
|
|
|
|
}
|
2017-10-22 17:52:16 -04:00
|
|
|
|
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
2018-05-10 00:20:09 -04:00
|
|
|
'ENGINE': 'django.db.backends.postgresql',
|
2018-06-03 19:32:47 -04:00
|
|
|
'NAME': environ.get('POSTGRES_DB', 'lemoncurry'),
|
|
|
|
'USER': environ.get('POSTGRES_USER'),
|
|
|
|
'PASSWORD': environ.get('POSTGRES_PASSWORD'),
|
|
|
|
'HOST': environ.get('POSTGRES_HOST', 'localhost'),
|
2017-10-22 17:52:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-22 18:04:59 -04:00
|
|
|
AUTH_USER_MODEL = 'users.User'
|
|
|
|
|
2018-02-06 00:18:15 -05:00
|
|
|
# Password hashers
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
|
|
|
PASSWORD_HASHERS = [
|
|
|
|
'django.contrib.auth.hashers.Argon2PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
|
|
|
]
|
|
|
|
|
2017-10-22 17:52:16 -04:00
|
|
|
# Password validation
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
|
|
|
|
2018-04-23 23:05:25 -04:00
|
|
|
PW_VALIDATOR_MODULE = 'django.contrib.auth.password_validation'
|
2017-10-22 17:52:16 -04:00
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
2018-04-23 23:05:25 -04:00
|
|
|
{'NAME': PW_VALIDATOR_MODULE + '.UserAttributeSimilarityValidator'},
|
|
|
|
{'NAME': PW_VALIDATOR_MODULE + '.MinimumLengthValidator'},
|
|
|
|
{'NAME': PW_VALIDATOR_MODULE + '.CommonPasswordValidator'},
|
|
|
|
{'NAME': PW_VALIDATOR_MODULE + '.NumericPasswordValidator'},
|
2017-10-22 17:52:16 -04:00
|
|
|
]
|
|
|
|
|
2017-10-24 08:50:57 -04:00
|
|
|
LOGIN_URL = 'lemonauth:login'
|
|
|
|
LOGIN_REDIRECT_URL = 'home:index'
|
|
|
|
LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
|
|
|
|
|
2017-10-22 17:52:16 -04:00
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
|
|
|
|
2017-10-23 00:55:32 -04:00
|
|
|
LANGUAGE_CODE = 'en-au'
|
2017-10-22 17:52:16 -04:00
|
|
|
|
2017-10-23 00:55:32 -04:00
|
|
|
TIME_ZONE = 'Australia/Sydney'
|
2017-10-22 17:52:16 -04:00
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
|
|
|
|
|
|
|
STATIC_URL = '/static/'
|
2018-04-23 23:05:25 -04:00
|
|
|
STATIC_ROOT = path.join(BASE_DIR, 'static')
|
2017-10-22 19:29:12 -04:00
|
|
|
STATICFILES_FINDERS = (
|
|
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
|
|
'compressor.finders.CompressorFinder',
|
|
|
|
)
|
2018-05-28 03:52:24 -04:00
|
|
|
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
|
2017-10-22 19:29:12 -04:00
|
|
|
|
|
|
|
COMPRESS_PRECOMPILERS = (
|
2018-04-25 20:32:01 -04:00
|
|
|
('text/stylus', 'npx stylus -u ./lemoncurry/static/lemoncurry/css/theme'),
|
2017-10-22 19:29:12 -04:00
|
|
|
)
|
2017-10-22 18:43:26 -04:00
|
|
|
|
2017-10-22 20:53:51 -04:00
|
|
|
MEDIA_URL = STATIC_URL + 'media/'
|
2018-04-23 23:05:25 -04:00
|
|
|
MEDIA_ROOT = path.join(STATIC_ROOT, 'media')
|
2017-10-22 20:53:51 -04:00
|
|
|
|
2017-10-28 21:12:39 -04:00
|
|
|
# django-contrib-sites
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/contrib/sites/
|
|
|
|
SITE_ID = 1
|
2017-10-24 06:57:07 -04:00
|
|
|
|
2017-10-24 10:46:18 -04:00
|
|
|
# django-agent-trust
|
|
|
|
# https://pythonhosted.org/django-agent-trust/
|
|
|
|
AGENT_COOKIE_SECURE = True
|
|
|
|
|
2018-01-10 17:32:45 -05:00
|
|
|
# django-cors-headers
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
2018-05-08 11:29:30 -04:00
|
|
|
CORS_URLS_REGEX = r'^/(?!admin|auth/(?:login|logout|indie)).*$'
|
2018-01-10 17:32:45 -05:00
|
|
|
|
2018-03-21 06:50:40 -04:00
|
|
|
# lemonshort
|
|
|
|
SHORT_BASE_URL = '/s/'
|
2017-10-28 21:56:30 -04:00
|
|
|
SHORTEN_MODELS = {
|
|
|
|
'e': 'entries.entry',
|
|
|
|
}
|
|
|
|
|
2017-10-24 06:57:07 -04:00
|
|
|
# django-meta
|
|
|
|
# https://django-meta.readthedocs.io/en/latest/settings.html
|
|
|
|
META_SITE_PROTOCOL = 'https'
|
2017-10-28 21:12:39 -04:00
|
|
|
META_USE_SITES = True
|
2017-10-24 06:57:07 -04:00
|
|
|
META_USE_OG_PROPERTIES = True
|
|
|
|
META_USE_TWITTER_PROPERTIES = True
|
2017-10-27 05:32:50 -04:00
|
|
|
|
|
|
|
# django-push
|
|
|
|
# https://django-push.readthedocs.io/en/latest/publisher.html
|
|
|
|
PUSH_HUB = 'https://00dani.superfeedr.com/'
|
2017-11-05 19:04:22 -05:00
|
|
|
|
|
|
|
# django-rq
|
|
|
|
# https://github.com/ui/django-rq
|
|
|
|
RQ_QUEUES = {'default': {'USE_REDIS_CACHE': 'default'}}
|
2018-04-19 22:35:51 -04:00
|
|
|
|
|
|
|
# django-super-favicon
|
|
|
|
FAVICON_STORAGE = 'django.core.files.storage.DefaultStorage'
|