Browse Source

Merge pull request #170 from CatalystCode/enhancement/allow-non-ssl-database-connections

Enhancement/Enable non-SSL connections to the database
pull/192/head
Hiroki Nakayama 5 years ago
committed by GitHub
parent
commit
6ee23ec4fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions
  1. 7
      app/app/settings.py
  2. 1
      requirements.txt

7
app/app/settings.py

@ -15,6 +15,7 @@ from os import path
import django_heroku
import dj_database_url
from environs import Env
from furl import furl
# Build paths inside the project like this: path.join(BASE_DIR, ...)
@ -195,7 +196,11 @@ LOGIN_REDIRECT_URL = '/projects/'
LOGOUT_REDIRECT_URL = '/'
# Change 'default' database configuration with $DATABASE_URL.
DATABASES['default'].update(dj_database_url.config(conn_max_age=500, ssl_require=True))
DATABASES['default'].update(dj_database_url.config(
env='DATABASE_URL',
conn_max_age=env.int('DATABASE_CONN_MAX_AGE', 500),
ssl_require='sslmode' not in furl(env('DATABASE_URL', '')).args,
))
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

1
requirements.txt

@ -14,6 +14,7 @@ environs==4.1.0
djangorestframework-xml==1.4.0
Faker==0.8.8
flake8==3.6.0
furl==2.0.0
gunicorn==19.9.0
mixer==6.1.3
model-mommy==1.6.0

Loading…
Cancel
Save