aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2013-05-01 22:27:06 +0000
committerRob Austein <sra@hactrn.net>2013-05-01 22:27:06 +0000
commit3d79fe3cbb16ff87375b9d847fcf951910ceefa8 (patch)
treef8911830357d3216da77a4d683962fc0beafd6e8
parent16ae84b316b668cdfec5839cf8a532a62492aab7 (diff)
Add ALLOWED_HOSTS. Closes #525.
svn path=/trunk/; revision=5312
-rw-r--r--rpkid/rpki/gui/default_settings.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/rpkid/rpki/gui/default_settings.py b/rpkid/rpki/gui/default_settings.py
index eadb570a..ecde12e2 100644
--- a/rpkid/rpki/gui/default_settings.py
+++ b/rpkid/rpki/gui/default_settings.py
@@ -7,17 +7,18 @@ __version__ = '$Id$'
import os
import random
import string
+import socket
import rpki.config
import rpki.autoconf
-# where to put static files
+# Where to put static files.
STATIC_ROOT = rpki.autoconf.datarootdir + '/rpki/media'
-# must end with a slash!
+# Must end with a slash!
STATIC_URL = '/media/'
-# where to email server errors
+# Where to email server errors.
ADMINS = (('Administrator', 'root@localhost'),)
LOGGING = {
@@ -50,9 +51,9 @@ LOGGING = {
},
},
}
-# load the sql authentication bits from the system rpki.conf
-rpki_config = rpki.config.parser(section='web_portal')
+# Load the SQL authentication bits from the system rpki.conf.
+rpki_config = rpki.config.parser(section='web_portal')
DATABASES = {
'default': {
@@ -79,7 +80,7 @@ def select_tz():
if os.path.exists('/usr/share/zoneinfo/' + tz):
return tz
# Can't determine the proper timezone, fall back to UTC and let Django
- # report the error to the user
+ # report the error to the user.
return 'UTC'
# Local time zone for this installation. Choices can be found here:
@@ -89,7 +90,6 @@ def select_tz():
# system time zone.
TIME_ZONE = select_tz()
-
def get_secret_key():
"""Retrieve the secret-key value from rpki.conf or generate a random value
if it is not present."""
@@ -100,6 +100,15 @@ def get_secret_key():
# Make this unique, and don't share it with anybody.
SECRET_KEY = get_secret_key()
+# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
+# for details on why you might need this.
+def get_allowed_hosts():
+ allowed_hosts = rpki_config.multiget("allowed-hosts")
+ allowed_hosts.append(socket.getfqdn())
+ return allowed_hosts
+
+ALLOWED_HOSTS = get_allowed_hosts()
+
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
@@ -141,7 +150,10 @@ TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.static"
)
-# allow local site to override any setting above
+# Allow local site to override any setting above -- but if there's
+# anything that local sites routinely need to modify, please consider
+# putting that configuration into rpki.conf and just adding code here
+# to read that configuration.
try:
from local_settings import *
except: