Skip to content

Commit

Permalink
Fix CSRF & bump to v0.7.1 (#328)
Browse files Browse the repository at this point in the history
* Disable CSRF check for debug mode (to support Colab)
* Bump to v0.7.1
  • Loading branch information
wwwillchen authored May 30, 2024
1 parent 55c20b4 commit d7b9f32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion mesop/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ def generate_data(ui_request: pb.UiRequest) -> Generator[str, None, None]:
def ui_stream() -> Response:
# Prevent CSRF by checking the request origin matches the origin
# of the URL root (where the Flask app is being served from)
if not is_same_origin(request.headers.get("Origin"), request.url_root):
#
# Skip the check if it's running in debug mode because when
# running in Colab, the UI and HTTP requests are on different origins.
if not runtime().debug_mode and not is_same_origin(
request.headers.get("Origin"), request.url_root
):
abort(403, "Rejecting cross-site POST request to /ui")
data = request.data
if not data:
Expand Down
2 changes: 1 addition & 1 deletion mesop/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Contains the version string."""

VERSION = "0.7.0"
VERSION = "0.7.1"

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

0 comments on commit d7b9f32

Please sign in to comment.