From e805e6a3296b676c0df9402a0a293e568b9fd859 Mon Sep 17 00:00:00 2001 From: Charles Severance Date: Sun, 22 Nov 2026 01:29:16 -0500 Subject: [PATCH] Revert the inbound LTI registration so the tree matches 8c1fef057. Co-authored-by: Cursor --- .coderabbit.yaml | 1 + .cursor/rules/coderabbit-fixes-stay-local.mdc | 12 - config-dist.php | 4 - lib/src/Controllers/Admin/Key.php | 24 - lib/src/Controllers/Instructor.php | 3 - lib/src/Controllers/Settings.php | 3 - .../templates/Admin/key/blackboard-detail.php | 7 +- .../templates/Admin/key/canvas-detail.php | 12 +- .../templates/Admin/key/client-id-check.php | 2 +- .../Controllers/templates/Admin/key/index.php | 22 +- .../templates/Admin/key/key-add.php | 38 +- .../templates/Admin/key/key-detail.php | 225 +------- .../templates/Admin/key/key-settings.php | 2 - .../templates/Admin/key/registration-add.php | 46 -- .../Admin/key/registration-detail.php | 130 ----- .../Admin/key/registration-fields.php | 37 -- .../Admin/key/registration-from-key.php | 14 - .../templates/Admin/key/registrations.php | 55 -- .../templates/Admin/key/requests.php | 2 +- lib/src/Core/LTIX.php | 232 +------- lib/src/Services/Admin/AdminService.php | 529 +----------------- lib/src/Services/Lti/database.php | 135 +---- lib/src/Services/Plus/GradeSync.php | 38 +- lib/src/Services/Plus/RosterSync.php | 19 +- .../Services/Settings/DynamicRegistration.php | 5 - lib/src/UI/CrudForm.php | 21 +- lib/tests/Core/InboundRegistrationTest.php | 425 -------------- .../Admin/AdminServiceKeyTypeTest.php | 12 - lti/oidc_login.php | 19 +- qa/tests/AdminTest.php | 135 +---- qa/tests/CourseToolLoopbackTest.php | 10 +- qa/tests/Support/TsugiPantherTestCase.php | 9 - 32 files changed, 108 insertions(+), 2120 deletions(-) delete mode 100644 .cursor/rules/coderabbit-fixes-stay-local.mdc delete mode 100644 lib/src/Controllers/templates/Admin/key/registration-add.php delete mode 100644 lib/src/Controllers/templates/Admin/key/registration-detail.php delete mode 100644 lib/src/Controllers/templates/Admin/key/registration-fields.php delete mode 100644 lib/src/Controllers/templates/Admin/key/registration-from-key.php delete mode 100644 lib/src/Controllers/templates/Admin/key/registrations.php delete mode 100644 lib/tests/Core/InboundRegistrationTest.php diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 46ccd26870..afc8b2182f 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -91,6 +91,7 @@ reviews: tools: phpstan: enabled: true + config_file: "phpstan.neon" phpcs: enabled: false phpmd: diff --git a/.cursor/rules/coderabbit-fixes-stay-local.mdc b/.cursor/rules/coderabbit-fixes-stay-local.mdc deleted file mode 100644 index e80257f4e6..0000000000 --- a/.cursor/rules/coderabbit-fixes-stay-local.mdc +++ /dev/null @@ -1,12 +0,0 @@ ---- -description: Do not push CodeRabbit fixes until the user has seen the diff -alwaysApply: true ---- - -# CodeRabbit fixes stay local - -When the work is fixing CodeRabbit comments, do not push the branch. - -Make the changes and stop. Leave them unpushed so the user can read the diff. A CodeRabbit review, a red check, or "fix the comments" is not permission to push, force-push, or open a pull request. - -Push only after the user explicitly says to push in that conversation, once they have seen what changed. diff --git a/config-dist.php b/config-dist.php index 1d341341db..fddd1383b6 100644 --- a/config-dist.php +++ b/config-dist.php @@ -174,10 +174,6 @@ function __the_end(){ // $CFG->home_path = 'https://example.com/'; // Legacy: $CFG->setExtension('home_path', $CFG->apphome); -// Temporary log when a launch or Plus token takes LTI config from lti_registration -// instead of lti_key. On unless set false. Remove by February 2027. -// $CFG->setExtension('log_registration_keys', false); - // Temporary ReqScope dump at /reqscope and tool/reqscope. Remove around December 2026. // /admin lists this with the QA settings when it is on. // $CFG->setExtension('reqscope_debug', true); diff --git a/lib/src/Controllers/Admin/Key.php b/lib/src/Controllers/Admin/Key.php index f867a2c5c4..12a6a08f4c 100644 --- a/lib/src/Controllers/Admin/Key.php +++ b/lib/src/Controllers/Admin/Key.php @@ -18,10 +18,6 @@ public static function routes(Application $app) { self::map($app, self::class, 'clientCheck', self::paths('key/client-id-check')); self::map($app, self::class, 'add', self::paths('key/key-add')); self::map($app, self::class, 'detail', self::paths('key/key-detail')); - self::map($app, self::class, 'registrations', self::paths('key/registrations')); - self::map($app, self::class, 'registrationAdd', self::paths('key/registration-add')); - self::map($app, self::class, 'registrationDetail', self::paths('key/registration-detail')); - self::map($app, self::class, 'registrationFromKey', self::paths('key/registration-from-key')); self::map($app, self::class, 'settings', self::paths('key/key-settings')); self::map($app, self::class, 'requests', self::paths('key/requests')); self::map($app, self::class, 'request', self::paths('key/request-detail')); @@ -50,26 +46,6 @@ public function detail() { $this->view('key/key-detail.php'); } - public function registrations() { - if ( $r = $this->gate('keys.view') ) return $r; - $this->view('key/registrations.php'); - } - - public function registrationAdd() { - if ( $r = $this->gate('keys.add') ) return $r; - $this->view('key/registration-add.php'); - } - - public function registrationDetail() { - if ( $r = $this->gate('keys.detail') ) return $r; - $this->view('key/registration-detail.php'); - } - - public function registrationFromKey() { - if ( $r = $this->gate('keys.add') ) return $r; - $this->view('key/registration-from-key.php'); - } - public function settings() { if ( $r = $this->gate('keys.settings') ) return $r; $this->view('key/key-settings.php'); diff --git a/lib/src/Controllers/Instructor.php b/lib/src/Controllers/Instructor.php index 7cf791cd9f..2dbd0b7b6d 100644 --- a/lib/src/Controllers/Instructor.php +++ b/lib/src/Controllers/Instructor.php @@ -1211,9 +1211,6 @@ public function keyDetail(Request $request) $query_fields, $allow_edit, $allow_delete); if ( $row === CrudForm::CRUD_FAIL || $row === CrudForm::CRUD_SUCCESS ) { - if ( $row === CrudForm::CRUD_SUCCESS && isset($_POST['doUpdate']) ) { - LTIX::clearKeysetCache(U::get($_REQUEST, 'key_id')); - } return new RedirectResponse($from_location); } if ( ! is_array($row) ) { diff --git a/lib/src/Controllers/Settings.php b/lib/src/Controllers/Settings.php index 4e402d53b1..8fc9dbcb53 100644 --- a/lib/src/Controllers/Settings.php +++ b/lib/src/Controllers/Settings.php @@ -1348,9 +1348,6 @@ public function keyDetail(Request $request) $query_fields, $allow_edit, $allow_delete); if ( $row === CrudForm::CRUD_FAIL || $row === CrudForm::CRUD_SUCCESS ) { - if ( $row === CrudForm::CRUD_SUCCESS && isset($_POST['doUpdate']) ) { - LTIX::clearKeysetCache(U::get($_REQUEST, 'key_id')); - } return new RedirectResponse($from_location); } if ( ! is_array($row) ) { diff --git a/lib/src/Controllers/templates/Admin/key/blackboard-detail.php b/lib/src/Controllers/templates/Admin/key/blackboard-detail.php index 0bcbe65644..622f4917e0 100644 --- a/lib/src/Controllers/templates/Admin/key/blackboard-detail.php +++ b/lib/src/Controllers/templates/Admin/key/blackboard-detail.php @@ -1,9 +1,10 @@

LTI 1.3

-Blackboard uses one issuer for every school, but +Blackboard uses a single issuer for all tenants, but since the Blackboard developer portal assigns a Well-Known/KeySet URL that is unique -to each Client ID, skip a reusable issuer in Tsugi and create a key for each client id. -Leave the LTI 1.3 registration unset and set all the issuer values on that key. +to each Client ID, it is best to skip creating a reusable Issuer in Tsugi, and instead create a Key for each Tenant, +select "No Global Issuer Selected" and set all the issuer values here +to create a Tenant key. The Deployment ID is provided when you place Tsugi into a Blackboard instance using the Client ID. For Blackboard, the following are the typical values for the Tsugi items: diff --git a/lib/src/Controllers/templates/Admin/key/canvas-detail.php b/lib/src/Controllers/templates/Admin/key/canvas-detail.php index 06924c2149..e12ccda612 100644 --- a/lib/src/Controllers/templates/Admin/key/canvas-detail.php +++ b/lib/src/Controllers/templates/Admin/key/canvas-detail.php @@ -1,10 +1,10 @@

Canvas LTI 1.3

-To use LTI 1.3 in Canvas, first create a Tsugi key using a temporary +To use LTI 1.3 in Canvas, first create a Tsugi Tenant using a temporary Client ID such as temporary-42-oertufgh. Make sure it is random enough to be unique across issuers as Tsugi prohibits duplicate (issuer, client_id) records system wide. -Save the key in Tsugi and use the +Save the Tenant in Tsugi and use the LTI values like JWKs URL shown by Tsugi to create a Developer Key in Canvas.

@@ -12,8 +12,8 @@

When the Developer Key is created, Canvas will assign a real Client ID (for example -38288000000000436). Edit the Tsugi key and replace the -temporary Client ID with the value assigned by Canvas and save the key. +38288000000000436). Edit the Tsugi Tenant and replace the +temporary Client ID with the value assigned by Canvas and save the Tenant.

@@ -26,7 +26,7 @@

The Deployment ID is optional in Tsugi and may be left blank to accept launches from any Canvas deployment using that issuer/client pair. -If you enter a Deployment ID on the key, launches will be restricted +If you enter a Deployment ID on the Tenant, launches will be restricted to that specific Canvas deployment (i.e. it might just be one course).

To use LTI 1.1 in Canvas, create your key with a title, key, and secret and come back here to view the XML-based Canvas auto-installation URL. Auto-installation of LTI 1.1 tools -in Canvas is on a per-key basis. +in Canvas is on a per-Tenant basis.

diff --git a/lib/src/Controllers/templates/Admin/key/client-id-check.php b/lib/src/Controllers/templates/Admin/key/client-id-check.php index b63ce07c4c..eed0c204bd 100644 --- a/lib/src/Controllers/templates/Admin/key/client-id-check.php +++ b/lib/src/Controllers/templates/Admin/key/client-id-check.php @@ -41,7 +41,7 @@ echo \Tsugi\Services\Admin\AdminService::issuerClientDuplicateNotice(); ?>

- Keys + Tenant Keys Client Id Check Admin

diff --git a/lib/src/Controllers/templates/Admin/key/index.php b/lib/src/Controllers/templates/Admin/key/index.php index 82e64a792a..77ea72a933 100644 --- a/lib/src/Controllers/templates/Admin/key/index.php +++ b/lib/src/Controllers/templates/Admin/key/index.php @@ -16,15 +16,12 @@ $rows = $PDOX->queryDie($patch_sql); $query_parms = array(); -$searchfields = array("K.key_id", "key_title", "key_key", "deploy_key", "K.login_at", "K.updated_at", "K.user_id", "K.lms_client", "R.issuer", "R.client_id"); +$searchfields = array("K.key_id", "key_title", "key_key", "deploy_key", "K.login_at", "K.updated_at", "K.user_id", "K.lms_client"); $sql = "SELECT K.key_id AS key_id, key_title, key_key, secret, lms_issuer, K.lms_client AS lms_client, lms_oidc_auth, lms_keyset_url, lms_token_url, deploy_key, K.login_at AS login_at, K.updated_at as updated_at, - K.user_id AS user_id, K.lti_registration_id AS lti_registration_id, - R.issuer AS registration_issuer, R.client_id AS registration_client + K.user_id AS user_id FROM {$CFG->dbprefix}lti_key AS K - LEFT JOIN {$CFG->dbprefix}lti_registration AS R - ON R.lti_registration_id = K.lti_registration_id "; $newsql = Table::pagedQuery($sql, $query_parms, $searchfields); @@ -37,13 +34,8 @@ $newrow['key'] = $row['key_key']; if ( !empty($row['key_title']) ) $newrow['key'] = $row['key_title']; $newrow['key_type'] = \Tsugi\Services\Admin\AdminService::keyTypeLabel($row); - $newrow['_html_key_type'] = \Tsugi\Services\Admin\AdminService::keyTypeHtml($row); $issuer_key = $row['lms_issuer']; $client_id = $row['lms_client']; - if ( empty($issuer_key) && empty($client_id) && ! empty($row['registration_issuer']) ) { - $issuer_key = $row['registration_issuer']; - $client_id = $row['registration_client']; - } $issuer_display = ''; if ( !empty($issuer_key) || !empty($client_id) ) { if ( !empty($issuer_key) ) { @@ -72,10 +64,9 @@ $OUTPUT->flashMessages(); echo \Tsugi\Services\Admin\AdminService::clientIdCheckNotices(); ?> -

Keys / Deployments

+

LTI Tenants (Keys)

- Registrations - Keys + Tenant Keys providekeys ) { ?> Key Requests @@ -84,12 +75,11 @@

-You have no keys for this system. +You have no Tenant keys for this system.

"registration-add", - "Insert Key" => "key-add" + "Insert Tenant" => "key-add" ); Table::pagedTable($newrows, $searchfields, false, "key-detail", false, $extra_buttons); // echo("
\n");print_r($newrows);echo("
\n"); diff --git a/lib/src/Controllers/templates/Admin/key/key-add.php b/lib/src/Controllers/templates/Admin/key/key-add.php index 9332426f7c..2453f21d6a 100644 --- a/lib/src/Controllers/templates/Admin/key/key-add.php +++ b/lib/src/Controllers/templates/Admin/key/key-add.php @@ -17,12 +17,13 @@ $from_location = LTIX::curPageUrlFolder(); $tablename = "{$CFG->dbprefix}lti_key"; -$fields = array('key_title', 'plus', 'user_id', 'key_key', 'key_sha256', 'secret', +$fields = array('key_title', 'plus', 'key_key', 'key_sha256', 'secret', 'lms_issuer', 'lms_issuer_sha256', 'lms_client', 'deploy_key', 'deploy_sha256', 'lms_oidc_auth', 'lms_keyset_url', 'lms_token_url', 'lms_token_audience', 'created_at', 'updated_at', + 'user_id', ); $titles = array( @@ -64,10 +65,6 @@ } if ( isset($_POST['doSave']) && count($_POST) > 0 ) { - if ( ! \Tsugi\Services\Admin\AdminService::applyPostedRegistrationToKey() ) { - header("Location: key-add"); - return; - } $lms_issuer = U::get($_POST, 'lms_issuer'); $lms_client = U::get($_POST, 'lms_client'); $identity_message = LTI::ascii255First(array( @@ -102,9 +99,7 @@ if ( isset($_POST['doSave']) ) { $binaryHex['guid'] = \Tsugi\Core\Guid::uuid7(); } -$save_fields = $fields; -$save_fields[] = 'lti_registration_id'; -$retval = CrudForm::handleInsert($tablename, $save_fields, $binaryHex); +$retval = CrudForm::handleInsert($tablename, $fields, $binaryHex); if ( $retval == CrudForm::CRUD_SUCCESS || $retval == CrudForm::CRUD_FAIL ) { header("Location: $from_location"); return; @@ -116,7 +111,7 @@ $OUTPUT->flashMessages(); ?> -

Adding Key +

Adding Tsugi Tenant/Key Exit