Skip to content
Snippets Groups Projects
Commit 86366e92 authored by Elmar Ludwig's avatar Elmar Ludwig Committed by Jan-Hendrik Willms
Browse files

add lis_course_section_sourcedid parameter, fixes #4461

Closes #4461

Merge request studip/studip!3246
parent 56f429e3
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ class LtiLink
protected $launch_url;
protected $consumer_key;
protected $consumer_secret;
protected $oauth_signature_method;
protected $signature_method;
// launch parameters and variables
protected $parameters = [];
......@@ -37,13 +37,14 @@ class LtiLink
* @param string $launch_url launch URL of external LTI tool
* @param string $consumer_key consumer key of the LTI link
* @param string $consumer_secret consumer secret of the LTI link
* @param string $signature_method signature method to use (optional)
*/
public function __construct($launch_url, $consumer_key, $consumer_secret, $oauth_signature_method = 'sha1')
public function __construct($launch_url, $consumer_key, $consumer_secret, $signature_method = 'sha1')
{
$this->launch_url = $launch_url;
$this->consumer_key = $consumer_key;
$this->consumer_secret = $consumer_secret;
$this->oauth_signature_method = $oauth_signature_method;
$this->signature_method = $signature_method;
// Basic LTI uses OAuth to sign requests
// OAuth Core 1.0 spec: http://oauth.net/core/1.0/
......@@ -55,7 +56,7 @@ class LtiLink
'oauth_version' => '1.0',
'oauth_nonce' => uniqid('lti', true),
'oauth_timestamp' => time(),
'oauth_signature_method' => 'HMAC-' . strtoupper($this->oauth_signature_method),
'oauth_signature_method' => 'HMAC-' . strtoupper($this->signature_method),
'tool_consumer_info_product_family_code' => 'studip',
'tool_consumer_info_version' => $GLOBALS['SOFTWARE_VERSION'],
'tool_consumer_instance_guid' => Config::get()->STUDIP_INSTALLATION_ID,
......@@ -123,6 +124,7 @@ class LtiLink
'context_type' => $this->variables['Context.type'],
'context_label' => $this->variables['Context.label'],
'context_title' => $this->variables['Context.title'],
'lis_course_section_sourcedid' => $this->variables['CourseSection.sourcedId'],
]);
}
}
......@@ -316,6 +318,6 @@ class LtiLink
$base_string = 'POST&' . rawurlencode($launch_url) . '&' . rawurlencode($launch_params);
$secret = rawurlencode($this->consumer_secret) . '&';
return base64_encode(hash_hmac($this->oauth_signature_method, $base_string, $secret, true));
return base64_encode(hash_hmac($this->signature_method, $base_string, $secret, true));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment