diff --git a/renumics/spotlight/cli.py b/renumics/spotlight/cli.py index ec117e9f..79632299 100644 --- a/renumics/spotlight/cli.py +++ b/renumics/spotlight/cli.py @@ -124,6 +124,12 @@ def cli_dtype_callback( @click.option( "--ssl-keyfile-password", type=str, default=None, help="SSL keyfile password" ) +@click.option( + "--no-ssl", + is_flag=True, + default=False, + help="Do not require SSL sertificate and keyfile when starting on non-localhost.", +) @click.option("-v", "--verbose", is_flag=True) @click.version_option(spotlight.__version__) def main( @@ -142,6 +148,7 @@ def main( ssl_keyfile: Optional[str], ssl_certfile: Optional[str], ssl_keyfile_password: Optional[str], + no_ssl: bool, verbose: bool, ) -> None: """ @@ -171,4 +178,5 @@ def main( ssl_keyfile=ssl_keyfile, ssl_certfile=ssl_certfile, ssl_keyfile_password=ssl_keyfile_password, + no_ssl=no_ssl, ) diff --git a/renumics/spotlight/server.py b/renumics/spotlight/server.py index dd7f9e95..7dd8801a 100644 --- a/renumics/spotlight/server.py +++ b/renumics/spotlight/server.py @@ -72,6 +72,7 @@ def __init__( ssl_keyfile: Optional[str] = None, ssl_certfile: Optional[str] = None, ssl_keyfile_password: Optional[str] = None, + no_ssl: bool = False, ) -> None: self.process = None @@ -80,7 +81,7 @@ def __init__( self._app_config = AppConfig() self._host = host - if self._host not in ("127.0.0.1", "localhost"): + if self._host not in ("127.0.0.1", "localhost") and not no_ssl: if ssl_certfile is None: raise MissingTLSCertificate( "Starting Spotlight on non-localhost without TLS certificate is insecure. Please provide TLS certificate and key." diff --git a/renumics/spotlight/viewer.py b/renumics/spotlight/viewer.py index 49d894ae..ea87110f 100644 --- a/renumics/spotlight/viewer.py +++ b/renumics/spotlight/viewer.py @@ -132,6 +132,7 @@ class Viewer: _ssl_keyfile: Optional[str] _ssl_certfile: Optional[str] _ssl_keyfile_password: Optional[str] + _no_ssl: bool _server: Optional[Server] _df: Optional[pd.DataFrame] @@ -142,12 +143,14 @@ def __init__( ssl_keyfile: Optional[str] = None, ssl_certfile: Optional[str] = None, ssl_keyfile_password: Optional[str] = None, + no_ssl: bool = False, ) -> None: self._host = host self._requested_port = port self._ssl_keyfile = ssl_keyfile self._ssl_certfile = ssl_certfile self._ssl_keyfile_password = ssl_keyfile_password + self._no_ssl = no_ssl self._server = None self._df = None @@ -233,6 +236,7 @@ def show( self._ssl_keyfile, self._ssl_certfile, self._ssl_keyfile_password, + self._no_ssl, ) self._server.start(config) @@ -406,6 +410,7 @@ def show( ssl_keyfile: Optional[str] = None, ssl_certfile: Optional[str] = None, ssl_keyfile_password: Optional[str] = None, + no_ssl: bool = False, ) -> Viewer: """ Start a new Spotlight viewer. @@ -435,6 +440,7 @@ def show( ssl_keyfile: Optional SSL key file. ssl_certfile: Optional SSL certificate file. ssl_certfile: Optional SSL keyfile password. + no_ssl: Do not require SSL sertificate and keyfile when starting on non-localhost. """ viewer = None @@ -445,7 +451,9 @@ def show( viewer = _VIEWERS[index] break if not viewer: - viewer = Viewer(host, port, ssl_keyfile, ssl_certfile, ssl_keyfile_password) + viewer = Viewer( + host, port, ssl_keyfile, ssl_certfile, ssl_keyfile_password, no_ssl + ) viewer.show( dataset,