feat: 重命名项目为 my-docs,更新依赖项并添加 Mermaid 支持,重构文档配置以提升可读性和功能性

This commit is contained in:
wood911010 committed 2025-11-21 00:33:56 +08:00
1 parent 4d2767dda2
commit c90b441973
9 files changed
+1876 -91

No files matched your search

+12
View File
@@ -1 +1,13 @@
# License Manager Docs
简洁的 VitePress 文档站点,记录 License Manager 的使用指南与 API 说明。
## 本地快速启动
1. 安装依赖(首次运行需要)
`npm install`
2. 启动文档服务器(默认端口 5173)
`npm run docs:dev`
3. 打开浏览器访问 `http://localhost:5173` 预览。
> 如需构建静态站点,可执行 `npm run docs:build`,产物位于 `docs/.vitepress/dist`。
-80
View File
@@ -1,80 +0,0 @@
export default {
title: 'License Manager',
description: 'License Manager Documentation',
base: '/', // 使用自定义域名时,base 应该设置为 '/'
// 忽略死链检查
ignoreDeadLinks: [
// 忽略所有 localhost 链接
/^https?:\/\/localhost/,
// 忽略演示环境链接
/^http:\/\/lm\.cedar-v\.com/
],
locales: {
root: {
label: '中文',
lang: 'zh-CN',
themeConfig: {
nav: [
{ text: '首页', link: '/' },
{ text: '指南', link: '/guide/' }
],
sidebar: {
'/guide/': [
{
text: '指南',
items: [
{ text: '介绍', link: '/guide/' },
{ text: '快速开始', link: '/guide/getting-started' },
{ text: '接口文档', link: '/guide/api' }
]
}
]
}
}
},
en: {
label: 'English',
lang: 'en-US',
themeConfig: {
nav: [
{ text: 'Home', link: '/en/' },
{ text: 'Guide', link: '/en/guide/' }
],
sidebar: {
'/en/guide/': [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/en/guide/' },
{ text: 'Getting Started', link: '/en/guide/getting-started' },
{ text: 'API Reference', link: '/en/guide/api' }
]
}
]
}
}
}
},
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' }
],
sidebar: {
'/guide/': [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/guide/' },
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: 'API 文档 | API Reference', link: '/guide/api' }
]
}
]
}
}
}
+92
View File
@@ -0,0 +1,92 @@
import { defineConfig } from 'vitepress'
import { withMermaid } from 'vitepress-plugin-mermaid'
export default withMermaid(
defineConfig({
title: 'License Manager',
description: 'License Manager Documentation',
base: '/', // 使用自定义域名时,base 应该设置为 '/'
// 忽略死链检查
ignoreDeadLinks: [
// 忽略所有 localhost 链接
/^https?:\/\/localhost/,
// 忽略演示环境链接
/^http:\/\/lm\.cedar-v\.com/
],
locales: {
root: {
label: '中文',
lang: 'zh-CN',
themeConfig: {
nav: [
{ text: '首页', link: '/' },
{ text: '指南', link: '/guide/' }
],
sidebar: {
'/guide/': [
{
text: '指南',
items: [
{ text: '介绍', link: '/guide/' },
{ text: '快速开始', link: '/guide/getting-started' },
{ text: '许可证结构与验证(客户端要点)', link: '/guide/license-token-structure' },
{ text: '接口文档', link: '/guide/api' }
]
}
]
}
}
},
en: {
label: 'English',
lang: 'en-US',
themeConfig: {
nav: [
{ text: 'Home', link: '/en/' },
{ text: 'Guide', link: '/en/guide/' }
],
sidebar: {
'/en/guide/': [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/en/guide/' },
{ text: 'Getting Started', link: '/en/guide/getting-started' },
{ text: 'License Structure & Validation', link: '/en/guide/license-token-structure' },
{ text: 'API Reference', link: '/en/guide/api' }
]
}
]
}
}
}
},
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' }
],
sidebar: {
'/guide/': [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/guide/' },
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: 'License Token Structure', link: '/guide/license-token-structure' },
{ text: 'API 文档 | API Reference', link: '/guide/api' }
]
}
]
}
},
markdown: {
mermaid: true
}
})
)
+114
View File
@@ -0,0 +1,114 @@
# License Structure & Validation (Client Essentials)
The system issues licenses as **Base64-encoded JSON strings**. During startup the client must decode the string and run through signature verification, hardware fingerprint checks, and expiry/status validation. This guide follows a “flow → structure → payload → example → checklist” order for quick reference.
## 1. Startup Flow Overview
Begin with the big picture: the following Mermaid diagram outlines each validation checkpoint after the client receives a license string, including all failure exits.
```mermaid
flowchart TD
%% Nodes
Start([Client boot]) --> GetToken[Fetch Base64 license string]
GetToken --> Decode[Base64 decode]
Decode --> ParseJSON{Parse JSON structure?}
ParseJSON -- No --> ErrFormat[Stop: invalid format]
ParseJSON -- Yes --> Extract[Extract core fields: <br/>data, signature, algorithm]
%% Signature stage
Extract --> VerifySig[[RSA signature verify]]
VerifySig -- Fail --> ErrTamper[Stop: license tampered]
VerifySig -- Pass --> ParseData[Deserialize data payload]
%% Business logic
ParseData --> CheckStatus{Check status & validity}
CheckStatus -- Locked / Expired --> ErrStatus[Stop: locked or expired]
CheckStatus -- Normal & valid --> CheckType{Detect deployment type}
%% Branches
CheckType -- standalone --> CheckHW{Compare hardware fingerprint}
CheckType -- cloud / hybrid --> CheckNet{Online/heartbeat validation}
%% Final results
CheckHW -- Mismatch --> ErrHW[Stop: fingerprint mismatch]
CheckNet -- Rejected --> ErrNet[Stop: server rejected]
CheckHW -- Match --> Success([All checks passed])
CheckNet -- Accepted --> Success
%% Styles
classDef error fill:#f9f2f4,stroke:#c00,stroke-width:2px,color:#c00;
classDef success fill:#e1fdf4,stroke:#009966,stroke-width:2px,color:#009966;
classDef process fill:#f9f9f9,stroke:#333,stroke-width:1px;
class ErrFormat,ErrTamper,ErrStatus,ErrHW,ErrNet error;
class Success success;
class Decode,VerifySig,ParseData,CheckHW,CheckNet process;
```
## 2. Top-Level License Structure
Once the Base64 string is decoded you will get a JSON object containing three core fields. The structure keeps the payload human-readable while protecting integrity through an asymmetrical signature.
### Field reference
| Field | Type | Description |
| :--- | :--- | :--- |
| `algorithm` | String | Algorithm used to generate the signature, for example `RSA-PSS-SHA256`. |
| `data` | String | **Primary payload** serialized as a JSON string. Contains all enforcement rules, time limits, and fingerprint bindings. |
| `signature` | String | Base64 signature generated from the `data` field. Clients must verify it with the embedded public key before trusting the payload. |
-----
## 3. `data` Payload Details
The `data` field carries every parameter that governs runtime behavior. After deserializing the string, reference the values below to decide how the software should run.
### Core parameters
| Parameter | Values / Type | Description & engineering tips |
| :--- | :--- | :--- |
| `status` | `normal`, `locked`, `expired` | Overall authorization state. **normal** allows execution, **locked** indicates an admin-enforced block, **expired** means the time window has passed. |
| `deployment_type` | `standalone`, `cloud`, `hybrid` | Determines the validation path: standalone = local fingerprint only; cloud = mandatory online heartbeat; hybrid = prefer online, allow short offline grace period. |
| `start_date` / `end_date` | ISO 8601 timestamp | Validity window for the license. Compare against system time during startup; treat any `end_date` in the past as expired. |
| `hardware_fingerprint` | String | Combination of hardware identifiers (MAC/CPU/HostID, etc.). Recalculate locally and compare; mismatch implies unauthorized copy. |
| `usage_limits` | Object | Usage quotas (API calls, seat counts, etc.). |
| `feature_config` | Object | Key-value feature switches controlling which modules (Basic vs Pro) the client may enable. |
| `license_key` | String | Unique identifier for the licensed device; use for logging and backend correlation. |
-----
## 4. Decoded Example
Here is a decoded license sample to highlight formatting and field expectations:
```json
{
"algorithm": "RSA-PSS-SHA256",
"data": "{\"activated_at\":\"2025-11-01T22:30:02...\",\"status\":\"normal\",\"deployment_type\":\"standalone\",\"hardware_fingerprint\":\"MAC:5e:a3...\",\"end_date\":\"3025-03-03T23:59:59+08:00\", ...}",
"signature": "MQDlxx/crzncJfw2Y00X5spzN1bPWKuU4IDxB48Mwy1WMhOoYUDCcrYjiMgNJHsXzUSD14MURqCBKBMgQAc7EOiUUcwfJ1mhSGvbFYnrSGFxjpbEHUg6dJlgSB4jSxwh4jtHSOb82SvPkHrNE0/p/HKN2Vr3Dj2qU0JB7hM2Jd0vb3Tk7WiFWd9as3vvAChhzoXqHo53vtY7ZyUb56VM/M4UMwJ4w4S7M3DZiPwAAobOn1MfOmOnchXzc+lkhC9c67xprmOi33ms775Dc0tNurv+rCLTQN8wgnt5dfhmdyMbsIk2c188IK/7uca2Pi3qaBKSIkVkSKN78pI2A6gMYIA=="
}
```
> **Note:** `data` must remain in its original string form when verifying the signature. Only deserialize after the RSA verification succeeds.
-----
## 5. Client Validation Checklist
Use this checklist to implement a hardened validation pipeline:
1. **Decode**: Base64-decode the license string.
2. **Verify signature**: With the built-in public key, run RSA verification against the original `data` string and the provided `signature`. Abort immediately if the signature fails.
3. **Parse payload**: Deserialize `data` into an object.
4. **Evaluate status & timeline**:
- Require `status === "normal"`.
- Confirm current time is between `start_date` and `end_date`.
5. **Match environment**:
- Branch based on `deployment_type`.
- Standalone: recompute hardware fingerprint and compare with `hardware_fingerprint`.
- Cloud/Hybrid: perform online heartbeat or fallback strategy.
> Consider implementing the checklist as a modular validation pipeline so additional strategies (SaaS tenant isolation, audit logging, etc.) can be plugged in later.
+1
View File
@@ -1,4 +1,5 @@
# 接口文档 # 接口文档
官方:[http://lm.cedar-v.com:18888/swagger/index.html](http://lm.cedar-v.com:18888/swagger/index.html) 官方:[http://lm.cedar-v.com:18888/swagger/index.html](http://lm.cedar-v.com:18888/swagger/index.html)
本地部署:[http://localhost:18888/swagger/index.html](http://localhost:18888/swagger/index.html) 本地部署:[http://localhost:18888/swagger/index.html](http://localhost:18888/swagger/index.html)
+116
View File
@@ -0,0 +1,116 @@
# 许可证结构与验证(客户端要点)
本系统生成的许可证是一个 **Base64 编码的 JSON 对象**。客户端在启动阶段需要解码该字符串,并据此完成授权校验、硬件绑定判定及密钥验签。下方内容按照「流程 → 数据结构 → 示例 → 验证步骤」的顺序组织,便于查阅。
## 1. 启动阶段流程概览
先从整体流程入手:以下 Mermaid 流程图展示了客户端拿到许可证字符串后的关键校验路径,帮助定位每一步需要完成的动作与可能的失败分支。
```mermaid
flowchart TD
%% 节点定义
Start([客户端启动]) --> GetToken[获取 Base64 许可证字符串]
GetToken --> Decode[Base64 解码]
Decode --> ParseJSON{JSON 结构解析?}
ParseJSON -- 失败 --> ErrFormat[❌ 停止: 格式错误]
ParseJSON -- 成功 --> Extract[提取核心字段: <br/>data, signature, algorithm]
%% 签名验证阶段
Extract --> VerifySig[[RSA 签名验证]]
VerifySig -- 签名不匹配 --> ErrTamper[❌ 停止: 许可证被篡改]
VerifySig -- 验证通过 --> ParseData[反序列化 data 字符串]
%% 业务逻辑检查阶段
ParseData --> CheckStatus{检查 Status & 有效期}
CheckStatus -- "Locked / Expired" --> ErrStatus[❌ 停止: 授权被锁或过期]
CheckStatus -- "Normal & 有效期内" --> CheckType{判断 Deployment Type}
%% 部署类型分支
CheckType -- "standalone (单机)" --> CheckHW{本地硬件指纹比对}
CheckType -- "cloud / hybrid" --> CheckNet{联网/心跳验证}
%% 最终结果
CheckHW -- 不匹配 --> ErrHW[❌ 停止: 设备指纹不符]
CheckNet -- 验证失败 --> ErrNet[❌ 停止: 服务端拒绝]
CheckHW -- 匹配 --> Success([✅ 校验通过: 允许运行软件])
CheckNet -- 验证成功 --> Success
%% 样式定义 (可选,用于美化)
classDef error fill:#f9f2f4,stroke:#c00,stroke-width:2px,color:#c00;
classDef success fill:#e1fdf4,stroke:#009966,stroke-width:2px,color:#009966;
classDef process fill:#f9f9f9,stroke:#333,stroke-width:1px;
class ErrFormat,ErrTamper,ErrStatus,ErrHW,ErrNet error;
class Success success;
class Decode,VerifySig,ParseData,CheckHW,CheckNet process;
```
## 2. 许可证顶层结构
当您对许可证字符串完成 Base64 解码后,将得到一个包含三个核心字段的 JSON 对象。该结构设计确保了数据的可视性(明文数据)与安全性(加密签名)。
### 顶级字段说明
| 字段名 (Field) | 类型 | 说明 |
| :--- | :--- | :--- |
| **`algorithm`** | String | 用于生成签名的加密算法(例如:`RSA-PSS-SHA256`)。 |
| **`data`** | String | **核心授权载体**。这是一个被序列化为字符串的 JSON 对象,包含了具体的授权规则、时间限制和硬件指纹。 |
| **`signature`** | String | 针对 `data` 字段生成的加密签名(Base64 格式)。客户端需使用公钥验证此签名,以确保授权信息未被篡改。 |
-----
## 3. `data` Payload 详解
`data` 字段是许可证的核心载荷。解析该 JSON 字符串后,客户端可获得决定软件行为的全部控制参数。
### 核心参数定义
| 参数名 | 枚举值/类型 | 描述与开发建议 |
| :--- | :--- | :--- |
| **`status`** | `normal` (正常)<br>`locked` (锁定)<br>`expired` (过期) | 当前授权的状态。<br>**开发建议**:<br>• **normal**: 允许软件正常运行。<br>• **locked**: 授权被管理员强制禁用或检测到违规,应立即阻止运行。<br>• **expired**: 授权已过有效期,应阻止运行或降级为受限模式。 |
| **`deployment_type`** | `standalone` (单机版)<br>`cloud` (云端版)<br>`hybrid` (混合版) | 部署模式,决定了验证逻辑:<br>• **standalone**: 仅进行本地硬件指纹比对。<br>• **cloud**: 需联网向授权服务器心跳验证。<br>• **hybrid**: 优先联网,断网时允许短时间本地离线验证。 |
| **`start_date`**<br>**`end_date`** | ISO 8601 时间戳 | 授权的生效与过期时间。<br>**开发建议**:在软件启动时比对当前系统时间。若 `end_date` 小于当前时间,将状态视为过期。 |
| **`hardware_fingerprint`** | String | 绑定的硬件特征组合(如 MAC, CPU, HostID)取决于客户端的实现。<br>**关键步骤**:客户端需重新计算本地硬件指纹,并与此字段比对。若不一致,说明许可证被非法复制。 |
| **`usage_limits`** | Object | 使用量限制(如 API 调用次数,用户数量限制等)。 |
| **`feature_config`** | Object | 功能特性开关(Key-Value)。<br>用于控制软件内特定模块(如 Pro版/基础版)的启用或禁用。 |
| **`license_key`** | String | 设备的唯一授权标识符。<br>用于日志记录或作为与后端通讯的凭证。 |
-----
## 4. 解码示例
以下示例展示了解码后的标准许可证对象,便于对字段含义与格式建立直观印象:
```json
{
"algorithm": "RSA-PSS-SHA256",
"data": "{\"activated_at\":\"2025-11-01T22:30:02...\",\"status\":\"normal\",\"deployment_type\":\"standalone\",\"hardware_fingerprint\":\"MAC:5e:a3...\",\"end_date\":\"3025-03-03T23:59:59+08:00\", ...}",
"signature": "MQDlxx/crzncJfw2Y00X5spzN1bPWKuU4IDxB48Mwy1WMhOoYUDCcrYjiMgNJHsXzUSD14MURqCBKBMgQAc7EOiUUcwfJ1mhSGvbFYnrSGFxjpbEHUg6dJlgSB4jSxwh4jtHSOb82SvPkHrNE0/p/HKN2Vr3Dj2qU0JB7hM2Jd0vb3Tk7WiFWd9as3vvAChhzoXqHo53vtY7ZyUb56VM/M4UMwJ4w4S7M3DZiPwAAobOn1MfOmOnchXzc+lkhC9c67xprmOi33ms775Dc0tNurv+rCLTQN8wgnt5dfhmdyMbsIk2c188IK/7uca2Pi3qaBKSIkVkSKN78pI2A6gMYIA=="
}
```
> **注意:** `data` 字段在传输过程中是**字符串格式**。验证签名时必须使用原始的 `data` 字符串,只有在读取配置时才将其反序列化为 JSON 对象。
-----
## 5. 客户端验证清单
为了保证软件的安全性和授权的有效性,建议客户端按照以下步骤执行校验:
1. **解码 (Decode):** 将许可证字符串进行 Base64 解码。
2. **验签 (Verify Signature):** 使用内置的**公钥 (Public Key)**,对 `data` 字符串和 `signature` 进行 RSA 校验。
* *若验签失败,说明许可证被篡改,应立即终止程序。*
3. **解析 (Parse):** 将 `data` 字符串反序列化为对象。
4. **状态检查 (Check Status):**
* 确认 `status` 等于 `"normal"`。
* 确认当前时间在 `start_date` 和 `end_date` 之间。
5. **环境指纹比对 (Fingerprint Match):**
* 根据 `deployment_type` 执行相应的硬件或网络校验。
* (单机版) 重新计算本地硬件信息并与 `data` 中的 `hardware_fingerprint` 进行比对。
> 可以将上述 5 步实现为模块化的校验管线,以便后续扩展(例如增加联网授权、租户隔离等策略)。
+6 -6
View File
@@ -4,7 +4,7 @@ layout: home
hero: hero:
name: License Manager name: License Manager
text: 软件授权管理平台 text: 软件授权管理平台
tagline: 为软件系统提供专业的授权码生成、分发、验证和管理服务 tagline: 一站式解决授权码生成、发放、验证与全生命周期管理
image: image:
src: /images/logo.png src: /images/logo.png
alt: License Manager alt: License Manager
@@ -22,15 +22,15 @@ hero:
features: features:
- icon: 🔧 - icon: 🔧
title: 客户管理 title: 客户管理
details: 完整的客户信息管理和状态控制,支持客户信息的增删改查、状态管理、授权关联等核心功能 details: 客户档案、联系人、授权关系统一维护,配合状态与风控策略
- icon: 🔐 - icon: 🔐
title: 授权生成 title: 授权生成
details: 支持在线/离线授权模式,基于硬件指纹绑定的授权机制确保安全性 details: 支持在线/离线授权、批量发放、硬件指纹绑定与密钥加密
- icon: 📊 - icon: 📊
title: 授权管理 title: 授权管理
details: 实时状态监控和授权生命周期管理,全面掌控授权状态 details: 生命周期可视化、到期提醒、锁定/解锁、日志审计一应俱全
- icon: 📦 - icon: 📦
title: 部署包生成 title: 部署包生成
@@ -38,11 +38,11 @@ features:
- icon: 🌐 - icon: 🌐
title: API服务 title: API服务
details: 提供验证、激活、心跳监控等完善的RESTful API接口 details: 验证、激活、心跳、租户隔离等 RESTful API,易于系统集成
- icon: ⚡ - icon: ⚡
title: 高性能 title: 高性能
details: Go原生协程支持10,000+并发,API响应时间<50ms,内存占用<100MB details: Go 原生协程支撑 10,000+ 并发,API 响应 <50ms,内存 <100MB
- icon: 🔒 - icon: 🔒
title: 安全可靠 title: 安全可靠
+1532 -4
View File
File diff suppressed because it is too large. Load diff
+3 -1
View File
@@ -7,6 +7,8 @@
"docs:preview": "vitepress preview docs" "docs:preview": "vitepress preview docs"
}, },
"devDependencies": { "devDependencies": {
"vitepress": "^1.0.0" "mermaid": "^11.12.1",
"vitepress": "^1.0.0",
"vitepress-plugin-mermaid": "^2.0.17"
} }
} }