From 7745660fb07b1ed5fef8f42ebb910073f7ce0389 Mon Sep 17 00:00:00 2001 From: Nicolas Clerc Date: Thu, 19 Dec 2024 17:04:27 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(backend)=20allow=20IMS=20LIS=20LTI=20?= =?UTF-8?q?roles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When parsing LTI role string from requests, we want to handle IMS LIS format. --- CHANGELOG.md | 4 ++++ src/backend/marsha/core/lti/__init__.py | 2 ++ src/backend/marsha/core/tests/lti/tests.py | 1 + 3 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 151052f075..91cd56e93a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/backend/marsha/core/lti/__init__.py b/src/backend/marsha/core/lti/__init__.py index ebd73dd43d..67cbecb299 100644 --- a/src/backend/marsha/core/lti/__init__.py +++ b/src/backend/marsha/core/lti/__init__.py @@ -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 diff --git a/src/backend/marsha/core/tests/lti/tests.py b/src/backend/marsha/core/tests/lti/tests.py index a4518e35e1..7fc0d8a726 100644 --- a/src/backend/marsha/core/tests/lti/tests.py +++ b/src/backend/marsha/core/tests/lti/tests.py @@ -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())