alancting / php-adfs-jwt
一个简单的PHP库,用于编码和解码Microsoft Active Directory Federation Services (ADFS) JSON Web Tokens (JWT),符合RFC 7519规范
1.0.2
2020-10-07 07:07 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.3
- phpunit/phpunit: >=4.8 <=9
This package is auto-updated.
Last update: 2024-09-16 15:32:58 UTC
README
PHP-ADFS-JWT
不再维护。
请移至 https://github.com/alancting/php-microsoft-jwt
一个简单的PHP库,用于编码和解码Microsoft Active Directory Federation Services (ADFS) JSON Web Tokens (JWT),符合RFC 7519规范。
从 firebase/php-jwt 分支而来
安装
使用composer管理您的依赖关系并下载PHP-ADFS-JWT
composer require alancting/php-adfs-jwt
示例
<?php 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';
测试
使用phpunit运行测试
$ composer run test