From 6d25edc685e7b369d9295d0da5a62214d0189405 Mon Sep 17 00:00:00 2001 From: Janos Pribelszki Date: Fri, 15 Mar 2024 13:18:39 +0100 Subject: [PATCH] backport: MS-2756 backport to v15.15.0.1 --- composer.json | 2 +- models/classes/LtiService.php | 19 ++++++++++++++++++- models/classes/TaoLtiSession.php | 8 ++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index d15c2e4d..7743e261 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "oat-sa/lib-lti1p3-ags": "^1.2", "oat-sa/lib-lti1p3-core": "^6.0.0", "oat-sa/generis" : ">=15.22", - "oat-sa/tao-core" : ">=50.24.6" + "oat-sa/tao-core" : "53.15.1.1" }, "autoload" : { "psr-4" : { diff --git a/models/classes/LtiService.php b/models/classes/LtiService.php index 192fbfc0..d05b7e23 100644 --- a/models/classes/LtiService.php +++ b/models/classes/LtiService.php @@ -35,6 +35,8 @@ use oat\oatbox\service\ConfigurableService; use oat\oatbox\service\ServiceManager; use oat\oatbox\session\SessionService; +use oat\tao\model\session\Context\TenantDataSessionContext; +use oat\tao\model\session\Context\UserDataSessionContext; use oat\tao\model\TaoOntology; use oat\taoLti\models\classes\LtiMessages\LtiErrorMessage; use oat\taoLti\models\classes\user\Lti1p3User; @@ -111,8 +113,23 @@ public function createLti1p3Session( $ltiUser->setRegistrationId($registration->getIdentifier()); - $session = TaoLtiSession::fromVersion1p3($ltiUser); + $contexts = []; + if ($clientId) { + $userId = $messagePayload->getUserIdentity(); + $clientIdParts = explode('-', $clientId); + $contexts = [ + new UserDataSessionContext( + $userId->getIdentifier(), + $userId->getIdentifier(), + $userId->getName(), + $userId->getEmail(), + $userId->getLocale() + ), + new TenantDataSessionContext(end($clientIdParts)) + ]; + } + $session = TaoLtiSession::fromVersion1p3($ltiUser, $contexts); $this->getServiceLocator()->propagate($session); return $session; diff --git a/models/classes/TaoLtiSession.php b/models/classes/TaoLtiSession.php index 063dcf33..21b6d9a0 100644 --- a/models/classes/TaoLtiSession.php +++ b/models/classes/TaoLtiSession.php @@ -37,14 +37,14 @@ class TaoLtiSession extends common_session_DefaultSession /** @var string */ private $version = self::VERSION_LTI_1P1; - public function __construct(LtiUserInterface $user) + public function __construct(LtiUserInterface $user, array $contexts = []) { - parent::__construct($user); + parent::__construct($user, $contexts); } - public static function fromVersion1p3(LtiUserInterface $user): self + public static function fromVersion1p3(LtiUserInterface $user, array $contexts = []): self { - $session = new self($user); + $session = new self($user, $contexts); $session->version = self::VERSION_LTI_1P3;