Skip to content

Commit

Permalink
Restrict access to fullscreen labs directly from an URL
Browse files Browse the repository at this point in the history
Add more authentication checks when acessing a fullscreen lab
direclty from an URL. Return a 401 when the user is not
authenticated in the platfrom.
  • Loading branch information
Maari Tamm committed Nov 13, 2024
1 parent 541d4c2 commit 2b21ad1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Unreleased
-------------------------
* [Bug fix] Add more authentication checks when accessing a fullscreen
lab directly from an URL. Return a 401 when user is not authenticated
on the platform.

Version 8.0.0 (2024-10-16)
-------------------------
* Drop support for Python 3.8 and `XBlock<2` (and, as a consequence,
Expand Down
2 changes: 1 addition & 1 deletion hastexo/hastexo.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def launch_new_window(self, request, suffix=''):
"""
The fullscreen lab view, opened in a new browser window.
"""
if 'sessionid' not in request.cookies:
if not all(c in request.cookies for c in ('sessionid', 'edxloggedin')):
return Response(status=401, body="Unauthorized")

# Get context
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_hastexo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ def test_launch_new_window(self):
with patch('webob.Request') as request:
request.cookies = Mock()
request.cookies = {
'edxloggedin': 'true',
'sessionid': 'fake_sessionid',
'csrftoken': 'fake_csrf_token'}
response = self.block.launch_new_window(request)
Expand Down

0 comments on commit 2b21ad1

Please sign in to comment.