feat: 后端接口请求/响应体加解密(RSA + AES-GCM)
新增可一键开关的接口数据加密能力:前端经 RSA 公钥协商 AES-256 会话密钥,普通 JSON 接口的请求体与响应体统一以 AES-GCM 信封收发,避免明文 JSON 被抓包;SSE 流式接口、文件上传下载与 GET 查询参数按设计保持明文。 变更内容: - 后端新增常量开关 CryptoConstants.API_ENCRYPTION_ENABLED 与 util/crypto(RSA 密钥管理、AES 会话存储、加解密服务) - 后端新增 /api/crypto 公钥与握手接口,及会话拦截器、请求体解密与响应体加密 Advice,并在 WebConfig 注册、JWT 放行 /api/crypto - 前端新增 utils/apiCrypto.ts(node-forge)并改造 api/request.ts,实现自动握手、请求/响应加解密与会话失效自动重试 - 前端 package.json 增加 node-forge 与 @types/node-forge 依赖 说明: - RSA 密钥对持久化在 config/crypto-keys.json(已 gitignore),AES 会话密钥仅存内存并按 TTL 与上限清理 - 关闭常量开关后后端整体旁路,前端探测到 enabled=false 自动改走明文 - 不加密 SSE、multipart 上传、二进制下载/图片与 GET 查询参数
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"echarts": "^6.1.0",
|
||||
"highlight.js": "^11.12.0",
|
||||
"naive-ui": "^2.45.2",
|
||||
"node-forge": "^1.3.1",
|
||||
"pinia": "^4.0.3",
|
||||
"sql-formatter": "^15.9.0",
|
||||
"vue": "^3.5.41",
|
||||
@@ -25,6 +26,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.13.3",
|
||||
"@types/node-forge": "^1.3.11",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@vue/tsconfig": "^0.9.1",
|
||||
"typescript": "~6.0.2",
|
||||
|
||||
Reference in New Issue
Block a user