a Django-based indieweb.org site https://00dani.me/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
7.2KB

  1. """
  2. Django settings for lemoncurry project.
  3. Generated by 'django-admin startproject' using Django 1.11.6.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/1.11/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/1.11/ref/settings/
  8. """
  9. import os
  10. import re
  11. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  12. BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = '6riil57g@r^wprf7mdy((+bs&(6l*phcn9&fd$l0@t-kzj+xww'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = []
  20. INTERNAL_IPS = ['127.0.0.1', '::1']
  21. # Settings to tighten up security - these can safely be on in dev mode too,
  22. # since I dev using a local HTTPS server.
  23. # Strict-Transport-Security: max out everything, we never want to serve
  24. # anything over insecure HTTP.
  25. SECURE_HSTS_SECONDS = 31536000
  26. SECURE_HSTS_INCLUDE_SUBDOMAINS = True
  27. SECURE_HSTS_PRELOAD = True
  28. # Only allow cookies to be sent from the client over secure HTTP.
  29. SESSION_COOKIE_SECURE = True
  30. CSRF_COOKIE_SECURE = True
  31. # Miscellanous headers to protect against attacks.
  32. SECURE_CONTENT_TYPE_NOSNIFF = True
  33. SECURE_BROWSER_XSS_FILTER = True
  34. X_FRAME_OPTIONS = 'DENY'
  35. # This technically isn't needed, since nginx doesn't let the app be accessed
  36. # over insecure HTTP anyway. Just for completeness!
  37. SECURE_SSL_REDIRECT = True
  38. # We run behind nginx, so we need nginx to tell us whether we're using HTTPS or
  39. # not.
  40. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  41. # Application definition
  42. INSTALLED_APPS = [
  43. 'django.contrib.admin',
  44. 'django.contrib.admindocs',
  45. 'django.contrib.auth',
  46. 'django.contrib.contenttypes',
  47. 'django.contrib.humanize',
  48. 'django.contrib.sessions',
  49. 'django.contrib.sites',
  50. 'django.contrib.sitemaps',
  51. 'django.contrib.messages',
  52. 'django.contrib.staticfiles',
  53. 'analytical',
  54. 'annoying',
  55. 'compressor',
  56. 'computed_property',
  57. 'corsheaders',
  58. 'debug_toolbar',
  59. 'django_activeurl',
  60. 'django_agent_trust',
  61. 'django_otp',
  62. 'django_otp.plugins.otp_totp',
  63. 'django_rq',
  64. 'favicon',
  65. 'meta',
  66. 'lemoncurry',
  67. 'entries',
  68. 'home',
  69. 'lemonauth',
  70. 'lemonshort',
  71. 'micropub',
  72. 'users',
  73. 'webmention',
  74. 'wellknowns',
  75. ]
  76. MIDDLEWARE = [
  77. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  78. 'django.middleware.security.SecurityMiddleware',
  79. 'django.contrib.admindocs.middleware.XViewMiddleware',
  80. 'django.contrib.sessions.middleware.SessionMiddleware',
  81. 'corsheaders.middleware.CorsMiddleware',
  82. 'django.middleware.common.CommonMiddleware',
  83. 'django.middleware.csrf.CsrfViewMiddleware',
  84. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  85. 'django_otp.middleware.OTPMiddleware',
  86. 'django_agent_trust.middleware.AgentMiddleware',
  87. 'django.contrib.messages.middleware.MessageMiddleware',
  88. 'django.contrib.sites.middleware.CurrentSiteMiddleware',
  89. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  90. ]
  91. ROOT_URLCONF = 'lemoncurry.urls'
  92. SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
  93. TEMPLATES = [
  94. {
  95. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  96. 'DIRS': [],
  97. 'APP_DIRS': True,
  98. 'OPTIONS': {
  99. 'context_processors': [
  100. 'django.template.context_processors.debug',
  101. 'django.template.context_processors.request',
  102. 'django.contrib.auth.context_processors.auth',
  103. 'django.contrib.messages.context_processors.messages',
  104. ],
  105. },
  106. },
  107. ]
  108. WSGI_APPLICATION = 'lemoncurry.wsgi.application'
  109. # Cache
  110. # https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-CACHES
  111. CACHES = {
  112. 'default': {
  113. 'BACKEND': 'redis_cache.RedisCache',
  114. 'LOCATION': '127.0.0.1:6380',
  115. 'KEY_PREFIX': 'lemoncurry',
  116. 'OPTIONS': {
  117. 'DB': 0,
  118. 'PARSER_CLASS': 'redis.connection.HiredisParser',
  119. },
  120. }
  121. }
  122. # Database
  123. # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
  124. DATABASES = {
  125. 'default': {
  126. 'ENGINE': 'django.db.backends.sqlite3',
  127. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  128. }
  129. }
  130. AUTH_USER_MODEL = 'users.User'
  131. # Password hashers
  132. # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
  133. PASSWORD_HASHERS = [
  134. 'django.contrib.auth.hashers.Argon2PasswordHasher',
  135. 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
  136. 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
  137. 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
  138. 'django.contrib.auth.hashers.BCryptPasswordHasher',
  139. ]
  140. # Password validation
  141. # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
  142. AUTH_PASSWORD_VALIDATORS = [
  143. {
  144. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  145. },
  146. {
  147. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  148. },
  149. {
  150. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  151. },
  152. {
  153. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  154. },
  155. ]
  156. LOGIN_URL = 'lemonauth:login'
  157. LOGIN_REDIRECT_URL = 'home:index'
  158. LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
  159. # Internationalization
  160. # https://docs.djangoproject.com/en/1.11/topics/i18n/
  161. LANGUAGE_CODE = 'en-au'
  162. TIME_ZONE = 'Australia/Sydney'
  163. USE_I18N = True
  164. USE_L10N = True
  165. USE_TZ = True
  166. # Static files (CSS, JavaScript, Images)
  167. # https://docs.djangoproject.com/en/1.11/howto/static-files/
  168. STATIC_URL = '/static/'
  169. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  170. STATICFILES_FINDERS = (
  171. 'django.contrib.staticfiles.finders.FileSystemFinder',
  172. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  173. 'compressor.finders.CompressorFinder',
  174. )
  175. COMPRESS_PRECOMPILERS = (
  176. ('text/stylus', './node_modules/.bin/stylus {infile} -u ./lemoncurry/static/lemoncurry/css/theme -o {outfile}'),
  177. )
  178. MEDIA_URL = STATIC_URL + 'media/'
  179. MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
  180. # django-contrib-sites
  181. # https://docs.djangoproject.com/en/dev/ref/contrib/sites/
  182. SITE_ID = 1
  183. # django-agent-trust
  184. # https://pythonhosted.org/django-agent-trust/
  185. AGENT_COOKIE_SECURE = True
  186. # django-cors-headers
  187. CORS_ORIGIN_ALLOW_ALL = True
  188. # django-debug-toolbar
  189. # https://django-debug-toolbar.readthedocs.io/en/stable/configuration.html
  190. DEBUG_TOOLBAR_CONFIG = {
  191. 'SHOW_TOOLBAR_CALLBACK': 'lemoncurry.debug.show_toolbar',
  192. }
  193. # lemonshort
  194. SHORT_BASE_URL = '/s/'
  195. SHORTEN_MODELS = {
  196. 'e': 'entries.entry',
  197. }
  198. # django-meta
  199. # https://django-meta.readthedocs.io/en/latest/settings.html
  200. META_SITE_PROTOCOL = 'https'
  201. META_USE_SITES = True
  202. META_USE_OG_PROPERTIES = True
  203. META_USE_TWITTER_PROPERTIES = True
  204. # django-push
  205. # https://django-push.readthedocs.io/en/latest/publisher.html
  206. PUSH_HUB = 'https://00dani.superfeedr.com/'
  207. # django-rq
  208. # https://github.com/ui/django-rq
  209. RQ_QUEUES = {'default': {'USE_REDIS_CACHE': 'default'}}
  210. # django-super-favicon
  211. FAVICON_STORAGE = 'django.core.files.storage.DefaultStorage'