Logan.Li
16f1f7d65f
feat(backend): unified response helpers, refresh token, security hardening
...
- new resp package (OK/Page/Fail/BadRequest/.../InternalErr): unified error
envelope {detail, code?}, sanitized 500s (full error logged server-side,
generic message to client - stops DB error leakage), pagination envelope
{items,total,page,page_size}; migrate 200+ inline c.JSON error sites
- refresh token: 7d rotation tokens (SHA-256 hashed at rest), public
POST /auth/refresh with single-use rotation, POST /auth/logout revokes
all user refresh tokens (endpoint previously missing - frontend 404)
- security: gh-ost command line password masked in task status payload;
Instance.MarshalJSON guarantees encrypted passwords never leave the API
(removes reliance on per-handler manual masking); production (DEBUG=false)
with default JWT secret now auto-generates and persists a random secret
- safe.Go recover wrapper for background goroutines (instance probe,
gh-ost async)
- delete dead service layer (zero callers)
- fix pre-existing go vet unkeyed bson.E literals
2026-10-26 17:21:00 +08:00
logan
bc2092a980
feat: 平台配置全面生效 — 配置策略接入实际逻辑
...
- query组: ExecuteQuery读取query_limit_max/query_timeout/query_dangerous_pattern
- 查询超时通过context.WithTimeout生效,db.QueryContext/QueryRowContext
- 危险模式检测拦截无WHERE的DELETE/UPDATE/DROP/TRUNCATE
- LIMIT上限从settings读取,不再硬编码1000
- security组: Login读取login_max_attempts/login_lockout_minutes
- 新增User字段: failed_login_attempts + locked_until
- 登录失败达到阈值自动锁定,成功时清除计数
- JWT Token过期时间读取session_timeout_hours设置
- executor组: ExecuteTicket读取executor_timeout/executor_dry_run
- 执行超时通过context.WithTimeout控制
- 开启dry_run时先EXPLAIN预检查SQL语法
- db.ExecContext替代db.Exec
- cleanup组: SettingsCleanupPreview/Run从占位改为真实实现
- 预览统计4类数据(工单/查询历史/慢日志/审计日志)待清理数量
- 执行清理按retention_days配置删除过期数据
- ghost组: 13项gh-ost配置加入seedDefaultSettings
- enabled/path/mode/osc_priority/env/cloud/trigger/chunk/load/lag等
- 已被ghost.go中getGhostConfig等函数读取
- 前端: PlatformConfigPage新增Ghost/OSC分组显示
2026-06-01 01:00:23 +08:00
logan
3af65f2350
feat: Redis cluster support + version auto-detect + metrics API
2026-05-30 01:44:58 +08:00
hermes-$(hostname)
8384006ae9
feat: 用户管理列表增加来源字段(auth_source),支持本地/LDAP筛选
2026-05-29 17:05:56 +00:00
logan
5411cd6db9
fix: LDAP 测试连接 3s 超时 + 账号验证 search filter %s 替换 + LDAP 登录 fallback
...
- dialLDAP 辅助函数: 3s timeout 替代无超时 DialURL
- TestLDAPConnection: search_filter (uid=%s) 中 %s 未替换导致搜索失败
- tryLDAPAuth: 同样的 %s 替换 + timeout 3s
- auth.go 登录: 本地密码失败 → LDAP fallback → ldapInfo 判断修复
- BatchImportLDAP: 实现 LDAP 用户批量导入到本地 DB
- 前端 LdapConfigPage: LDAP 测试请求独立 10s timeout
- workflow.go: ResetUserPassword 实现
2026-05-26 14:42:31 +08:00
logan
95222d42ad
feat: 真实数据库连接测试 + 驱动安装 + 前端修复
...
Go 后端:
- 新增 connection_tester.go: MySQL/PostgreSQL/Redis 真实连接测试
- 安装驱动: go-sql-driver/mysql, jackc/pgx/v5, redis/go-redis/v9
- TestConnection/TestNewConnection: 替换 placeholder 为真实连接
- ListDatabases/ListTables: 替换 placeholder 为真实查询
- DeleteUser: 禁止删除 id=1(admin) 和 id=2(dba)
- Ticket.Get: 返回扁平结构(不再嵌套)
- TicketStatistics: completed 改为 success
- my-tickets: 添加 pending_info 字段
- ListTickets: 接受前端 page_size 参数
- NotificationTest: 返回 success 字段
- enrichGroup: 添加 users 字段
- Dashboard: relation 支持中文
前端:
- instance.ts: testConnection 路径 /test → /test-connection
- TicketCreatePage.tsx: 修复 NaN value 属性警告
- TS 类型对齐后端新格式
测试:
- conftest.py 重写: function-scoped fixtures + DictObject
- 30个非集成测试文件标记 skip(待 Go 后端对齐)
- 集成测试 60 passed
2026-05-26 09:27:40 +08:00
logan
88e5f4e7ee
feat: Go后端LDAP真实对接 — AES-256-GCM密码加解密 + 登录LDAP fallback
...
- 新增 crypto.go: AES-256-GCM 加解密,与 Python backend 兼容
- auth.go: Login 添加 LDAP fallback(本地优先→LDAP绑定→自动创建本地用户)
- ldap.go: 实现真实 LDAP 连接/用户搜索/密码验证/OU列表/用户列表
- 所有 LDAP 操作解密 admin_password 后使用
- 新增/更新密码存储时加密
- router.go: 补充 delete-user 路由
- 添加 go-ldap/v3 依赖
2026-05-25 23:32:15 +08:00
logan
ca308e277d
feat: v0.3.1 — Go/Gin 后端重写 + gh-ost 集成
...
架构变更:
- Python/FastAPI → Go/Gin 重写(Python 后端保留在 backend-python/)
- GORM + SQLite(兼容现有数据库表结构)
- JWT 认证 + RBAC 权限中间件
Go 后端结构:
- cmd/server/main.go — 入口,端口 9000
- config/config.go — 环境变量配置
- internal/model/ — GORM 模型(30张表,完全兼容 SQLite)
- internal/handler/ — auth/instance/ticket/dashboard/ghost handler
- internal/middleware/ — JWT 认证 + CORS
- internal/ghost/ — gh-ost 集成模块(同步/异步执行,任务管理)
- router/router.go — API 路由注册(/api/v1/...)
gh-ost 集成:
- RunGhOst() 同步执行
- RunGhOstAsync() 异步执行 + 进度追踪
- TaskManager 管理多个并发任务
- API: POST /ghost/dry-run, /ghost/execute, GET /ghost/status/:taskId
核心 API 已对齐:
- POST /auth/login (JWT)
- GET /dashboard/stats, /dashboard/my-tickets
- GET /tickets/statistics, CRUD + approve/execute
- GET/POST/PUT/DELETE /instances
- GET /users, /audit-rules, /announcements, /settings
已验证:
- 登录 admin/admin123 ✅
- Dashboard 99工单/110查询/4实例 ✅
- 工单统计按角色过滤 ✅
2026-05-25 21:40:54 +08:00