Files
kintone-license-server/README.md
hsueh chiahao 37e40997f0
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m13s
fix readme
2025-11-03 12:55:46 +08:00

97 lines
2.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.

# Kintone License Server
> 公网url: https://kintone.alicorns.co.jp
基于 Node.js 的 kintone license 服务端,用于验证 kintone plugin 的 license。
目前支持:
- [kintone-vue-template](https://git.alicorns.co.jp/kintone-plugins/kintone-vue-template)
## 功能
- 提供 `POST /api/license/check` 接口,根据请求 body 中的 `domain``pluginId``pluginKey` 参数:
1. 如果许可证不存在,创建试用许可证(时长基于 DB 配置,到期时间为最后一天的 23:59:59
2. 如果存在,加载现有许可证。
3. 使用对应的插件 RSA 私钥生成 JWT返回给客户端。
> 对于用户付费,目前需要新增 `customers` 记录,并且手动修改数据库的 `licenses.purchase_date`、`licenses.customer_fk`
## 运行步骤
### 本地开发
1. **安装依赖:**
```
npm install
```
2. **构建项目:**
```
npm run build
```
3. **初始化数据库:**
- 运行初始化脚本:`init-db.sql`
4. **启动服务器:**
```
npm run dev # 开发模式
npm start # 生产模式(需预先构建)
```
### Docker Compose 部署(推荐)
1. **启动所有服务:**
```
docker-compose up --build -d
```
这将启动:
- PostgreSQL 数据库(在 `db` 服务中)
- 许可证服务器应用(在 `app` 服务中,端口 3000
2. **检查服务状态:**
```
docker-compose ps
```
3. **查看日志:**
```
docker-compose logs -f
```
4. **停止服务:**
```
docker-compose down
```
5. **测试 API**
- 健康检查:`GET http://localhost:3000/health`
- 许可证检查:`POST http://localhost:3000/api/license/check`
请求 body 示例:
```json
{
"domain": "example.com",
"pluginId": "test-plugin",
"pluginKey": "default-plugin"
}
```
成功响应:
```json
{
"success": true,
"jwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```
## 数据库结构
- **plugins**插件信息id, plugin_id, plugin_name, private_key, deleted。多插件支持每个插件有唯一私钥。
- **customers**客户信息id, name, email, phone, comment
- **licenses**许可证记录id, domain, plugin_id, expired_time, purchase_date, plugin_fk, customer_fk, message
- 外键 `plugin_fk` 关联插件,`customer_fk` 关联客户。
许可逻辑:
- 请求 (domain, pluginId) 组合唯一标识许可证。
- 试用:`purchase_date = NULL``isPaid = false``expiredTime`
- 付费:`purchase_date` 被外部系统设置,`expiredTime = -1`。