Use ssl for flask server (#319)

* Use ssl for flask server

* Use window location protocol to get https or http in frontend

* Make use_ssl configurable

* Remove log port in frontend
This commit is contained in:
Jonathan Zernik 2020-10-24 18:04:56 -04:00 committed by GitHub
parent 9ed4d79c78
commit 537bb8439b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View file

@ -32,6 +32,7 @@ rpc_port=8994
enabled=true
host=0.0.0.0
port=12994
use_ssl=false
[postgresql]
host=db

View file

@ -77,10 +77,7 @@ import {
} from "../proto/squeak_admin_pb"
export let web_host_port = 'http://' + window.location.hostname + ':' + window.location.port;
console.log("web_host_port:");
console.log(web_host_port);
export let web_host_port = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port;
function makeRequest(route, request, handleResponse) {

View file

@ -297,9 +297,10 @@ def create_app(handler):
class SqueakAdminWebServer():
def __init__(self, host, port, handler):
def __init__(self, host, port, use_ssl, handler):
self.host = host
self.port = port
self.use_ssl = use_ssl
self.handler = handler
self.app = create_app(handler)
@ -308,4 +309,5 @@ class SqueakAdminWebServer():
self.host,
self.port,
debug=False,
ssl_context='adhoc' if self.use_ssl else None,
)

View file

@ -65,6 +65,7 @@ def load_admin_web_server(config, handler) -> SqueakAdminWebServer:
return SqueakAdminWebServer(
config["webadmin"]["host"],
config["webadmin"]["port"],
config["webadmin"].getboolean("use_ssl"),
handler,
)
@ -156,6 +157,10 @@ def load_admin_web_server_enabled(config):
return config["webadmin"].getboolean("enabled")
def load_admin_web_server_use_ssl(config):
return config["webadmin"].getboolean("use_ssl")
def start_admin_web_server(admin_web_server):
logger.info("Calling start_admin_web_server...")
thread = threading.Thread(