Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  
   3  require_once($CFG->dirroot . '/enrol/lti/ims-blti/OAuth.php');
   4  
   5  /**
   6   * A Trivial memory-based store - no support for tokens
   7   */
   8  class TrivialOAuthDataStore extends OAuthDataStore {
   9      private $consumers = array();
  10  
  11      function add_consumer($consumer_key, $consumer_secret) {
  12          $this->consumers[$consumer_key] = $consumer_secret;
  13      }
  14  
  15      function lookup_consumer($consumer_key) {
  16          if ( strpos($consumer_key, "http://" ) === 0 ) {
  17              $consumer = new OAuthConsumer($consumer_key,"secret", NULL);
  18              return $consumer;
  19          }
  20          if ( $this->consumers[$consumer_key] ) {
  21              $consumer = new OAuthConsumer($consumer_key,$this->consumers[$consumer_key], NULL);
  22              return $consumer;
  23          }
  24          return NULL;
  25      }
  26  
  27      function lookup_token($consumer, $token_type, $token) {
  28          return new OAuthToken($consumer, "");
  29      }
  30  
  31      // Return NULL if the nonce has not been used
  32      // Return $nonce if the nonce was previously used
  33      function lookup_nonce($consumer, $token, $nonce, $timestamp) {
  34          // Should add some clever logic to keep nonces from
  35          // being reused - for no we are really trusting
  36      // that the timestamp will save us
  37          return NULL;
  38      }
  39  
  40      function new_request_token($consumer) {
  41          return NULL;
  42      }
  43  
  44      function new_access_token($token, $consumer) {
  45          return NULL;
  46      }
  47  }
  48  ?>