Skip to content

Commit fc072a2

Browse files
committed
chore(django checks): resolve a few check --deploy checks
On boot run deploy checks to see if there are any problems. Resolved a few of them even if they are not directly relevant to us. https://docs.djangoproject.com/es/1.9/ref/checks has all available checks. Silenced 2 SSL related ones that router takes care of
1 parent 3398ac3 commit fc072a2

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

rootfs/bin/boot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ else
7777
addgroup deis "$(stat -c "%G" /var/run/docker.sock)"
7878
fi
7979

80+
echo "Django checks:"
81+
./manage.py check --deploy api
82+
8083
echo "Health Checks:"
8184
./manage.py healthchecks
8285

rootfs/deis/settings.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
DEBUG = False
1515

16+
# Silence two security messages around SSL as router takes care of them
17+
# https://docs.djangoproject.com/es/1.9/ref/checks/#security
18+
SILENCED_SYSTEM_CHECKS = [
19+
'security.W004',
20+
'security.W008'
21+
]
22+
1623
ADMINS = (
1724
# ('Your Name', 'your_email@example.com'),
1825
)
@@ -84,14 +91,14 @@
8491
MIDDLEWARE_CLASSES = (
8592
'corsheaders.middleware.CorsMiddleware',
8693
'django.middleware.security.SecurityMiddleware',
94+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
95+
'django.middleware.csrf.CsrfViewMiddleware',
8796
'django.contrib.sessions.middleware.SessionMiddleware',
8897
'django.middleware.common.CommonMiddleware',
8998
'django.contrib.auth.middleware.AuthenticationMiddleware',
9099
'django.contrib.messages.middleware.MessageMiddleware',
91100
'api.middleware.APIVersionMiddleware',
92101
'deis.middleware.PlatformVersionMiddleware',
93-
# Uncomment the next line for simple clickjacking protection:
94-
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
95102
)
96103

97104
ROOT_URLCONF = 'deis.urls'
@@ -125,8 +132,8 @@
125132
LOGIN_URL = '/v2/auth/login/'
126133
LOGIN_REDIRECT_URL = '/'
127134

135+
# Security settings
128136
CORS_ORIGIN_ALLOW_ALL = True
129-
130137
CORS_ALLOW_HEADERS = (
131138
'content-type',
132139
'accept',
@@ -141,6 +148,17 @@
141148
'Deis-Release',
142149
)
143150

151+
X_FRAME_OPTIONS = 'DENY'
152+
CSRF_COOKIE_SECURE = True
153+
CSRF_COOKIE_HTTPONLY = True
154+
SESSION_COOKIE_SECURE = True
155+
SECURE_CONTENT_TYPE_NOSNIFF = True
156+
SECURE_BROWSER_XSS_FILTER = True
157+
158+
# Honor HTTPS from a trusted proxy
159+
# see https://docs.djangoproject.com/en/1.6/ref/settings/#secure-proxy-ssl-header
160+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
161+
144162
# standard datetime format used for logging, model timestamps, etc.
145163
DEIS_DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S%Z'
146164

@@ -262,8 +280,9 @@
262280
SCHEDULER_OPTIONS = None
263281

264282
# security keys and auth tokens
265-
SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi')
266-
BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi')
283+
random_secret = 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi*#@&*^'
284+
SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', random_secret)
285+
BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', random_secret)
267286

268287
# registry settings
269288
REGISTRY_HOST = os.environ.get('DEIS_REGISTRY_SERVICE_HOST', '127.0.0.1')
@@ -299,10 +318,6 @@
299318

300319
APP_URL_REGEX = '[a-z0-9-]+'
301320

302-
# Honor HTTPS from a trusted proxy
303-
# see https://docs.djangoproject.com/en/1.6/ref/settings/#secure-proxy-ssl-header
304-
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
305-
306321
# Unit Hostname handling.
307322
# Supports:
308323
# default - Docker generated hostname

0 commit comments

Comments
 (0)