Skip to content

Commit 2fbf041

Browse files
authored
Secure server routes behind editor toolbar env var (#828)
1 parent 383cf00 commit 2fbf041

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mesop/server/server.py

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
"MESOP_AI_SERVICE_BASE_URL", "http://localhost:43234"
2727
)
2828

29+
EXPERIMENTAL_EDITOR_TOOLBAR_ENABLED = (
30+
os.environ.get("MESOP_EXPERIMENTAL_EDITOR_TOOLBAR", "false").lower() == "true"
31+
)
32+
33+
2934
LOCALHOSTS = (
3035
# For IPv4 localhost
3136
"127.0.0.1",
@@ -400,6 +405,8 @@ def hot_reload() -> Response:
400405

401406

402407
def check_editor_access():
408+
if not EXPERIMENTAL_EDITOR_TOOLBAR_ENABLED:
409+
abort(403) # Throws a Forbidden Error
403410
# Prevent accidental usages of editor mode outside of
404411
# one's local computer
405412
if request.remote_addr not in LOCALHOSTS:

0 commit comments

Comments
 (0)