Postfix's Transport Encryption under Control of the User
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.

base.py 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. """
  2. Django settings for PostTLS project.
  3. """
  4. import os
  5. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  6. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  7. # SECURITY WARNING: keep the secret key used in production secret!
  8. SECRET_KEY = os.environ["POSTTLS_SECRET_KEY"]
  9. # SECURITY WARNING: don't run with debug turned on in production!
  10. if os.environ["POSTTLS_ENVIRONMENT_TYPE"] == "production":
  11. DEBUG = False
  12. else:
  13. DEBUG = True
  14. ALLOWED_HOSTS = ['localhost', '127.0.0.1']
  15. INSTALLED_APPS = [
  16. 'flat', # flat theme for django admin
  17. 'django.contrib.admin',
  18. 'django.contrib.auth',
  19. 'django.contrib.contenttypes',
  20. 'django.contrib.sessions',
  21. 'django.contrib.messages',
  22. 'django.contrib.staticfiles',
  23. 'core',
  24. ]
  25. MIDDLEWARE_CLASSES = [
  26. 'django.middleware.security.SecurityMiddleware',
  27. 'django.contrib.sessions.middleware.SessionMiddleware',
  28. 'django.middleware.common.CommonMiddleware',
  29. 'django.middleware.csrf.CsrfViewMiddleware',
  30. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  31. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  32. 'django.contrib.messages.middleware.MessageMiddleware',
  33. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  34. ]
  35. ROOT_URLCONF = 'config.urls'
  36. TEMPLATES = [
  37. {
  38. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  39. 'DIRS': [],
  40. 'APP_DIRS': True,
  41. 'OPTIONS': {
  42. 'context_processors': [
  43. 'django.template.context_processors.debug',
  44. 'django.template.context_processors.request',
  45. 'django.contrib.auth.context_processors.auth',
  46. 'django.contrib.messages.context_processors.messages',
  47. ],
  48. },
  49. },
  50. ]
  51. WSGI_APPLICATION = 'config.wsgi.application'
  52. DATABASES = {
  53. 'default': {
  54. 'ENGINE': 'django.db.backends.sqlite3',
  55. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  56. }
  57. }
  58. # Custom User Model
  59. # see: Two Scoops of Django, page 258
  60. # see: https://www.youtube.com/watch?v=0bAJV0zNWQw
  61. AUTH_USER_MODEL = 'core.User'
  62. LANGUAGE_CODE = 'en-us'
  63. TIME_ZONE = 'UTC'
  64. USE_I18N = True
  65. USE_L10N = True
  66. USE_TZ = True
  67. # SSL - activate in production
  68. if os.environ["POSTTLS_ENVIRONMENT_TYPE"] == "production":
  69. SECURE_SSL_REDIRECT = True
  70. SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTOCOL", "https")
  71. SESSION_COOKIE_SECURE = True
  72. CSRF_COOKIE_SECURE = True
  73. # Static files (CSS, JavaScript, Images)
  74. # https://docs.djangoproject.com/en/dev/howto/static-files/
  75. STATIC_URL = '/static/'
  76. STATIC_ROOT = os.environ["POSTTLS_STATIC_ROOT_DIR"]
  77. MEDIA_URL = '/media/'
  78. MEDIA_ROOT = os.environ["POSTTLS_MEDIA_ROOT_DIR"]
  79. ##################################################
  80. # Settings for App PostTLS
  81. ##################################################
  82. # email notification for mails in queue
  83. POSTTLS_NOTIFICATION_SENDER = os.environ["POSTTLS_NOTIFICATION_SENDER"]
  84. POSTTLS_NOTIFICATION_SMTP_HOST = os.environ["POSTTLS_NOTIFICATION_SMTP_HOST"]
  85. # host on which the application runs
  86. POSTTLS_TLS_HOST = os.environ["POSTTLS_TLS_HOST"]
  87. POSTTLS_NOTIFICATION_SYSADMIN_MAIL_ADDRESS = os.environ["POSTTLS_NOTIFICATION_SYSADMIN_MAIL_ADDRESS"]