1. Go to this page and download the library: Download alancting/php-adfs-jwt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alancting / php-adfs-jwt example snippets
use Alancting\Adfs\JWT\Adfs\AdfsConfiguration;
use Alancting\Adfs\JWT\Adfs\AdfsAccessTokenJWT;
use Alancting\Adfs\JWT\Adfs\AdfsIdTokenJWT;
$openid_configuration_url = 'https://[Your ADFS hostname]/adfs/.well-known/openid-configuration';
$client_id = 'your_client_id';
/**
* AdfsConfiguration will fetch the issuers, audiences and jwks for jwt validation
*/
$adfs_configs = new AdfsConfiguration($openid_configuration_url, $client_id);
$id_token_jwt = 'id.token.jwt';
$access_token_jwt = 'access.token.jwt';
/**
* If the jwt is invalid, exception will be thrown.
*/
$access_token = new AdfsAccessTokenJWT($adfs_configs, $access_token_jwt);
echo "\n";
// Getting the payload from access token
print_r($access_token->getPayload());
echo "\n";
$id_token = new AdfsIdTokenJWT($adfs_configs, $id_token_jwt);
echo "\n";
// Getting the unique_name(username) from id token
echo $id_token->getUsername();
echo "\n";
// Getting the payload from id token
print_r($id_token->getPayload());
echo "\n";
/**
* You might want to 'cache' the tokens for expire validation
* To check whether the access token and id token are expired, simply call
*/
echo ($access_token->isExpired()) ? 'Access token is expired' : 'Access token is valid';
echo ($id_token->isExpired()) ? 'Id token is expired' : 'Id token is valid';
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.