Differences Between: [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace Packback\Lti1p3\MessageValidators; 4 5 use Packback\Lti1p3\Interfaces\IMessageValidator; 6 use Packback\Lti1p3\LtiConstants; 7 use Packback\Lti1p3\LtiException; 8 9 class ResourceMessageValidator implements IMessageValidator 10 { 11 public function canValidate(array $jwtBody) 12 { 13 return $jwtBody[LtiConstants::MESSAGE_TYPE] === 'LtiResourceLinkRequest'; 14 } 15 16 public function validate(array $jwtBody) 17 { 18 if (empty($jwtBody['sub'])) { 19 throw new LtiException('Must have a user (sub)'); 20 } 21 if (!isset($jwtBody[LtiConstants::VERSION])) { 22 throw new LtiException('Missing LTI Version'); 23 } 24 if ($jwtBody[LtiConstants::VERSION] !== LtiConstants::V1_3) { 25 throw new LtiException('Incorrect version, expected 1.3.0'); 26 } 27 if (!isset($jwtBody[LtiConstants::ROLES])) { 28 throw new LtiException('Missing Roles Claim'); 29 } 30 if (empty($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) { 31 throw new LtiException('Missing Resource Link Id'); 32 } 33 34 return true; 35 } 36 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body