Skip to content

Commit

Permalink
MDL-79844 core_ltix: update refs in moved site admin files
Browse files Browse the repository at this point in the history
This change gets the 'manage tools' site admin page and the pages
it links to (hidden legacy settings pages), working properly again.
  • Loading branch information
snake committed May 8, 2024
1 parent c97666c commit aab016a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions ltix/classes/output/tool_configure_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public function export_for_template(renderer_base $output) {

$url = new moodle_url('/ltix/typessettings.php', array('sesskey' => sesskey(), 'returnto' => 'toolconfigure'));
$data->configuremanualurl = $url->out();
$url = new moodle_url('/admin/settings.php?section=modsettinglti');
$url = new moodle_url('/admin/settings.php?section=ltisettings');
$data->managetoolsurl = $url->out();
$url = new moodle_url('/ltix/toolproxies.php');
$data->managetoolproxiesurl = $url->out();
$data->keyhelp = $keyhelp->export_for_template($output);
$data->secrethelp = $secrethelp->export_for_template($output);
return $data;
}
}
}
13 changes: 6 additions & 7 deletions ltix/openid-configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* It is part of the LTI Tool Dynamic Registration, and used by
* tools to get the site configuration and registration end-point.
*
* @package mod_lti
* @package core_ltix
* @copyright 2020 Claude Vervoort (Cengage), Carlos Costa, Adrian Hutchinson (Macgraw Hill)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -29,20 +29,19 @@

define('NO_DEBUG_DISPLAY', true);
define('NO_MOODLE_COOKIES', true);
require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/mod/lti/locallib.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir.'/weblib.php');

$scopes = registration_helper::get()->lti_get_service_scopes();
$scopes[] = 'openid';
$conf = [
'issuer' => $CFG->wwwroot,
'token_endpoint' => (new moodle_url('/mod/lti/token.php'))->out(false),
'token_endpoint' => (new moodle_url('/ltix/token.php'))->out(false),
'token_endpoint_auth_methods_supported' => ['private_key_jwt'],
'token_endpoint_auth_signing_alg_values_supported' => ['RS256'],
'jwks_uri' => (new moodle_url('/mod/lti/certs.php'))->out(false),
'authorization_endpoint' => (new moodle_url('/mod/lti/auth.php'))->out(false),
'registration_endpoint' => (new moodle_url('/mod/lti/openid-registration.php'))->out(false),
'jwks_uri' => (new moodle_url('/ltix/certs.php'))->out(false),
'authorization_endpoint' => (new moodle_url('/ltix/auth.php'))->out(false),
'registration_endpoint' => (new moodle_url('/ltix/openid-registration.php'))->out(false),
'scopes_supported' => $scopes,
'response_types_supported' => ['id_token'],
'subject_types_supported' => ['public', 'pairwise'],
Expand Down
13 changes: 7 additions & 6 deletions ltix/openid-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* This file receives a registration request along with the registration token and returns a client_id.
*
* @copyright 2020 Claude Vervoort (Cengage), Carlos Costa, Adrian Hutchinson (Macgraw Hill)
* @package mod_lti
* @package core_ltix
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_DEBUG_DISPLAY', true);
Expand All @@ -27,15 +27,16 @@
use core_ltix\local\ltiopenid\registration_helper;
use core_ltix\local\ltiopenid\registration_exception;

require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/mod/lti/locallib.php');
require_once(__DIR__ . '/../config.php');
require_once(__DIR__ . '/constants.php');
require_once(__DIR__ . '/OAuth.php'); // Required, since autoloading won't work for this collection of classes.

$code = 200;
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' or ($_SERVER['REQUEST_METHOD'] === 'GET')) {
$doregister = $_SERVER['REQUEST_METHOD'] === 'POST';
// Retrieve registration token from Bearer Authorization header.
$authheader = core_ltix\OAuthUtil::get_headers()['Authorization'] ?? '';
$authheader = \core_ltix\OAuthUtil::get_headers()['Authorization'] ?? '';
if (!($authheader && substr($authheader, 0, 7) == 'Bearer ')) {
$message = 'missing_registration_token';
$code = 401;
Expand All @@ -52,7 +53,7 @@
if ($doregister) {
$registrationpayload = json_decode(file_get_contents('php://input'), true);
$config = registration_helper::get()->registration_to_config($registrationpayload, $tokenres['clientid']);
if ($type->id) {
if (!empty($type->id)) {
\core_ltix\helper::update_type($type, clone $config);
$typeid = $type->id;
} else {
Expand All @@ -77,7 +78,7 @@
$code = 400;
$message = 'Unsupported operation';
}
$response = new \mod_lti\local\ltiservice\response();
$response = new \core_ltix\local\ltiservice\response();
// Set code.
$response->set_code($code);
// Set body.
Expand Down
13 changes: 6 additions & 7 deletions ltix/startltiadvregistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Redirect the user to registration with token and openid config url as query params.
*
* @package mod_lti
* @package core_ltix
* @copyright 2020 Cengage
* @author Claude Vervoort
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -28,9 +28,8 @@
use core_ltix\local\ltiopenid\jwks_helper;
use core_ltix\local\ltiopenid\registration_helper;

require_once(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->dirroot . '/mod/lti/locallib.php');

require_login();
$context = context_system::instance();
Expand All @@ -43,12 +42,12 @@

if (!empty($types) && $typeid == -1) {
// There are matching types for the registration domain, let's prompt the user to upgrade.
$pageurl = new moodle_url('/mod/lti/startltiadvregistration.php');
$pageurl = new moodle_url('/ltix/startltiadvregistration.php');
$PAGE->set_context($context);
$PAGE->set_url($pageurl);
$PAGE->set_pagelayout('maintenance');
$output = $PAGE->get_renderer('mod_lti');
$page = new \mod_lti\output\registration_upgrade_choice_page($types, $starturl);
$output = $PAGE->get_renderer('core_ltix');
$page = new \core_ltix\output\registration_upgrade_choice_page($types, $starturl);
echo $output->header();
echo $output->render($page);
echo $output->footer();
Expand All @@ -72,7 +71,7 @@
];
$privatekey = jwks_helper::get_private_key();
$regtoken = JWT::encode($token, $privatekey['key'], 'RS256', $privatekey['kid']);
$confurl = new moodle_url('/mod/lti/openid-configuration.php');
$confurl = new moodle_url('/ltix/openid-configuration.php');
$url = new moodle_url($starturl);
$url->param('openid_configuration', $confurl->out(false));
$url->param('registration_token', $regtoken);
Expand Down
2 changes: 1 addition & 1 deletion ltix/toolproxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$pageurl = new moodle_url('/ltix/toolproxies.php');
$PAGE->set_url($pageurl);

admin_externalpage_setup('ltitoolproxies');
admin_externalpage_setup('ltixtoolproxies');

$PAGE->set_title(get_string('toolregistration', 'core_ltix'));

Expand Down
2 changes: 1 addition & 1 deletion ltix/typessettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

$PAGE->set_title(get_string('toolsetup', 'core_ltix'));
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('ltitoolconfigure');
$PAGE->set_secondary_active_tab('ltixtoolconfigure');
$PAGE->navbar->add(get_string('manage_external_tools', 'core_ltix'), new moodle_url('/ltix/toolconfigure.php'));
$PAGE->navbar->add(get_string('toolsetup', 'core_ltix'), $PAGE->url);
$PAGE->requires->js_call_amd('core_ltix/coursecategory', 'init', [$type->lti_coursecategories]);
Expand Down

0 comments on commit aab016a

Please sign in to comment.