Browse Source

[core] Introduce ALLOWED_HOSTS configuration for Hue

Added to pseudo_distributed.ini and hue.ini
Enrico Berti 10 years ago
parent
commit
43870822be

+ 4 - 0
desktop/conf.dist/hue.ini

@@ -152,6 +152,10 @@
   # }
   # }
   ## log_redaction_file=
   ## log_redaction_file=
 
 
+  # Comma separated list of strings representing the host/domain names that the Hue server can serve.
+  # e.g.: localhost,domain1,*
+  ## allowed_hosts=*
+
   # Administrators
   # Administrators
   # ----------------
   # ----------------
   [[django_admins]]
   [[django_admins]]

+ 4 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -160,6 +160,10 @@
   #   ]
   #   ]
   # }
   # }
 
 
+  # Comma separated list of strings representing the host/domain names that the Hue server can serve.
+  # e.g.: localhost,domain1,*
+  ## allowed_hosts=*
+
 #poll_enabled=false
 #poll_enabled=false
 
 
   # Administrators
   # Administrators

+ 7 - 0
desktop/core/src/desktop/conf.py

@@ -176,6 +176,13 @@ LOG_REDACTION_FILE = Config(
   type=parse_redaction_policy_from_file,
   type=parse_redaction_policy_from_file,
   default=None)
   default=None)
 
 
+ALLOWED_HOSTS = Config(
+  key='allowed_hosts',
+  default=['*'],
+  type=coerce_csv,
+  help=_('Comma separated list of strings representing the host/domain names that the Hue server can serve.')
+)
+
 def is_https_enabled():
 def is_https_enabled():
   return bool(SSL_CERTIFICATE.get() and SSL_PRIVATE_KEY.get())
   return bool(SSL_CERTIFICATE.get() and SSL_PRIVATE_KEY.get())
 
 

+ 3 - 1
desktop/core/src/desktop/settings.py

@@ -205,7 +205,6 @@ FILE_UPLOAD_HANDLERS = (
 # Wrap each request in a transaction.
 # Wrap each request in a transaction.
 ATOMIC_REQUESTS = True
 ATOMIC_REQUESTS = True
 
 
-
 ############################################################
 ############################################################
 # Part 4: Installation of apps
 # Part 4: Installation of apps
 ############################################################
 ############################################################
@@ -250,6 +249,9 @@ TEMPLATE_DEBUG = DEBUG
 # configs.
 # configs.
 ############################################################
 ############################################################
 
 
+# Configure allowed hosts
+ALLOWED_HOSTS = desktop.conf.ALLOWED_HOSTS.get()
+
 # Configure hue admins
 # Configure hue admins
 ADMINS = []
 ADMINS = []
 for admin in desktop.conf.DJANGO_ADMINS.get():
 for admin in desktop.conf.DJANGO_ADMINS.get():