Skip to content

Commit 498817b

Browse files
committed
Remove SSL cert for localhost
This commit removes SSL certification creation and usage when running webviz in localhost mode. This makes it HTTP-only for localhost with no HTTPS option.
1 parent 2538035 commit 498817b

10 files changed

+17
-316
lines changed

.github/workflows/webviz-config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ jobs:
6868
6969
- name: 🤖 Run tests
7070
run: |
71-
webviz certificate
7271
webviz preferences --theme default
7372
pytest ./tests --headless --forked
7473
webviz docs --portable ./docs_build --skip-open

INTRODUCTION.md

-9
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ webviz build ./examples/basic_example.yaml
8282
and then modify `./examples/basic_example.yaml` while the Webviz application is
8383
still running, a hot reload will occur.
8484

85-
#### Localhost certificate
86-
87-
For quick local analysis, `webviz-config` uses `https` and runs on `localhost`.
88-
In order to create your personal :lock: `https` certificate (only valid for `localhost`), run
89-
```bash
90-
webviz certificate --auto-install
91-
```
92-
Certificate installation guidelines will be given when running the command.
93-
9485
#### User preferences
9586

9687
You can set preferred :rainbow: theme and/or :earth_africa: browser, such that `webviz` remembers it for later

webviz_config/_docs/open_docs.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def _index() -> str:
3030
host="localhost",
3131
port=port,
3232
debug=False,
33-
ssl_context=webviz_config.certificate.LocalhostCertificate().ssl_context,
3433
)
3534

3635

webviz_config/_localhost_token.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77

88

99
class LocalhostToken:
10-
"""Uses a method similar to jupyter notebook (however, here we do it over
11-
https in addition). This method is only used during interactive usage on
12-
localhost, and the workflow is as follows:
10+
"""Uses a method similar to jupyter notebook. This method is only used during
11+
interactive usage on localhost, and the workflow is as follows:
1312
1413
- During the flask app building, a one-time-token (ott) and a cookie_token
1514
is generated.
1615
- When the app is ready, the user needs to "login" using this
17-
one-time-token in the url (https://localhost:{port}?ott={token})
16+
one-time-token in the url (http://localhost:{port}?ott={token})
1817
- If ott is valid - a cookie with a separate token is set, and the
1918
one-time-token is discarded. The cookie is then used for subsequent
2019
requests.
@@ -28,6 +27,7 @@ class LocalhostToken:
2827
2928
The port is used as a postfix on the cookie name in order to make sure that
3029
two different localhost applications running simultaneously do not interfere.
30+
3131
"""
3232

3333
def __init__(self, app: flask.app.Flask, port: int):

webviz_config/certificate/__init__.py

-1
This file was deleted.

webviz_config/certificate/_certificate_generator.py

-228
This file was deleted.

webviz_config/certificate/_localhost_certificate.py

-39
This file was deleted.

webviz_config/command_line.py

-24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pathlib
44

55
from ._build_webviz import build_webviz
6-
from .certificate._certificate_generator import create_ca
76
from ._docs.open_docs import open_docs
87
from ._docs._create_schema import create_schema
98
from ._user_data_dir import user_data_dir
@@ -61,29 +60,6 @@ def main() -> None:
6160

6261
parser_build.set_defaults(func=build_webviz)
6362

64-
# Add "certificate" parser:
65-
66-
parser_cert = subparsers.add_parser(
67-
"certificate",
68-
help="Create a https certificate authority for webviz "
69-
"(validity limited to localhost only)",
70-
)
71-
72-
parser_cert.add_argument(
73-
"--force",
74-
action="store_true",
75-
help="Overwrite webviz root https certificate if it already exists",
76-
)
77-
78-
parser_cert.add_argument(
79-
"--auto-install",
80-
action="store_true",
81-
help="Automatically install the webviz certificate in "
82-
"your personal public key infrastructure",
83-
)
84-
85-
parser_cert.set_defaults(func=create_ca)
86-
8763
# Add "documentation" parser:
8864

8965
parser_docs = subparsers.add_parser(

webviz_config/templates/webviz_template.py.jinja2

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import dash_html_components as html
1616
from flask_talisman import Talisman
1717
import webviz_config
1818
import webviz_config.plugins
19-
import webviz_config.certificate
2019
from webviz_config.themes import installed_themes
2120
from webviz_config.common_cache import CACHE
2221
from webviz_config.webviz_store import WEBVIZ_STORAGE
@@ -67,7 +66,9 @@ app._deprecated_webviz_settings = {
6766
CACHE.init_app(server)
6867

6968
theme.adjust_csp({"script-src": app.csp_hashes()}, append=True)
70-
Talisman(server, content_security_policy=theme.csp, feature_policy=theme.feature_policy)
69+
if __name__ != "__main__":
70+
# Do not increase security when running this script directly
71+
Talisman(server, content_security_policy=theme.csp, feature_policy=theme.feature_policy)
7172

7273
WEBVIZ_STORAGE.use_storage = {{portable}}
7374
WEBVIZ_STORAGE.storage_folder = Path(__file__).resolve().parent / "webviz_storage"
@@ -153,7 +154,6 @@ if __name__ == "__main__":
153154
app.run_server(
154155
host="localhost",
155156
port=port,
156-
ssl_context=webviz_config.certificate.LocalhostCertificate().ssl_context,
157157
debug=False,
158158
use_reloader={{not portable}},
159159
dev_tools_prune_errors=False,

0 commit comments

Comments
 (0)