Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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  ?>