From 48ec9b3bd2c8ae2efebffba69058a9fe281727dc Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Wed, 18 Oct 2023 11:14:45 +0800 Subject: [PATCH] MDL-79725 libraries: fix auth URL generation in lti1p3 library --- lib/lti1p3/readme_moodle.txt | 2 ++ lib/lti1p3/src/LtiOidcLogin.php | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/lti1p3/readme_moodle.txt b/lib/lti1p3/readme_moodle.txt index ddb6b0778b4..4468b2f759d 100644 --- a/lib/lti1p3/readme_moodle.txt +++ b/lib/lti1p3/readme_moodle.txt @@ -2,6 +2,8 @@ LTI 1.3 Tool Library import instructions This library is a patched for use in Moodle - it requires the following changes be applied on top of the packback upstream base: 1. Removal of phpseclib dependency (replaces a single call with openssl equivalent) +2. Apply the fix from https://github.com/packbackbooks/lti-1-3-php-library/pull/107. If this is already merged upstream, please +remove this line. To upgrade to a new version of this library: 1. Clone the latest version of the upstream library from github: diff --git a/lib/lti1p3/src/LtiOidcLogin.php b/lib/lti1p3/src/LtiOidcLogin.php index 7d12c7a51eb..dda447e18da 100644 --- a/lib/lti1p3/src/LtiOidcLogin.php +++ b/lib/lti1p3/src/LtiOidcLogin.php @@ -90,7 +90,12 @@ class LtiOidcLogin $auth_params['lti_message_hint'] = $request['lti_message_hint']; } - $auth_login_return_url = $registration->getAuthLoginUrl().'?'.http_build_query($auth_params, '', '&'); + if (parse_url($registration->getAuthLoginUrl(), PHP_URL_QUERY)) { + $separator = '&'; + } else { + $separator = '?'; + } + $auth_login_return_url = $registration->getAuthLoginUrl().$separator.http_build_query($auth_params, '', '&'); // Return auth redirect. return new Redirect($auth_login_return_url, http_build_query($request, '', '&'));