You are here

public function LTIToolProvider::consumerHandler in LTI Tool Provider 2.x

Same name and namespace in other branches
  1. 8 src/Authentication/Provider/LTIToolProvider.php \Drupal\lti_tool_provider\Authentication\Provider\LTIToolProvider::consumerHandler()

Looks up the consumer entity that matches the consumer key.

Parameters

$provider:

Return value

int

  • OAUTH_OK if validated.
  • OAUTH_CONSUMER_KEY_UNKNOWN if not.

File

src/Authentication/Provider/LTIToolProvider.php, line 289

Class

LTIToolProvider
Oauth authentication provider for LTI Tool Provider.

Namespace

Drupal\lti_tool_provider\Authentication\Provider

Code

public function consumerHandler($provider) : int {
  try {
    $ids = $this->entityTypeManager
      ->getStorage('lti_tool_provider_consumer')
      ->getQuery()
      ->condition('consumer_key', $provider->consumer_key, '=')
      ->execute();
    if (!count($ids)) {
      return OAUTH_CONSUMER_KEY_UNKNOWN;
    }
    $this->consumerEntity = $this->entityTypeManager
      ->getStorage('lti_tool_provider_consumer')
      ->load(key($ids));
    $provider->consumer_secret = $this->consumerEntity
      ->get('consumer_secret')
      ->getValue()[0]['value'];
  } catch (InvalidPluginDefinitionException|PluginNotFoundException $e) {
    return OAUTH_CONSUMER_KEY_UNKNOWN;
  }
  return OAUTH_OK;
}