Skip to content

Commit d7b9f32

Browse files
authored
Fix CSRF & bump to v0.7.1 (#328)
* Disable CSRF check for debug mode (to support Colab) * Bump to v0.7.1
1 parent 55c20b4 commit d7b9f32

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

mesop/server/server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ def generate_data(ui_request: pb.UiRequest) -> Generator[str, None, None]:
163163
def ui_stream() -> Response:
164164
# Prevent CSRF by checking the request origin matches the origin
165165
# of the URL root (where the Flask app is being served from)
166-
if not is_same_origin(request.headers.get("Origin"), request.url_root):
166+
#
167+
# Skip the check if it's running in debug mode because when
168+
# running in Colab, the UI and HTTP requests are on different origins.
169+
if not runtime().debug_mode and not is_same_origin(
170+
request.headers.get("Origin"), request.url_root
171+
):
167172
abort(403, "Rejecting cross-site POST request to /ui")
168173
data = request.data
169174
if not data:

mesop/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Contains the version string."""
22

3-
VERSION = "0.7.0"
3+
VERSION = "0.7.1"
44

55
if __name__ == "__main__":
66
print(VERSION)

0 commit comments

Comments
 (0)