承接 dusta/jwt-ready 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dusta/jwt-ready

最新稳定版本:v1.0.0

Composer 安装命令:

composer require dusta/jwt-ready

包简介

Module jwt

README 文档

README

Simple Firebase\JWT wrapper

PHP Standalone

use Dusta\JWTReady\JWTReady;

require_once __DIR__ . '/../vendor/autoload.php'; 
$JWTReady = new JWTReady(['key' => 'YOUR-SECRET-KEY']);

// Return string
$jwt = $JWTReady->generate(['key' => 'value']);
// return eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJrZXkiOm51bGwsImlhdCI6bnVsbC.....

// if empty check headers Bearer/s
$check = $JWTReady->checkJWT($jwt);
// return ['jwt' => 'eyJ0eXAiOiJKV1QiLCJhbG....', 'payload' => [...]]

$decoded = $JWTReady->decode($jwt);
// return ['key' => 'value']

Example SilmFramework

src/routers.php

use Slim\Http\Request;
use Slim\Http\Response;

$app->get('/auth/check', function (Request $request, Response $response, array $args) {

    try {

        /** @var JWTReady $JWTReady */
        $JWTReady = $this->get('JWTReady');
        $checkJWT = $JWTReady->checkJWT();

    } catch (AuthorizationHeaderException $e) {
        return $response->withJson(['code' => 401, 'message' => 'Invalid BearerToken']);
    }

    return $response->withJson(['code' => 200])->withHeader('Bearer', $checkJWT->get('jwt'));
});

src/dependencies.php

use Dusta\JWTReady\JWTReady;

$container = $app->getContainer();

// monolog
$container['JWTReady'] = function ($c) {
    $settings = $c->get('settings')['JWTReady'];

    $JWTReady = new JWTReady($settings);
    return $JWTReady;
};

src/settings.php

<?php
return [
    'settings' => [
        'displayErrorDetails' => true, // set to false in production
        'addContentLengthHeader' => false, // Allow the web server to send the content-length header

        'JWTReady' => [
            'key' => 'SecretKey',
            'iat' => null,
            'jti' => null,
            'iss' => null,
            'nbf' => null,
            'exp' => null,
            'data' => null
        ]
    ],
];

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固