whcoding / signature
API 签名
v1.0.0
2021-06-25 07:10 UTC
Requires
- php: ^7.3|^8.0
- laravel/framework: ^8.40
Requires (Dev)
- php: ^7.3|^8.0
- laravel/framework: ^8.40
This package is auto-updated.
Last update: 2024-09-05 16:28:40 UTC
README
laravel-signature
laravel-signature 是一个接口签名验证包,其中包括了对token生成、token过期时间、请求的有效期、sign生成
运行环境
- php >=7.3
- composer
- laravel >= 8.40
- 在 .env 中开启 debug 会返回正确的 sign,生产环境请记得关闭。
使用方法
composer require whcoding/signature
设置 auth.php
'defaults' => [
'guard' => 'api', // laravel 默认 session 更改为 api
'passwords' => 'users',
],
'guards' => [
.....
'api' => [
'driver' => 'signature', // 更改为 signature
'provider' => 'users',
'hash' => false,
],
],
配置文件
php artisan vendor:publish --provider="Signature\SignatureProvider"
执行迁移
php artisan migrate
前端请求需要携带的参数
{
"ts" : "时间戳(请求时间)",
"user_id" : "用户id",
"sign": "前端根据该包的sign算法生成的(参考 Signature.php 中的 makeSign 方法)"
}