aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/classes/LTI13a/Registration.php13
-rw-r--r--lib/models/LtiPlatform.php13
-rw-r--r--lib/models/LtiTool.php28
3 files changed, 50 insertions, 4 deletions
diff --git a/lib/classes/LTI13a/Registration.php b/lib/classes/LTI13a/Registration.php
index 096519e..2ce1e8d 100644
--- a/lib/classes/LTI13a/Registration.php
+++ b/lib/classes/LTI13a/Registration.php
@@ -110,7 +110,8 @@ class Registration implements RegistrationInterface
if ($this->tool) {
return $this->tool->getToolData();
} elseif ($this->platform) {
- //TODO: Use the global tool configuration for Stud.IP as LTI tool.
+ //Return the global tool:
+ return \LtiTool::getGlobalTool();
}
//If no tool or platform is present, the registration is not linked to a tool.
throw new \Studip\LTIException(
@@ -186,7 +187,11 @@ class Registration implements RegistrationInterface
}
return $keyring->toKeyChain();
} elseif ($this->platform) {
- //TODO: return the global tool key chain.
+ //Return the global tool keychain.
+ $keyring = \LtiTool::getGlobalToolKeyring(true);
+ if ($keyring) {
+ return $keyring->toKeyChain();
+ }
}
return null;
@@ -208,8 +213,8 @@ class Registration implements RegistrationInterface
if ($this->tool) {
return $this->tool->jwks_url ?? null;
} else {
- //TODO: Return the global JWKS URL for Stud.IP as LTI tool.
- return null;
+ //Return the global JWKS URL for Stud.IP as LTI tool.
+ return \LtiTool::getGlobalJwksUrl();
}
}
}
diff --git a/lib/models/LtiPlatform.php b/lib/models/LtiPlatform.php
index 6a76add..6fe431f 100644
--- a/lib/models/LtiPlatform.php
+++ b/lib/models/LtiPlatform.php
@@ -13,6 +13,8 @@
* @category Stud.IP
*/
+use OAT\Library\Lti1p3Core\Platform\Platform;
+
/**
* The LtiPlatform class represents LTI 1.3A platforms that are using
@@ -57,4 +59,15 @@ class LtiPlatform extends SimpleORMap
['platform_id' => $this->id]
);
}
+
+ public function getPlatformData() : Platform
+ {
+ return new Platform(
+ $this->id,
+ $this->name,
+ $this->url,
+ $this->oidc_init_url,
+ $this->oauth2_access_token_url
+ );
+ }
}
diff --git a/lib/models/LtiTool.php b/lib/models/LtiTool.php
index bde6203..e6dfddc 100644
--- a/lib/models/LtiTool.php
+++ b/lib/models/LtiTool.php
@@ -193,4 +193,32 @@ class LtiTool extends SimpleORMap
return _('unbekannt');
}
}
+
+ public static function getGlobalTool() : Tool
+ {
+ $c = Config::get();
+
+ return new Tool(
+ $c->STUDIP_INSTALLATION_ID,
+ $c->UNI_NAME_CLEAN,
+ $GLOBALS['ABSOLUTE_URI_STUDIP'],
+ URLHelper::getURL('dispatch.php/lti/auth/odic_init', null, true),
+ URLHelper::getURL('dispatch.php/lti/auth/oauth2_token', null, true)
+ );
+ }
+
+ public static function getGlobalJwksUrl() : string
+ {
+ return \URLHelper::getURL('dispatch.php/lti/auth/jwks');
+ }
+
+ public static function getGlobalToolKeyring(bool $generate = false) : ?\Keyring
+ {
+ $keyring = \Keyring::findOneBySQL("`range_type` = 'global' AND `range_id` = 'lti13a_tool'");
+ if ($generate && !$keyring) {
+ //Generate the keyring:
+ $keyring = \Keyring::generate('lti13a_tool', 'global');
+ }
+ return $keyring;
+ }
}