Skip to content

Commit

Permalink
MGMT-61 tidy up some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dbhynds committed Apr 14, 2022
1 parent 784503d commit 4d4cdcb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/LtiMessageLaunch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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'];
}
Expand All @@ -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()
Expand Down

0 comments on commit 4d4cdcb

Please sign in to comment.