Skip to content

Commit

Permalink
Merge pull request #157 from MrRoundRobin/token_validation
Browse files Browse the repository at this point in the history
Token Validation with modulus and exponent
  • Loading branch information
hajekj authored Jun 2, 2022
2 parents fd8158f + e4f597e commit 3ca385f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Provider/Azure.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TheNetworg\OAuth2\Client\Provider;

use Firebase\JWT\JWT;
use Firebase\JWT\JWK;
use League\OAuth2\Client\Grant\AbstractGrant;
use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
Expand Down Expand Up @@ -354,6 +355,22 @@ public function getJwtVerificationKeys()

$keys[$keyinfo['kid']] = $publicKey;
}
} else if (isset($keyinfo['n']) && isset($keyinfo['e'])) {
$pkey_object = JWK::parseKey($keyinfo);

if ($pkey_object === false) {
throw new \RuntimeException('An attempt to read a public key from a ' . $keyinfo['n'] . ' certificate failed.');
}

$pkey_array = openssl_pkey_get_details($pkey_object);

if ($pkey_array === false) {
throw new \RuntimeException('An attempt to get a public key as an array from a ' . $keyinfo['n'] . ' certificate failed.');
}

$publicKey = $pkey_array ['key'];

$keys[$keyinfo['kid']] = $publicKey;
}
}

Expand Down

0 comments on commit 3ca385f

Please sign in to comment.