Skip to content

Commit

Permalink
MDL-68384 mod_lti: fix spec violations bo claim name and dl value type
Browse files Browse the repository at this point in the history
  • Loading branch information
claudevervoort committed Sep 28, 2020
1 parent a36870c commit d224506
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
28 changes: 18 additions & 10 deletions mod/lti/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ function lti_get_jwt_claim_mapping() {
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'accept_copy_advice',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'accept_media_types' => [
'suffix' => 'dl',
Expand All @@ -138,7 +139,8 @@ function lti_get_jwt_claim_mapping() {
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'accept_multiple',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'accept_presentation_document_targets' => [
'suffix' => 'dl',
Expand All @@ -156,19 +158,22 @@ function lti_get_jwt_claim_mapping() {
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'accept_unsigned',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'auto_create' => [
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'auto_create',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'can_confirm' => [
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'can_confirm',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'content_item_return_url' => [
'suffix' => 'dl',
Expand Down Expand Up @@ -389,7 +394,7 @@ function lti_get_jwt_claim_mapping() {
'tool_consumer_info_product_family_code' => [
'suffix' => '',
'group' => 'tool_platform',
'claim' => 'family_code',
'claim' => 'product_family_code',
'isarray' => false
],
'tool_consumer_info_version' => [
Expand Down Expand Up @@ -483,14 +488,14 @@ function lti_get_jwt_claim_mapping() {
'isarray' => false
],
'lis_outcome_service_url' => [
'suffix' => 'bos',
'group' => 'basicoutcomesservice',
'suffix' => 'bo',
'group' => 'basicoutcome',
'claim' => 'lis_outcome_service_url',
'isarray' => false
],
'lis_result_sourcedid' => [
'suffix' => 'bos',
'group' => 'basicoutcomesservice',
'suffix' => 'bo',
'group' => 'basicoutcome',
'claim' => 'lis_result_sourcedid',
'isarray' => false
],
Expand Down Expand Up @@ -3192,9 +3197,12 @@ function lti_sign_jwt($parms, $endpoint, $oauthconsumerkey, $typeid = 0, $nonce
$claim = LTI_JWT_CLAIM_PREFIX;
if (array_key_exists($key, $claimmapping)) {
$mapping = $claimmapping[$key];
$type = $mapping["type"] ?? "string";
if ($mapping['isarray']) {
$value = explode(',', $value);
sort($value);
} else if ($type == 'boolean') {
$value = isset($value) && ($value == 'true');
}
if (!empty($mapping['suffix'])) {
$claim .= "-{$mapping['suffix']}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private function users_to_json($resource, $users, $course, $exclude, $limitfrom,
$serviceurl = lti_ensure_url_is_https($serviceurl);
}
$basicoutcome->lis_outcome_service_url = $serviceurl;
$message->{'https://purl.imsglobal.org/spec/lti-bos/claim/basicoutcomesservice'} = $basicoutcome;
$message->{'https://purl.imsglobal.org/spec/lti-bo/claim/basicoutcome'} = $basicoutcome;
}
$member->message = [$message];
}
Expand Down
25 changes: 15 additions & 10 deletions mod/lti/tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ public function test_lti_get_jwt_claim_mapping() {
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'accept_copy_advice',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'accept_media_types' => [
'suffix' => 'dl',
Expand All @@ -639,7 +640,8 @@ public function test_lti_get_jwt_claim_mapping() {
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'accept_multiple',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'accept_presentation_document_targets' => [
'suffix' => 'dl',
Expand All @@ -657,19 +659,22 @@ public function test_lti_get_jwt_claim_mapping() {
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'accept_unsigned',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'auto_create' => [
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'auto_create',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'can_confirm' => [
'suffix' => 'dl',
'group' => 'deep_linking_settings',
'claim' => 'can_confirm',
'isarray' => false
'isarray' => false,
'type' => 'boolean'
],
'content_item_return_url' => [
'suffix' => 'dl',
Expand Down Expand Up @@ -890,7 +895,7 @@ public function test_lti_get_jwt_claim_mapping() {
'tool_consumer_info_product_family_code' => [
'suffix' => '',
'group' => 'tool_platform',
'claim' => 'family_code',
'claim' => 'product_family_code',
'isarray' => false
],
'tool_consumer_info_version' => [
Expand Down Expand Up @@ -984,14 +989,14 @@ public function test_lti_get_jwt_claim_mapping() {
'isarray' => false
],
'lis_outcome_service_url' => [
'suffix' => 'bos',
'group' => 'basicoutcomesservice',
'suffix' => 'bo',
'group' => 'basicoutcome',
'claim' => 'lis_outcome_service_url',
'isarray' => false
],
'lis_result_sourcedid' => [
'suffix' => 'bos',
'group' => 'basicoutcomesservice',
'suffix' => 'bo',
'group' => 'basicoutcome',
'claim' => 'lis_result_sourcedid',
'isarray' => false
],
Expand Down

0 comments on commit d224506

Please sign in to comment.