feat: 为本地 HTTP API 增加 Token 鉴权与安全加固

- 使用 Electron safeStorage 加密存储并自动初始化 API Token
- 为 health 以外的接口增加 Bearer Token 鉴权
- 限制 CORS 仅允许可信本地 Origin
- 增加鉴权、Token rotation、safeStorage 和手动验收测试
This commit is contained in:
Wxw-Gu
2026-08-07 17:48:05 +08:00
parent 0c21008ec3
commit a73af3b5ad
33 changed files with 1328 additions and 130 deletions
+7
View File
@@ -445,6 +445,10 @@ declare global {
port: number
error?: string
}>
apiTokenStatus: () => Promise<import('../shared/local-api-auth').ApiTokenStatus>
revealApiToken: () => Promise<import('../shared/local-api-auth').ApiTokenRevealResult>
copyApiToken: () => Promise<import('../shared/local-api-auth').ApiTokenActionResult>
rotateApiToken: () => Promise<import('../shared/local-api-auth').ApiTokenActionResult>
apiStart: (
host?: string,
port?: number
@@ -469,6 +473,9 @@ declare global {
revealReaderSkill: () => Promise<{ success: boolean; error?: string }>
openReaderSkillGithub: () => Promise<{ success: boolean; error?: string }>
testLocalApiRequest: (request: LocalApiTestRequest) => Promise<LocalApiTestResponse>
copyLocalApiCurl: (
request: LocalApiTestRequest
) => Promise<import('../shared/local-api-test').LocalApiCurlCopyResult>
copyText: (text: string) => Promise<{ success: boolean; error?: string }>
// ============================================================
// AI 图片理解基础设施(ImageInsightService)