Files
rent/apps/server/src/entities/system-secret.entity.ts
T
xiaoquan 3b75e26599 feat: 系统密钥管理模块(数据库加密存储)
后端:
- 新增 system_secrets 表(AES-256-GCM 加密存储)
- 新增 crypto.util.ts 加解密工具
- 新增 SecretService 共享服务(CRUD + 加解密)
- 新增 AdminSecretController 管理端 API(仅超管)
- API 返回值脱敏(*** + 最后4位)

前端(平台后台):
- 新增系统密钥管理页面(按分组展示、CRUD 操作)
- 侧边栏新增「系统密钥」菜单

管理员可在后台网页管理所有密钥,不再需要 SSH 到服务器改配置

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 12:03:37 +08:00

35 lines
964 B
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
} from 'typeorm';
@Entity('system_secrets')
export class SystemSecret {
@PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
id: number;
@Column({ name: 'secret_key', length: 100, comment: '密钥名' })
secretKey: string;
@Column({ name: 'secret_value', type: 'text', comment: '加密后的值' })
secretValue: string;
@Column({ name: 'description', length: 200, nullable: true, comment: '说明' })
description: string;
@Column({ name: 'group_name', length: 50, default: 'default', comment: '分组' })
groupName: string;
@Column({ type: 'enum', enum: ['all', 'prod', 'test'], default: 'all', comment: '适用环境' })
env: 'all' | 'prod' | 'test';
@CreateDateColumn({ name: 'created_at', comment: '创建时间' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
updatedAt: Date;
}