Skip to content
Permalink
Browse files

WIP [Investigate disabling REST API over non-https connections #141]:…

… added production setting of SECURE_SSL_REDIRECT
  • Loading branch information...
matthewcornell committed May 28, 2019
1 parent 666b88c commit 65e82441727461feea33f6c27d18e062073bbeb1
@@ -12,6 +12,8 @@

import os

from django.conf import settings


BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

@@ -123,6 +125,9 @@

STATIC_URL = '/static/'

if not settings.DEBUG: # NB: requires "children" settings to set DEBUG before importing
SECURE_SSL_REDIRECT = True

#
# set up logging - https://stackoverflow.com/questions/5137042/how-can-i-get-django-to-print-the-debug-information-to-the-console
# note: According to docs, I should not have to specify this - default should be to log everything INFO and higher to
@@ -179,7 +184,6 @@
message_constants.ERROR: 'danger', # the only one that needs correcting, i.e., the only one different from default
}


#
# S3 support - used by cloud_file.py
#
@@ -189,7 +193,6 @@
if not S3_BUCKET_PREFIX:
raise RuntimeError('base.py: S3_BUCKET_PREFIX not configured!')


#
# support for sending emails via https://www.sendinblue.com/ by way of https://github.com/anymail/django-anymail
#
@@ -1,20 +1,30 @@
import dj_database_url
from django.core.exceptions import ImproperlyConfigured

from .base import *
import os


#
# ---- DEBUG and SECRET_KEY ----
#

# NB: must set the following before importing from base

DEBUG = False

if 'SECRET_KEY' not in os.environ:
from django.core.exceptions import ImproperlyConfigured


raise ImproperlyConfigured("The 'SECRET_KEY' environment variable was not set.")

SECRET_KEY = os.environ['SECRET_KEY']

#
# ---- imports ----
#

import dj_database_url

from .base import *


#
# ---- MIDDLEWARE ----
@@ -25,8 +35,7 @@
# https://warehouse.python.org/project/whitenoise/
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
]
)
])

#
# ---- database config ----
@@ -1,10 +1,12 @@
from .base import *

# NB: must set the following before importing from base

DEBUG = True

SECRET_KEY = '&6kqgmf2fi3==##07k$!ns_#sd1%v4e4%$lbgft9(c7ar9itbh'

from .base import *


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
@@ -1,10 +1,12 @@
from .base import *

# NB: must set the following before importing from base

DEBUG = True

SECRET_KEY = 'i9)wcfth2$)-ggdx2n-z9ek4o4o759cpgo)_gk(oen8713g%to'

from .base import *


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',

0 comments on commit 65e8244

Please sign in to comment.
You can’t perform that action at this time.