havenshen/larsign
Composer 安装命令:
composer require havenshen/larsign
包简介
Laravel signature certification with web API server.
README 文档
README
About
The larsign package authorized signature server.
Features
- Handles larsign requests
Installation
Laravel
Require the havenshen/larsign package in your composer.json and update your dependencies:
$ composer require havenshen/larsign
Add the HavenShen\Larsign\LarsignServiceProvider to your config/app.php providers array:
HavenShen\Larsign\LarsignServiceProvider::class,
Add the HavenShen\Larsign\LarsignFacade to your config/app.php aliases array:
'Larsign' => HavenShen\Larsign\LarsignFacade::class,
Lumen
Require the havenshen/larsign package in your composer.json and update your dependencies:
$ composer require havenshen/larsign
Register the package with lumen in bootstrap/app.php with the following:
$app->register(HavenShen\Larsign\LarsignServiceProvider::class);
Global usage
To allow Larsign for all your routes, add the HandleLarsign middleware in the $middleware property of app/Http/Kernel.php class:
protected $middleware = [ // ... \HavenShen\Larsign\HandleLarsign::class, ];
Group middleware
If you want to allow Larsign on a specific middleware group or route, add the HandleLarsign middleware to your group:
protected $middlewareGroups = [ 'web' => [ // ... ], 'api' => [ // ... \HavenShen\Larsign\HandleLarsign::class, ], ];
Application route middleware
If you want to allow Larsign on a specific application middleware or route, add the HandleLarsign middleware to your application route:
protected $routeMiddleware = [ // ... 'auth.larsign' => \HavenShen\Larsign\HandleLarsign::class, ];
Configuration
The defaults are set in config/larsign.php. Copy this file to your own config directory to modify the values. If you're using Laravel, you can publish the config using this command:
$ php artisan vendor:publish --provider="HavenShen\Larsign\LarsignServiceProvider"
If you're using Lumen, Copy the configuration larsign.php from vendor/havenshen/larsign/config/larsign.php to your config/ directory
return [ /* |-------------------------------------------------------------------------- | Larsign |-------------------------------------------------------------------------- | */ 'headerName' => env('LARSIGN_HEADER_NAME', 'Larsign'), 'accessKey' => env('LARSIGN_ACCESS_KEY', ''), 'secretKey' => env('LARSIGN_SECRET_KEY', ''), ];
Add api route in routes/api.php Copy this.
Route::middleware(['auth.larsign'])->group(function () { Route::get('/larsign', function () { return [ 'message' => 'done.' ]); });
or
Route::get('/larsign', function () { return [ 'message' => 'done.' ]; })->middleware('auth.larsign');
Client
Generate Larsign signatures
- Assume the following management credentials:
AccessKey = "test" SecretKey = "123456"
- Call interface address:
url = "https://larsign.dev/api/v1/test?page=1"
- The original string to be signed:
note: the time-stamping followed by a newline [currenttime + voucher valid seconds]
signingStr = "/api/v1/test?page=1\n1510986405"
- Base64 url safe encode:
signingStrBase64UrlSafeEncode = "L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1"
hmac_sha1carriesSecretKeyencryption then base64 url safe encode:
sign = "MLKnFIdI-0TOQ4mHn5TyCcmWACU="
- The final administrative credentials are:
note: stitching
headerNameSpaceAccessKey:sign:signingStrBase64UrlSafeEncode
larsignToken = "Larsign test:MLKnFIdI-0TOQ4mHn5TyCcmWACU=:L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1"
- Add http header:
note: header key in
config/larsign.php -> headerName
Larsign:Larsign test:MLKnFIdI-0TOQ4mHn5TyCcmWACU=:L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1
Client signature authorization failed
Http Response: 403
Testing
$ phpunit
License
The MIT License (MIT). Please see License File for more information.
havenshen/larsign 适用场景与选型建议
havenshen/larsign 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.17k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2017 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「authorization」 「api」 「middleware」 「signature」 「laravel」 「laravel-5-packages」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 havenshen/larsign 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 havenshen/larsign 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 havenshen/larsign 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
A PSR-7 compatible library for making CRUD API endpoints
Slim Framework 3 CSRF protection middleware utilities
Laravel JWT auth service package
统计信息
- 总下载量: 2.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-05