caiyun / license-client
Caiyun commercial license client for Laravel
v1.0.0
2026-08-04 13:53 UTC
Requires
- php: ^8.3
- ext-json: *
- ext-openssl: *
- illuminate/console: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/routing: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- nesbot/carbon: ^3.0
- symfony/http-foundation: ^7.2|^8.0
- symfony/http-kernel: ^7.2|^8.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- mockery/mockery: ^1.6
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^12.0
This package is not auto-updated.
Last update: 2026-08-05 12:27:37 UTC
README
Laravel 商业授权客户端,支持 RSA 签名许可证、授权时间、域名绑定、功能权益、远程撤销和离线宽限。
安装
在业务项目的 composer.json 配置私有仓库:
{
"repositories": [
{"type": "vcs", "url": "git@github.com:763606865/caiyun-license-client.git"}
]
}
composer require caiyun/license-client:^1.0 php artisan vendor:publish --tag=caiyun-license-config
Laravel 会通过 Composer 自动发现 LicenseServiceProvider,自动注册 licensed、feature 中间件和 license:status 命令。默认将基础授权中间件加入 web 和 api 组。
配置
LICENSE_ENABLED=true LICENSE_GLOBAL_MIDDLEWARE=true LICENSE_TOKEN=<signed-license> LICENSE_PUBLIC_KEY_PATH=storage/app/license/public.pem LICENSE_VERIFY_DOMAIN=true LICENSE_REMOTE_ENABLED=true LICENSE_REMOTE_ENDPOINT=https://license.example.com/api/v1/leases LICENSE_PROJECT=cms LICENSE_REMOTE_CHECK_INTERVAL=60 LICENSE_OFFLINE_GRACE_HOURS=72
公钥放入 storage/app/license/public.pem,私钥只能保留在授权服务器。也可用 LICENSE_PUBLIC_KEY 传入 Base64 编码的 PEM 公钥。
php artisan license:status --domain=example.com
功能授权
Route::middleware('feature:payment')->group(function (): void { Route::post('/orders/{order}/pay', PayController::class); });
模块内部也应进行权益检查,避免只删除路由中间件即可绕过:
use Caiyun\License\LicenseManager; app(LicenseManager::class)->authorize('payment', request()->getHost());
新功能在发布包前加入 config/license.php 的 features。
远程租约协议
客户端向 LICENSE_REMOTE_ENDPOINT 发送:
{
"license": "<signed-license>",
"license_id": "LIC-2026-0001",
"instance_id": "stable UUID",
"domain": "example.com",
"project": "cms",
"app_version": null
}
授权服务器返回 {"lease":"<signed-lease>"}。租约 Payload 必须包含:
{
"license_id": "LIC-2026-0001",
"instance_id": "stable UUID",
"domain": "example.com",
"issued_at": "2026-08-04T12:00:00+08:00",
"expires_at": "2026-08-07T12:00:00+08:00",
"features": ["payment", "mobile", "ai"]
}
租约使用同一 RSA 私钥签名,有效时间不得超过 LICENSE_OFFLINE_GRACE_HOURS。撤销返回 HTTP 403:
{"reason":"revoked","message":"授权已撤销"}
开发
composer install composer check
PHP 要求 >= 8.3,支持 Laravel 12 和 Laravel 13。
License
Proprietary. 未经授权不得复制、修改、再分发或绕过许可验证。