Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 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 SubmissionReviewMessageValidator implements IMessageValidator
  10  {
  11      public function canValidate(array $jwtBody)
  12      {
  13          return $jwtBody[LtiConstants::MESSAGE_TYPE] === 'LtiSubmissionReviewRequest';
  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 ($jwtBody[LtiConstants::VERSION] !== LtiConstants::V1_3) {
  22              throw new LtiException('Incorrect version, expected 1.3.0');
  23          }
  24          if (!isset($jwtBody[LtiConstants::ROLES])) {
  25              throw new LtiException('Missing Roles Claim');
  26          }
  27          if (empty($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
  28              throw new LtiException('Missing Resource Link Id');
  29          }
  30          if (empty($jwtBody[LtiConstants::FOR_USER])) {
  31              throw new LtiException('Missing For User');
  32          }
  33  
  34          return true;
  35      }
  36  }