feat: implement frontend-backend encrypted communication via AES-256-GCM
参考 novavis-authority 的加解密方案,实现前后端通信的应用层加密: - 重写 src/lib/crypto.ts 使用 Web Crypto API(浏览器兼容),PBKDF2+AES-256-GCM - 新增 src/lib/crypto-server.ts 服务端加解密工具(Node.js crypto) - 新增 src/lib/api-crypto.ts API 路由中间件 withCrypto(),自动解密请求体/加密响应体 - 更新 src/lib/admin-api.ts 自动加密所有请求/解密响应 - 所有 11 个 admin API 路由文件已应用 withCrypto 包装器 - 更新 .env 文件,添加 NEXT_PUBLIC_ENCRYPTION_SECRET 和 ENCRYPTION_SECRET
This commit is contained in:
1 parent
c480772aec
commit
d5d04aa96d
24 files changed
+449
-120
No files matched your search
@@ -15,6 +15,7 @@ import {
|
||||
internalError,
|
||||
forbidden,
|
||||
} from '@/lib/api-response';
|
||||
import { withCrypto } from '@/lib/api-crypto';
|
||||
|
||||
function parseItem(item: { data: string; [key: string]: unknown }) {
|
||||
return { ...item, data: JSON.parse(item.data as string) };
|
||||
@@ -32,10 +33,10 @@ const ACTION_PERMISSION: Record<WorkflowAction, 'update' | 'publish'> = {
|
||||
archive: 'publish',
|
||||
};
|
||||
|
||||
export async function POST(
|
||||
export const POST = withCrypto(async (
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
) => {
|
||||
const { id } = await params;
|
||||
|
||||
try {
|
||||
@@ -90,4 +91,4 @@ export async function POST(
|
||||
console.error('Workflow error:', error);
|
||||
return internalError();
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user