From 1bc7f99bf716254fa525668ee0933a02a24bc9da Mon Sep 17 00:00:00 2001 From: Stephen Vickers Date: Fri, 26 Apr 2019 05:03:26 +0100 Subject: [PATCH] MDL-62599 mod_lti: Merge lti_convert_to_jwt and lti_sign_jwt --- mod/lti/locallib.php | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index b1534348651..f92e4cbc2b3 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -3008,36 +3008,16 @@ function lti_sign_parameters($oldparms, $endpoint, $method, $oauthconsumerkey, $ } /** - * Signs the petition to launch the external tool using JWT + * Converts the message paramters to their equivalent JWT claim and signs the payload to launch the external tool using JWT * - * @param array $oldparms Parameters to be passed for signing + * @param array $parms Parameters to be passed for signing * @param string $endpoint url of the external tool * @param string $oauthconsumerkey * @param string $typeid ID of LTI tool type * @param string $nonce Nonce value to use * @return array|null */ -function lti_sign_jwt($oldparms, $endpoint, $oauthconsumerkey, $typeid = 0, $nonce = '') { - - $parms = $oldparms; - - $newparms = array(); - $newparms['id_token'] = lti_convert_to_jwt($parms, $endpoint, $oauthconsumerkey, $typeid, $nonce); - - return $newparms; -} - -/** - * Converts the message paramters to their equivalent JWT claim and signs the payload to launch the external tool using JWT - * - * @param array $parms Parameters to be passed for signing - * @param string $endpoint url of the external tool - * @param string $oauthconsumerkey - * @param int $typeid - * @param string $nonce - * @return string - */ -function lti_convert_to_jwt($parms, $endpoint, $oauthconsumerkey, $typeid, $nonce) { +function lti_sign_jwt($parms, $endpoint, $oauthconsumerkey, $typeid = 0, $nonce = '') { if (empty($typeid)) { $typeid = 0; @@ -3109,7 +3089,6 @@ function lti_convert_to_jwt($parms, $endpoint, $oauthconsumerkey, $typeid, $nonc $privatekey = get_config('mod_lti', 'privatekey'); $kid = get_config('mod_lti', 'kid'); $jwt = JWT::encode($payload, $privatekey, 'RS256', $kid); - return $jwt; }