Skip to content

Commit a61c65b

Browse files
committed
🐛(backend) fix blackboard LTI roles parsing
Parsing LTI roles sent by blackboard was broken. Fixes #2676
1 parent 0b443a1 commit a61c65b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Fixed
12+
13+
- Fix blackboard LTI roles parsing
14+
1115
## [5.5.2] - 2024-12-19
1216

1317
### Added

src/backend/marsha/core/lti/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def roles(self):
265265
"""
266266
roles = self.request.POST.get("roles", "")
267267
# remove LIS roles prefix
268-
roles = re.sub(r"^urn:lti:instrole:ims/lis/", "", roles)
268+
roles = re.sub(r"urn:lti:(inst)?role:ims/lis/", "", roles)
269269
# Remove all spaces from the string and extra trailing or leading commas
270270
roles = re.sub(r"[\s+]", "", roles).strip(",")
271271
# Return a set of the roles mentioned in the request

src/backend/marsha/core/tests/lti/tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ def test_lti_video_instructor(self):
9797
", staff", # a leading comma should be ignored
9898
"staff,", # a trailing comma should be ignored
9999
"urn:lti:instrole:ims/lis/Instructor", # the LIS role identifier should be recognized
100+
"urn:lti:role:ims/lis/Instructor,urn:lti:instrole:ims/lis/Faculty",
100101
]:
101102
request = self.factory.post("/", {"roles": roles_string})
102103
lti = LTI(request, uuid.uuid4())
103-
self.assertTrue(lti.is_instructor)
104+
self.assertTrue(lti.is_instructor, roles_string)
104105

105106
for roles_string in ["", "instructori", "student", "administrator,student"]:
106107
request = self.factory.post("/", {"roles": roles_string})
107108
lti = LTI(request, uuid.uuid4())
108-
self.assertFalse(lti.is_instructor)
109+
self.assertFalse(lti.is_instructor, roles_string)
109110

110111
@mock.patch.object(lti_module, "verify_request_common", return_value=True)
111112
def test_lti_passport_unknown(self, mock_verify):

0 commit comments

Comments
 (0)