Skip to content

Commit

Permalink
v1.0.24 send plugin version using standard LTI claim
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-kialo committed Nov 17, 2023
1 parent f595e3f commit feb1630
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v1.0.24 (Build - 2023111701)

* Send plugin's version and "platform" information using standard LTI claims.

### v1.0.23 (Build - 2023102005)

* Send plugin version number to Kialo.
Expand Down
12 changes: 11 additions & 1 deletion classes/lti_flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
* Functions implementing the LTI steps.
*/
class lti_flow {
/**
* The "product_family_code" that the plugin uses to identify itself during LTI requests to tools.
*/
public const PRODUCT_FAMILY_CODE = "moodle_kialo_plugin";

/**
* Can be used to override the default JwksFetcher. Used for testing purposes.
*
Expand Down Expand Up @@ -309,7 +314,12 @@ public static function lti_auth(): LtiMessageInterface {
// See https://github.com/oat-sa/lib-lti1p3-core/issues/154.
$nonce = $request->getQueryParams()['nonce'] ?? '';
$payloadbuilder = new MessagePayloadBuilder(new static_nonce_generator($nonce));
$payloadbuilder->withClaim('kialo_plugin_version', kialo_config::get_release());

// See https://www.imsglobal.org/spec/lti/v1p3#platform-instance-claim.
$payloadbuilder->withClaim('https://purl.imsglobal.org/spec/lti/claim/tool_platform', [
'product_family_code' => self::PRODUCT_FAMILY_CODE,
'version' => kialo_config::get_release(),
]);

// Create the OIDC authenticator.
$authenticator = new OidcAuthenticator($registrationrepository, $userauthenticator, $payloadbuilder);
Expand Down
1 change: 1 addition & 0 deletions openid-configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function lti_get_capabilities() {
'claims_supported' => ['sub', 'iss', 'name', 'given_name', 'middle_name', 'family_name', 'email', 'picture', 'locale',
'zoneinfo',
],
// This is similar to https://www.imsglobal.org/spec/lti/v1p3#platform-instance-claim, but not the same!
'https://purl.imsglobal.org/spec/lti-platform-configuration' => [
'product_family_code' => 'moodle_kialo_plugin',
'version' => $CFG->release,
Expand Down
6 changes: 5 additions & 1 deletion tests/classes/lti_flow_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,11 @@ public function test_lti_auth(): void {
$this->assertEquals($this->user->firstname . " " . $this->user->lastname, $token->claims()->get("name"));
$this->assertEquals($this->user->email, $token->claims()->get("email"));
$this->assertEquals($this->user->lang, $token->claims()->get("locale"));
$this->assertEquals(kialo_config::get_release(), $token->claims()->get("kialo_plugin_version"));

$this->assertEquals([
"product_family_code" => lti_flow::PRODUCT_FAMILY_CODE,
"version" => kialo_config::get_release(),
], $token->claims()->get("https://purl.imsglobal.org/spec/lti/claim/tool_platform"));

global $PAGE, $USER;
$expectedpicture = new \user_picture($USER);
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
$plugin->component = 'mod_kialo';

// See https://moodledev.io/docs/apis/commonfiles/version.php.
$plugin->version = 2023102005; // Must be incremented for each new release!
$plugin->release = '1.0.23'; // Semantic version.
$plugin->version = 2023111701; // Must be incremented for each new release!
$plugin->release = '1.0.24'; // Semantic version.

// Officially we require PHP 7.4. The first Moodle version that requires this as a minimum is Moodle 4.1.
// But technically this plugin also runs on older Moodle versions, as long as they run on PHP 7.4,
Expand Down

0 comments on commit feb1630

Please sign in to comment.