定制 tokin/json-web-tokin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tokin/json-web-tokin

最新稳定版本:1.0

Composer 安装命令:

composer require tokin/json-web-tokin

包简介

A JSON Web Token Library

README 文档

README

Tokin some webs

Description:

This is small library that can be used to verify JSON Web Tokens. There are 2 classes that are used in this library JsonWebToken and Verifier, the JsonWebToken class allows to segment the pieces of the token out so they can be easily generated/derived.

To use the Verifier, all you will need is a JsonWebToken instance, as well as the key that was used to sign token (in a lot of cases this will be your Client Secret).

Examples

Verifying a JWT

use Tokin\JWT\JsonWebToken;
use Tokin\JWT\Verifier;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEyMzM0NjQ2NCIsImZpcnN0X25hbWUiOiJUZXN0IiwibGFzdF9uYW1lIjoiTWNUZXN0ZXJzb24iLCJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJleHBpcmVzIjoxMjMyMTQyfQ.7BHgbsBAyK0IRDKPtFOhHKFYta6_fdujngX64zMYrtg';
$key = 'abcdefghijklmno';

$verifier = new Verifier();
$jwt = new JsonWebToken($token);

return $verifier->verify($jwt, $key); // returns a boolean

Retrieving Header Info From JWT

use Tokin\JWT\JsonWebToken;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEyMzM0NjQ2NCIsImZpcnN0X25hbWUiOiJUZXN0IiwibGFzdF9uYW1lIjoiTWNUZXN0ZXJzb24iLCJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJleHBpcmVzIjoxMjMyMTQyfQ.7BHgbsBAyK0IRDKPtFOhHKFYta6_fdujngX64zMYrtg';

$jwt = new JsonWebToken($token);

$headers = $jwt->getHeader(true); // this will return the JSON for the header, false will return the Base 64 URL Encoded value

// {"typ": "JWT", "alg":"HS256"}

Retrieving the Payload Info From JWT

use Tokin\JWT\JsonWebToken;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEyMzM0NjQ2NCIsImZpcnN0X25hbWUiOiJUZXN0IiwibGFzdF9uYW1lIjoiTWNUZXN0ZXJzb24iLCJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJleHBpcmVzIjoxMjMyMTQyfQ.7BHgbsBAyK0IRDKPtFOhHKFYta6_fdujngX64zMYrtg';

$jwt = new JsonWebToken($token);

$payload = $jwt->getPayload(true); // this will return the JSON for the header, false will return the Base 64 URL Encoded value

Retrieving the Signature From JWT

use Tokin\JWT\JsonWebToken;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEyMzM0NjQ2NCIsImZpcnN0X25hbWUiOiJUZXN0IiwibGFzdF9uYW1lIjoiTWNUZXN0ZXJzb24iLCJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJleHBpcmVzIjoxMjMyMTQyfQ.7BHgbsBAyK0IRDKPtFOhHKFYta6_fdujngX64zMYrtg';

$jwt = new JsonWebToken($token);

$signature = $jwt->getSignature();

Retrieving the Original JWT

use Tokin\JWT\JsonWebToken;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEyMzM0NjQ2NCIsImZpcnN0X25hbWUiOiJUZXN0IiwibGFzdF9uYW1lIjoiTWNUZXN0ZXJzb24iLCJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJleHBpcmVzIjoxMjMyMTQyfQ.7BHgbsBAyK0IRDKPtFOhHKFYta6_fdujngX64zMYrtg';

$jwt = new JsonWebToken($token);

$token = $jwt->getOriginalToken();

统计信息

  • 总下载量: 2.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固