imemento/jwt
Composer 安装命令:
composer require imemento/jwt
包简介
Custom JWT logic
README 文档
README
A custom JWT Wrapper to be used in iMemento projects. It uses the RS256 algorithm and it is framework independent.
Install
composer require imemento/jwt
Usage
use iMemento\JWT\JWT;
Encoding
To encode a JWT just use the encode static method:
/** * $payload object/array * $privateKey mixed the key used to sign the token */ $token = JWT::encode($payload, $private_key);
Decoding
To decode a JWT we must follow the next steps.
-
Instantiate the class with the token we want to decode:
$jwt = new JWT($token);
-
Get the issuer before checking the signature (used to find the correct public key):
$issuer = $jwt->getIssuer();
-
Get the payload and check the signature at the same time:
$payload = $jwt->decode($public_key);
Additional Classes
Guard.php - Decrypts the token and is used to extract the permissions from it.
Issuer.php - Represents the current application.
Payload.php - Is used to create a standard payload for the JWT.
统计信息
- 总下载量: 2.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-07