From 4d4cdcbbf1c68814d8fb5f632c652b648fb5115f Mon Sep 17 00:00:00 2001 From: Davo Date: Thu, 14 Apr 2022 10:08:35 -0500 Subject: [PATCH] MGMT-61 tidy up some comments --- src/LtiMessageLaunch.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/LtiMessageLaunch.php b/src/LtiMessageLaunch.php index a4fb67dc..cfcd9150 100644 --- a/src/LtiMessageLaunch.php +++ b/src/LtiMessageLaunch.php @@ -297,9 +297,7 @@ private function getPublicKey() // Find key used to sign the JWT (matches the KID in the header) foreach ($publicKeySet['keys'] as $key) { if ($key['kid'] == $this->jwt['header']['kid']) { - // If alg is omitted from the JWK, infer it from the JWT header alg. - // See https://datatracker.ietf.org/doc/html/rfc7517#section-4.4. - $key['alg'] = $this->inferKeyAlgorithm($key); + $key['alg'] = $this->getKeyAlgorithm($key); try { $keySet = JWK::parseKeySet([ @@ -319,8 +317,12 @@ private function getPublicKey() throw new LtiException(static::ERR_NO_PUBLIC_KEY); } - private function inferKeyAlgorithm(array $key): string - { + /** + * If alg is omitted from the JWK, infer it from the JWT header alg. + * See https://datatracker.ietf.org/doc/html/rfc7517#section-4.4. + */ + private function getKeyAlgorithm(array $key): string + { if (isset($key['alg'])) { return $key['alg']; } @@ -338,7 +340,7 @@ private function jwtAlgMatchesJwkKty($key): bool $jwtAlg = $this->jwt['header']['alg']; return isset(static::$ltiSupportedAlgs[$jwtAlg]) && - static::$ltiSupportedAlgs[$jwtAlg] == $key['kty']; + static::$ltiSupportedAlgs[$jwtAlg] === $key['kty']; } private function cacheLaunchData()