Created
March 10, 2021 19:47
-
-
Save drupol/0123d027b5151550b719ac44f50cec86 to your computer and use it in GitHub Desktop.
Trying to decode a token with a ES256 signature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Facile\JoseVerifier\JWK\JwksProviderBuilder; | |
use Facile\JoseVerifier\JWTVerifier; | |
use Symfony\Component\HttpClient\HttpClient; | |
use Symfony\Component\HttpClient\Psr18Client; | |
include __DIR__ . '/vendor/autoload.php'; | |
$token = 'eyJhbGciOiAiRVMyNTYiLCAiY3R5IjoiSldUIn0.eyJhdCI6IkFULTU2MTIwODgtbGhXbzYwQUJkd25raVpnTGZCaFA5ZDFpTXJCVWl2NjFMOGxVV3pHN3ptUWFLSG81Z0FqNXRNT3B6cnAzOG15ZVk4U290enNVdG1jbDV4OUpGelVXVVB0LXJhOGduQ0YxbFdhbGw3WVQyR0VCQUstcVZMUlJ5RzMyRjJaS2VxY21DYXJRazI5Qk00VnRJdzBtU2RXUldjelhPZnhrY3FLeTRUcU1oalJHcGJ0UEJma3p6UXVSblEwWmt6dENlNGdhaHlPallTIiwidHMiOjE2MTUzODc3MTk2OTN9.QZE4mWYNvf9CAAF8sX5TylmUL3X88qqHHavlHOy4J-_XjUgtLV6jwTC7H-PYc__sYznTbo5LpsOoUZHYgdZKlw'; | |
$euLoginJwksProvider = (new JwksProviderBuilder()) | |
->setHttpClient(new Psr18Client(HttpClient::create())) | |
->setJwksUri('https://replace-here-with-the-proper-host/oauth2/keys') | |
->build(); | |
$result = (new JWTVerifier('https://foobar.com', 'client-id', null)) | |
->withJwksProvider($euLoginJwksProvider) | |
->withExpectedAlg('ES256') | |
->verify($token); | |
var_dump($result); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment