Skip to content

Commit

Permalink
MDL-79725 libraries: fix auth URL generation in lti1p3 library
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Oct 20, 2023
1 parent d188d58 commit 837b682
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/lti1p3/readme_moodle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This library is a patched for use in Moodle - it requires the following changes
2. Removal of Guzzle dependency (replaced with generic http client interfaces which are more compatible with Moodle's curl.)
3. Small fix to http_build_query() usages, to make sure the arg separator is explicitly set to '&', so as not to trip up
on Moodle's definition of PHP's arg_separator.output which is set to '&' in lib/setup.php.
4. 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:
Expand Down
7 changes: 6 additions & 1 deletion lib/lti1p3/src/LtiOidcLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ public function doOidcLoginRedirect($launch_url, array $request = null)
$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, '', '&'));
Expand Down

0 comments on commit 837b682

Please sign in to comment.