caiyun/license-client

Caiyun commercial license client for Laravel

Maintainers

Package info

github.com/763606865/caiyun-license-client

pkg:composer/caiyun/license-client

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-08-04 13:53 UTC

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,自动注册 licensedfeature 中间件和 license:status 命令。默认将基础授权中间件加入 webapi 组。

配置

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.phpfeatures

远程租约协议

客户端向 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. 未经授权不得复制、修改、再分发或绕过许可验证。