antarccub/jwt-auth
Composer 安装命令:
composer require antarccub/jwt-auth
包简介
JWT Authentication for Laravel projects
README 文档
README
JWT-Auth for Laravel
Installation
Package is available on Packagist,
you can install it using Composer.
composer require antarccub/jwt-auth
After that, you need to publish config file with the following command:
php artisan vendor:publish --tag:jwt-config
To start using the package you have to change your auth driver in the auth.php file:
'guards' => [
'web' => [ 'driver' => 'session', 'provider' => 'users', ],
'api' => [ 'driver' => 'jwt', // JWT Auth 'provider' => 'users', ], ],
Basic Usage
Now you can use Laravel Auth facade with JWT Authentication
Route::middleware('auth:api')->get('/user', function (Request $request) {
return response()->json(Auth::user());
});
Configuration
/*
* Here you can add all claims (iss, aud, jti, sub) you want to validate and theirs corresponding value * * Example: * 'iss' => 'http://example.com', * * 'jti' => '123123j2j3oj' * */
'claims' => [
// 'iss' => 'http://example.com',
],
/* * Here you can config the signature verification type * */
'signature' => 'public-key', // public-key | secret
'methods' => [ 'public-key' => [ 'type' => 'RSA', // RSA, ECDSA 'signer' => 'SHA256', // RSA256, RSA348, RSA512 'provider' => 'Antarccub\JwtAuth\Providers\PublicKeyFileProvider',
'content' => storage_path('public.key'), // Only for PublicKeyFileProvider 'url' => env('JWT_PKEY') // Only for PublicKeyUrlProvider ],
'secret' => [ 'signer' => 'SHA256', 'value' => 'example' ] ]
Contributing
This package is for my personal use, but feel free to change all you want!
References
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-17