Files
ai_site/docs/外公司部署-授权与登录控制.md
2026-07-31 10:31:17 +08:00

54 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 登录策略与外公司部署授权
## 删文件后旧包还能用吗?
分几层:
| 客户删了什么 | 能否拦住旧延期包 |
|--------------|------------------|
| 只删 `leases/*.json` | **能** — 消费记录在 `state/_consumed.json` |
| 只删 leases + 改/清 state 文件 | **能**(有库时)— Postgres `license_consumed` 双写,可恢复 |
| **leases + state + 数据库全删** | 本地拦不住 → 需配置 **`RedeemURL` 联网核销**,或你们**永不重签同一 id** |
纯离线、客户把机器数据全部清空,没有任何方案能 100% 防复用(等于新装机)。要硬保证:配核销服务,或只发一次性 id 且服务端登记。
---
## 推荐:延期软件 + 分层持久化
```text
./data/license/leases/ # 租约文件(可删)
./data/license/state/ # _consumed.json 已消费 id签名
Postgres license_consumed # 第二副本
RedeemURL可选 # 你们服务端核销 id
```
### yaml
```yaml
License:
Enabled: true
Customer: "A公司"
LeaseDir: "./data/license/leases"
StateDir: "./data/license/state"
ControlSecret: "换成强密钥"
RedeemURL: "https://license.你们的域名" # 建议生产打开
SeedNotAfter: "2027-07-30"
```
`RedeemURL` 时:导入包会 `POST {RedeemURL}/v1/license/redeem`,服务端若该 id 已核销则拒绝。删光客户机数据后旧包仍无效。
临时延期:**仅 1 次**、最多 30 天。同一本地 id 不可二次导入。
---
## API
`X-License-Secret``renew` / `extend` / `import`
```bash
curl -X POST http://客户机:8888/api/v1/license/import \
-H "X-License-Secret: 强密钥" -H "Content-Type: application/json" \
--data-binary @pack.json
```