Skip to content

Commit

Permalink
✨(backend) allow IMS LIS LTI roles
Browse files Browse the repository at this point in the history
When parsing LTI role string from requests, we want to handle IMS LIS
format.
  • Loading branch information
kernicPanel committed Dec 20, 2024
1 parent 09bb96f commit 7745660
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Support for the IMS LIS role format in the LTI launch

## [5.5.1] - 2024-11-29

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions src/backend/marsha/core/lti/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def roles(self):
"""
roles = self.request.POST.get("roles", "")
# remove LIS roles prefix
roles = re.sub(r"^urn:lti:instrole:ims/lis/", "", roles)
# Remove all spaces from the string and extra trailing or leading commas
roles = re.sub(r"[\s+]", "", roles).strip(",")
# Return a set of the roles mentioned in the request
Expand Down
1 change: 1 addition & 0 deletions src/backend/marsha/core/tests/lti/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_lti_video_instructor(self):
"student, Instructor", # a space after the comma is allowed
", staff", # a leading comma should be ignored
"staff,", # a trailing comma should be ignored
"urn:lti:instrole:ims/lis/Instructor", # the LIS role identifier should be recognized
]:
request = self.factory.post("/", {"roles": roles_string})
lti = LTI(request, uuid.uuid4())
Expand Down

0 comments on commit 7745660

Please sign in to comment.