mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-65536 mod_lti: fix stale platformid when wwwroot is changed
If the site is installed, and then the wwwroot changed, the plugin config value for platformid for mod_lti is then stale, resulting in OIDC errors. Given this config value was set using the wwwroot, we should just be able to use the value of $CFG->wwwroot direcly, thus avoiding this problem.
This commit is contained in:
parent
6a7451ff1b
commit
63dd2951bb
@ -28,11 +28,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* Stub for database installation.
|
||||
*/
|
||||
function xmldb_lti_install() {
|
||||
global $CFG;
|
||||
|
||||
// Add platform ID configuration setting.
|
||||
set_config('platformid', $CFG->wwwroot, 'mod_lti');
|
||||
|
||||
// Create the private key.
|
||||
$kid = bin2hex(openssl_random_pseudo_bytes(10));
|
||||
set_config('kid', $kid, 'mod_lti');
|
||||
|
@ -157,9 +157,6 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Add platform ID configuration setting.
|
||||
set_config('platformid', $CFG->wwwroot, 'mod_lti');
|
||||
|
||||
// Create the private key.
|
||||
$kid = bin2hex(openssl_random_pseudo_bytes(10));
|
||||
set_config('kid', $kid, 'mod_lti');
|
||||
|
@ -3018,6 +3018,7 @@ function lti_sign_parameters($oldparms, $endpoint, $method, $oauthconsumerkey, $
|
||||
* @return array|null
|
||||
*/
|
||||
function lti_sign_jwt($parms, $endpoint, $oauthconsumerkey, $typeid = 0, $nonce = '') {
|
||||
global $CFG;
|
||||
|
||||
if (empty($typeid)) {
|
||||
$typeid = 0;
|
||||
@ -3054,7 +3055,7 @@ function lti_sign_jwt($parms, $endpoint, $oauthconsumerkey, $typeid = 0, $nonce
|
||||
'iat' => $now,
|
||||
'exp' => $now + 60,
|
||||
);
|
||||
$payload['iss'] = get_config('mod_lti', 'platformid');
|
||||
$payload['iss'] = $CFG->wwwroot;
|
||||
$payload['aud'] = $oauthconsumerkey;
|
||||
$payload[LTI_JWT_CLAIM_PREFIX . '/claim/deployment_id'] = strval($typeid);
|
||||
$payload[LTI_JWT_CLAIM_PREFIX . '/claim/target_link_uri'] = $endpoint;
|
||||
@ -3264,7 +3265,7 @@ function lti_post_launch_html($newparms, $endpoint, $debug=false) {
|
||||
*/
|
||||
function lti_initiate_login($courseid, $id, $instance, $config, $messagetype = 'basic-lti-launch-request', $title = '',
|
||||
$text = '') {
|
||||
global $SESSION, $USER;
|
||||
global $SESSION, $USER, $CFG;
|
||||
|
||||
if (!empty($instance)) {
|
||||
$endpoint = !empty($instance->toolurl) ? $instance->toolurl : $config->lti_toolurl;
|
||||
@ -3284,7 +3285,7 @@ function lti_initiate_login($courseid, $id, $instance, $config, $messagetype = '
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['iss'] = get_config('mod_lti', 'platformid');
|
||||
$params['iss'] = $CFG->wwwroot;
|
||||
$params['target_link_uri'] = $endpoint;
|
||||
$params['login_hint'] = $USER->id;
|
||||
$params['lti_message_hint'] = $id;
|
||||
@ -3839,7 +3840,8 @@ function get_tool_type_state_info(stdClass $type) {
|
||||
* @return array An array with configuration details
|
||||
*/
|
||||
function get_tool_type_config($type) {
|
||||
$platformid = get_config('mod_lti', 'platformid');
|
||||
global $CFG;
|
||||
$platformid = $CFG->wwwroot;
|
||||
$clientid = $type->clientid;
|
||||
$deploymentid = $type->id;
|
||||
$publickeyseturl = new moodle_url('/mod/lti/certs.php');
|
||||
@ -3940,7 +3942,7 @@ function serialise_tool_type(stdClass $type) {
|
||||
'description' => $description,
|
||||
'urls' => get_tool_type_urls($type),
|
||||
'state' => get_tool_type_state_info($type),
|
||||
'platformid' => get_config('mod_lti', 'platformid'),
|
||||
'platformid' => $CFG->wwwroot,
|
||||
'clientid' => $type->clientid,
|
||||
'deploymentid' => $type->id,
|
||||
'hascapabilitygroups' => !empty($capabilitygroups),
|
||||
|
Loading…
x
Reference in New Issue
Block a user