feat(M4): 生命周期 + 审计 — 到期锁定/回收 cron、审计查询/CSV 导出/每日归档、settings 动态策略

This commit is contained in:
2026-08-30 10:17:22 +08:00
parent 1ea18490e0
commit c0e2ff975a
18 changed files with 1088 additions and 75 deletions
+10
View File
@@ -31,6 +31,7 @@ type Config struct {
Auth AuthConfig `toml:"auth"`
SMTP SMTPConfig `toml:"smtp"`
System SystemConfig `toml:"system"`
Audit AuditConfig `toml:"audit"`
}
type AppConfig struct {
@@ -90,6 +91,11 @@ type SystemConfig struct {
AuthorizedKeysDir string `toml:"authorized_keys_dir"` // authorized_keys 所在目录(测试可覆盖)
}
// AuditConfig 审计保留与归档配置。
type AuditConfig struct {
ArchiveDir string `toml:"archive_dir"` // 每日归档目录(空 = 不归档也不自动清理,防止丢审计)
}
// Default 返回带开发环境默认值的配置,作为 config.example.toml 与未配置项的兜底。
func Default() *Config {
return &Config{
@@ -114,6 +120,10 @@ func Default() *Config {
CaptchaTTL: 5 * time.Minute,
},
SMTP: SMTPConfig{Port: 587},
Audit: AuditConfig{
// 开发默认不归档(避免在任意目录落文件);生产显式配置 archive_dir 启用归档。
ArchiveDir: "",
},
System: SystemConfig{
// 开发默认 dry-run:未配置 config 直接跑 serve 时只打印计划,避免误操作系统账号。
// 生产必须显式 dry_run=false 且 sudo=true(见 deploy/sudoers.example)。