diff options
Diffstat (limited to 'lavalab-gen.py')
-rwxr-xr-x | lavalab-gen.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py index b0b58b4..d1a78e2 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -14,6 +14,7 @@ tokens_yaml = "tokens.yaml" baud_default = 115200 ser2net_port_start = 63001 ser2net_ports = {} +allowed_hosts_list = [ '"127.0.0.1"' ] template_conmux = string.Template("""# # auto-generated by lavalab-gen.py for ${board} @@ -60,6 +61,7 @@ template_settings_conf = string.Template(""" "HTTPS_XML_RPC": false, "LOGIN_URL": "/accounts/login/", "LOGIN_REDIRECT_URL": "/", + "ALLOWED_HOSTS": [ $allowed_hosts ], "CSRF_TRUSTED_ORIGINS": ["$lava_http_fqdn"], "CSRF_COOKIE_SECURE": $cookie_secure, "SESSION_COOKIE_SECURE": $session_cookie_secure @@ -94,7 +96,7 @@ def main(): else: masters = workers["masters"] for master in masters: - keywords_master = [ "name", "type", "host", "users", "groups", "tokens", "webadmin_https", "persistent_db", "zmq_auth", "zmq_auth_key", "zmq_auth_key_secret", "http_fqdn", "slave_keys", "slaveenv", "loglevel" ] + keywords_master = [ "name", "type", "host", "users", "groups", "tokens", "webadmin_https", "persistent_db", "zmq_auth", "zmq_auth_key", "zmq_auth_key_secret", "http_fqdn", "slave_keys", "slaveenv", "loglevel", "allowed_hosts" ] for keyword in master: if not keyword in keywords_master: print("WARNING: unknown keyword %s" % keyword) @@ -149,13 +151,19 @@ def main(): session_cookie_secure = "false" if "http_fqdn" in worker: lava_http_fqdn = worker["http_fqdn"] + allowed_hosts_list.append('"%s"' % lava_http_fqdn) else: - lava_http_fqdn = "example.com" + lava_http_fqdn = "127.0.0.1" + allowed_hosts_list.append('"%s"' % name) + if "allowed_hosts" in worker: + for allow_host in worker["allowed_hosts"]: + allowed_hosts_list.append('"%s"' % allow_host) + allowed_hosts = ','.join(allowed_hosts_list) f_fqdn = open("%s/lava_http_fqdn" % workerdir, 'w') f_fqdn.write(lava_http_fqdn) f_fqdn.close() fsettings = open("%s/settings.conf" % workerdir, 'w') - fsettings.write(template_settings_conf.substitute(cookie_secure=cookie_secure, session_cookie_secure=session_cookie_secure, lava_http_fqdn=lava_http_fqdn)) + fsettings.write(template_settings_conf.substitute(cookie_secure=cookie_secure, session_cookie_secure=session_cookie_secure, lava_http_fqdn=lava_http_fqdn, allowed_hosts=allowed_hosts)) fsettings.close() master_use_zmq_auth = False if "zmq_auth" in worker: |