Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't protect static assets from XSRF #592

Merged
merged 6 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ below.
- Mel Hall
- Christopher Bennett
- Mark Dawson
- Min RK
<!-- end-shortlog -->

(All contributors are identifiable with email addresses in the git version
Expand Down
1 change: 1 addition & 0 deletions changes.d/592.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compatibility with JupyterHub 4.1 XSRF changes for static requests
13 changes: 13 additions & 0 deletions cylc/uiserver/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,23 @@ class CylcStaticHandler(CylcAppHandler, web.StaticFileHandler):
def initialize(self, *args, **kwargs):
return web.StaticFileHandler.initialize(self, *args, **kwargs)

def check_xsrf_cookie(self):
# don't need XSRF protections on static assets
return

@web.authenticated
def get(self, path):
# authenticate the static handler
# this provides us with login redirection and token caching
if not path:
# Request for /index.html
# Accessing xsrf_token ensures xsrf cookie is set
# to be available for next request to /userprofile
self.xsrf_token
# Ensure request goes through this method even when cached so
# that the xsrf cookie is set on new browser sessions
# (doesn't prevent browser storing the response):
self.set_header('Cache-Control', 'no-cache')
return web.StaticFileHandler.get(self, path)


Expand Down
Loading