Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 1321... Línea 1321...
1321
    try {
1321
    try {
1322
        if (empty($keyset)) {
1322
        if (empty($keyset)) {
1323
            throw new moodle_exception('errornocachedkeysetfound', 'mod_lti');
1323
            throw new moodle_exception('errornocachedkeysetfound', 'mod_lti');
1324
        }
1324
        }
1325
        $keysetarr = json_decode($keyset, true);
1325
        $keysetarr = json_decode($keyset, true);
1326
        // JWK::parseKeySet uses RS256 algorithm by default.
-
 
1327
        $keys = JWK::parseKeySet($keysetarr);
1326
        $keys = JWK::parseKeySet($keysetarr);
1328
        $jwt = JWT::decode($jwtparam, $keys);
1327
        $jwt = JWT::decode($jwtparam, $keys);
1329
    } catch (Exception $e) {
1328
    } catch (Exception $e) {
1330
        // Something went wrong, so attempt to update cached keyset and then try again.
1329
        // Something went wrong, so attempt to update cached keyset and then try again.
1331
        $keyset = download_file_content($keyseturl);
1330
        $keyset = download_file_content($keyseturl);
1332
        $keysetarr = json_decode($keyset, true);
1331
        $keysetarr = json_decode($keyset, true);
Línea 1333... Línea 1332...
1333
 
1332
 
-
 
1333
        // Fix for firebase/php-jwt's dependency on the optional 'alg' property in the JWK.
-
 
1334
        // The fix_jwks_alg() call only fixes a single, matched key and will leave others present (which may be missing alg too),
1334
        // Fix for firebase/php-jwt's dependency on the optional 'alg' property in the JWK.
1335
        // Remaining keys missing alg are excluded since they cannot be used for decoding anyway (no match to JWT kid).
-
 
1336
        $keysetarr = jwks_helper::fix_jwks_alg($keysetarr, $jwtparam);
Línea 1335... Línea 1337...
1335
        $keysetarr = jwks_helper::fix_jwks_alg($keysetarr, $jwtparam);
1337
        $keysetarr['keys'] = array_filter($keysetarr['keys'], fn($key) => isset($key['alg']));
1336
 
1338
 
1337
        // JWK::parseKeySet uses RS256 algorithm by default.
1339
        // JWK::parseKeySet uses RS256 algorithm by default.
1338
        $keys = JWK::parseKeySet($keysetarr);
1340
        $keys = JWK::parseKeySet($keysetarr);
Línea 4352... Línea 4354...
4352
    }
4354
    }
4353
    // If it has xml at the end of the url, it's a cartridge.
4355
    // If it has xml at the end of the url, it's a cartridge.
4354
    if (preg_match('/\.xml$/', $url)) {
4356
    if (preg_match('/\.xml$/', $url)) {
4355
        return true;
4357
        return true;
4356
    }
4358
    }
-
 
4359
 
-
 
4360
    // Skip slow cartridge checks during tests.
-
 
4361
    // During tests, working .xml cartridge URLs are used when testing cartridge support. These will match the '.xml' check
-
 
4362
    // above (which is fast). Don't try to check whether other tool URLs are cartridges because most URLs used in tests will be
-
 
4363
    // example URLs and won't be resolvable, resulting in network hangs within load_cartridge() - which is called every time a
-
 
4364
    // tool is edited and will result in slow tests or seemingly random test failures.
-
 
4365
    if (!defined('BEHAT_SITE_RUNNING') && !defined('PHPUNIT_TEST')) {
4357
    // Even if it doesn't have .xml, load the url to check if it's a cartridge..
4366
        // Even if it doesn't have .xml, load the url to check if it's a cartridge..
4358
    try {
4367
        try {
4359
        $toolinfo = lti_load_cartridge($url,
4368
            $toolinfo = lti_load_cartridge($url,
4360
            array(
4369
                array(
4361
                "launch_url" => "launchurl"
4370
                    "launch_url" => "launchurl"
4362
            )
4371
                )
4363
        );
4372
            );
4364
        if (!empty($toolinfo['launchurl'])) {
4373
            if (!empty($toolinfo['launchurl'])) {
4365
            return true;
4374
                return true;
-
 
4375
            }
-
 
4376
        } catch (moodle_exception $e) {
-
 
4377
            return false; // Error loading the xml, so it's not a cartridge.
4366
        }
4378
        }
4367
    } catch (moodle_exception $e) {
-
 
4368
        return false; // Error loading the xml, so it's not a cartridge.
-
 
4369
    }
4379
    }
4370
    return false;
4380
    return false;
4371
}
4381
}
Línea 4372... Línea 4382...
4372
 
4382
 
Línea 4582... Línea 4592...
4582
    $newtoken->lastaccess = null;
4592
    $newtoken->lastaccess = null;
Línea 4583... Línea 4593...
4583
 
4593
 
Línea 4584... Línea 4594...
4584
    $DB->insert_record('lti_access_tokens', $newtoken);
4594
    $DB->insert_record('lti_access_tokens', $newtoken);
4585
 
-
 
4586
    return $newtoken;
-
 
4587
 
-
 
4588
}
-
 
4589
 
-
 
4590
 
-
 
4591
/**
-
 
4592
 * Wrapper for function libxml_disable_entity_loader() deprecated in PHP 8
-
 
4593
 *
-
 
4594
 * Method was deprecated in PHP 8 and it shows deprecation message. However it is still
-
 
4595
 * required in the previous versions on PHP. While Moodle supports both PHP 7 and 8 we need to keep it.
-
 
4596
 * @see https://php.watch/versions/8.0/libxml_disable_entity_loader-deprecation
-
 
4597
 *
-
 
4598
 * @param bool $value
-
 
4599
 * @return bool
-
 
4600
 *
-
 
4601
 * @deprecated since Moodle 4.3
-
 
4602
 */
-
 
4603
function lti_libxml_disable_entity_loader(bool $value): bool {
-
 
4604
    debugging(__FUNCTION__ . '() is deprecated, please do not use it any more', DEBUG_DEVELOPER);
4595