You are here

public function LTIToolProvider::applies 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::applies()

Overrides AuthenticationProviderInterface::applies

See also

https://www.imsglobal.org/wiki/step-1-lti-launch-request

File

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

Class

LTIToolProvider
Oauth authentication provider for LTI Tool Provider.

Namespace

Drupal\lti_tool_provider\Authentication\Provider

Code

public function applies(Request $request) : bool {
  $lti_message_type = $request->request
    ->get('lti_message_type');
  $lti_version = $request->request
    ->get('lti_version');
  $oauth_consumer_key = $request->request
    ->get('oauth_consumer_key');
  $resource_link_id = $request->request
    ->get('resource_link_id');
  if (!$request
    ->isMethod('POST')) {
    return FALSE;
  }
  if ($lti_message_type !== 'basic-lti-launch-request') {
    return FALSE;
  }
  if (!in_array($lti_version, [
    'LTI-1p0',
    'LTI-1p2',
  ])) {
    return FALSE;
  }
  if (empty($oauth_consumer_key)) {
    return FALSE;
  }
  if (empty($resource_link_id)) {
    return FALSE;
  }
  return TRUE;
}