12 Commits

Author SHA1 Message Date
向宁
11315fd00b feat: wire Watermill CQRS — EventBus in usecases, event handlers, router lifecycle
- Add EventPublisher interface in biz layer for domain event publishing
- Wire EventBusPublisher (Watermill EventBus adapter) into FileUsecase, FolderUsecase, ShareUsecase
- Publish events after UploadFile, DeleteFile, CreateFolder, DeleteFolder, CreateShare
- Implement CQRSHandler with logging event handlers for all 6 event types
- Register event handlers via CQRSBus.RegisterHandlers using Watermill EventProcessor
- Store subscriber and wmLogger in CQRSBus for EventProcessor wiring
- Expose SqlDB() on Data struct for Watermill SQL pub/sub
- Start Watermill router in goroutine alongside Kratos app with graceful close
- Use appContext wrapper struct to pass CQRSBus through Wire DI graph
2026-05-25 13:52:05 +08:00
向宁
3eb1a1839d feat: add JWT auth middleware with public endpoint selector
Add HS256 JWT authentication to both HTTP and gRPC servers using
Kratos jwt middleware with selector to skip auth for public share
endpoints (GetShareInfo, DownloadShare). Wire DI updated to inject
conf.Auth into server constructors.
2026-05-25 13:43:34 +08:00
向宁
42addaea7d feat: add Wire DI and rewrite main.go as Kratos app entry point
- Create wire.go with interface bindings (biz interfaces → data implementations)
- Rewrite main.go to use Kratos config loading + Wire-generated initApp
- Remove temporary deps.go pinning file
- Wire generates complete dependency graph: config → data → biz → service → server → app
2026-05-25 13:12:18 +08:00
向宁
3a18ca0579 feat: add directory structure and file sharing support
- PostgreSQL metadata overlay layer on top of existing S3 storage
- 3 new tables: folders, files, share_links
- Folder CRUD: create, get with children, tree, rename, delete (cascade)
- File operations: upload to folder, move between folders
- Share links: create with optional password/expiry/download limit, public access
- S3 compensation on PG write failure
- Existing 14 endpoints untouched
2026-05-20 20:26:19 +08:00
向宁
d3015d63f2 feat: add OpenTelemetry tracing, metrics, and logging
- Create internal/common/otel.go with InitOTel() for tracing + metrics + logs
- Add otelgin middleware for automatic Gin HTTP span creation
- Add OTelEndpoint config (default: 192.168.1.154:4316)
- Export all signals via OTLP gRPC to OTel Collector
2026-05-17 22:08:03 +08:00
root
d861be0d6e feat: 新增文件文本内容接口,修复Markdown预览
- 新增 GET /files/content 接口,后端直接读取S3文件文本内容返回
- Repository 新增 GetFileContent 方法
- CQRS: 新增 GetFileContentQuery / GetFileContentHandler
- 前端 Markdown 预览改为调用后端接口获取内容,用 marked.js 渲染
- 解决 presigned URL CORS 和下载头导致 MD 文件无法预览的问题
- config.go: AuthAPIKey 默认值恢复为 xn001624.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-06 18:08:42 +08:00
root
9efd78aaff fix: 修正 RustFS 连接地址,移除硬编码密钥
- 修正 RustFS 端点地址为 192.168.1.154:9000(对应服务器实际部署)
- 移除 config.go 中硬编码的 AccessKey/SecretKey 默认值,改为环境变量传入
- 移除 middleware/auth.go 中硬编码的 API_KEY_VALUE 常量,改为参数注入
- 新增 Config.AuthAPIKey 字段,通过 AUTH_API_KEY 环境变量配置
- 移除 login.html 页面上的密钥格式提示,防止信息泄露
- docker-compose.yml 补全 RustFS 连接所需的环境变量

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-05 17:02:01 +08:00
root
54f66c56ed feat: 添加 Web UI 登录功能
为 Web UI 添加完整的登录验证系统,遵循 CQRS 架构模式。

主要功能:
- 创建登录页面 UI (web/login.html)
  - 美观的渐变背景设计
  - 密钥输入和验证
  - 错误提示和加载状态

- 实现登录验证 (遵循 CQRS)
  - 新增 LoginQuery 和 LoginHandler (internal/api/handlers/auth_handlers.go)
  - 新增 AuthEndpoint (internal/api/endpoints/auth_endpoints.go)
  - 注册登录接口 /auth/login (无需授权)

- 更新主页面 (web/index.html)
  - 添加登录状态检查
  - 未登录显示提示信息
  - 所有 API 请求自动携带 X-API-Key 头
  - 添加退出登录功能
  - 401 错误自动跳转登录页

- 更新路由配置 (cmd/server/main.go)
  - 添加 /auth/login 公开路由
  - 注册登录处理器和端点

- 新增登录文档 (docs/LOGIN_GUIDE.md)
  - 完整的使用说明
  - 技术实现细节
  - API 接口说明

安全特性:
- 密钥存储在 localStorage
- 自动处理登录过期
- 支持主动退出登录

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:27:45 +08:00
root
11fc10ba8a feat: 添加API授权中间件
为所有API接口添加授权验证,要求请求头中包含有效的API密钥才能访问。

主要变更:
- 新增授权中间件 (internal/middleware/auth.go)
  - 验证 X-API-Key 请求头
  - 密钥值为 xn001624.
  - 无效密钥返回 401 Unauthorized

- 更新路由配置 (cmd/server/main.go)
  - 使用路由组统一应用授权中间件
  - 保护所有文件和存储桶操作接口
  - Swagger 和 Web UI 保持公开访问

- 新增授权使用文档 (docs/AUTH_GUIDE.md)
  - 多语言使用示例 (cURL, JavaScript, Python)
  - 完整的错误说明和授权范围

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:22:04 +08:00
root
00a0e583a8 添加存储桶删除功能
- 新增 DeleteBucketHandler 处理存储桶删除请求
- 添加 DELETE /buckets API 端点
- 在前端界面添加删除存储桶按钮功能
- 添加存储桶删除请求验证器

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 16:40:09 +08:00
root
71a5ea5f41 添加文件删除功能 2025-12-19 16:32:20 +08:00
root
8232827835 Initial commit 2025-12-18 09:34:49 +08:00