定制 adrianoalves/jwt 二次开发

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

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

adrianoalves/jwt

Composer 安装命令:

composer require adrianoalves/jwt

包简介

Luis Cobucci JWT adapted to use in Laravel

README 文档

README

A JSON Web Token Library made to adapt the lcobucci/jwt for Laravel and Lumen.

It uses Asymmetric Algorithm using a private key for signature creation and a public key for verification. This means that it's fine to distribute your public key. However, the private key should remain secret.

Laravel Installation

Via composer

composer require adrianoalves/jwt

Install the package

php artisan jwt:install

Generate private and public keys

php artisan make:jwt-keys

Modify the jwt.php in your config file as necessary and add your app's Policies if necessary.

Change the route driver in your auth.php config file to jwt.

'guards' => [
    'jwt' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ],
],

Auth Guard Usage

Routing

Route::middleware('auth:jwt')->get('/user', function (Request $request) {
    return $request->user();
});

// if you set jwt as driver for your api guard
Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Login

// Generate a token for the user if the credentials are valid
$token = Auth::attempt($credentials);

User

// Getting the currently authenticated user
$user = Auth::user();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-19