Commit Graph

16 Commits

Author SHA1 Message Date
movingsam
4fd931d44b IMPL-11: 更新 TenantRoutingMiddleware 适配新 Transform
职责分离:
- Middleware: 负责 JWT 验证、TenantId 验证、设置 ClusterId 和 TenantId 到 HttpContext.Items
- Transform: 负责从数据库查询 Destination 并设置 ProxyRequest.RequestUri

修改内容:
1. TenantRoutingMiddleware:
   - 添加设置 TenantId 到 HttpContext.Items 供 Transform 使用
   - 修复服务名提取正则表达式,支持连字符(-)和下划线(_)
   - 更新 XML 文档,明确职责分离说明

2. TenantRoutingTransform:
   - 添加 ExtractTenantId 方法,优先从 HttpContext.Items 获取 TenantId
   - 保留从 JWT 提取作为回退机制

3. 单元测试:
   - 新增职责分离验证测试 (ShouldNotSetDestinationUri, ShouldOnlySetClusterIdAndTenantId)
   - 新增与 Transform 协作测试 (ShouldSetItemsForTransformConsumption)
   - 更新服务名提取测试,支持更多字符类型
   - 总测试数: 24个,全部通过
2026-03-08 01:20:20 +08:00
movingsam
c7cf1d3738 feat: add TenantRoutingTransform for multi-tenant routing (IMPL-10)
- Implement YARP RequestTransform to route requests based on tenant
- Extract tenant ID from JWT token (supports multiple claim types)
- Query tenant-specific destination first, fallback to default
- Add IMemoryCache for performance optimization (5min expiration)
- Update Platform packages to 1.0.14 to use GwDestination.TenantCode
2026-03-08 01:01:22 +08:00
movingsam
52eba07097 feat: add MigrationTool for gateway config migration (IMPL-7)
- Create MigrationTool console app for exporting DB config to K8s YAML
- Support dry-run mode and validation
- Add Npgsql and YamlDotNet dependencies
2026-03-08 00:35:04 +08:00
movingsam
449fe3a385 refactor: 移除 GatewayConfigController - 网关只需转发请求 2026-03-04 13:35:49 +08:00
movingsam
0c08620565 refactor: 升级 Fengling.Platform.Infrastructure 到 1.0.12 并迁移到新模型
- 升级 Fengling.Platform.Infrastructure 包到 1.0.12
- DatabaseRouteConfigProvider: 使用 GwTenantRoutes 和 GwRouteMatch
- DatabaseClusterConfigProvider: 使用 GwClusters 和内嵌 Destinations
- GatewayDbContext: 添加兼容性别名 (TenantRoutes, ServiceInstances)
- RouteCache: 更新使用新的模型结构
- 暂时禁用 GatewayConfigController 和测试 (需要重写以适配新模型)
2026-03-04 13:30:35 +08:00
movingsam
28941fc0ef chore: 升级 Fengling.Platform.Infrastructure 到 1.0.12 2026-03-04 13:17:22 +08:00
movingsam
42b8c9cca5 fix: 升级 Fengling.Platform 包并修复编译警告
- 修复 CS0108: GatewayDbContext.Tenants 隐藏继承成员
- 修复 NU1506: 移除重复 PackageVersion 定义
- 修复 NU1507: 添加包源映射配置 (NuGet.Config)
2026-03-04 13:14:26 +08:00
movingsam
3994a95177 feat: remove K8s health check from gateway (Phase 2)
- Delete KubernetesPendingSyncService.cs
- Delete PendingServicesController.cs
- Delete GwPendingServiceDiscovery.cs model
- Update GatewayDbContext.cs - remove DbSet
- Update Program.cs - remove service registration and using statements
- Update roadmap and requirements documentation
2026-03-02 18:42:54 +08:00
movingsam
8f7e8d3a71 docs: update all planning docs to Chinese 2026-03-02 18:15:23 +08:00
movingsam
da4f03502a refactor: reorganize project structure into yarpgateway folder
- Move YarpGateway and all source files to src/yarpgateway/
- Keep Fengling.Gateway.Plugin.Abstractions at src/ level
- Fix duplicate project reference in YarpGateway.slnx
- Update solution paths and test project references
- Add ProjectReference from YarpGateway to abstractions
2026-03-01 17:47:48 +08:00
movingsam
4839366227 feat(plugin): 添加 NuGet 包发布配置
- 添加包元数据到 csproj
- 创建 nuget.yml 发布工作流
2026-03-01 17:10:06 +08:00
movingsam
09957364e2 feat(plugin): 添加插件抽象层项目 Fengling.Gateway.Plugin.Abstractions
- 创建插件接口定义 (IGatewayPlugin, IRequestPlugin, IResponsePlugin, IRouteTransformPlugin, ILoadBalancePlugin)
- 添加 YARP 引用用于类型定义
2026-03-01 17:00:48 +08:00
movingsam
d7007d0d7f config: improve Redis configuration and credentials management
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-28 18:38:07 +08:00
movingsam
eec65c1e05 security: enhance JWT and tenant routing middleware
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-28 18:37:48 +08:00
movingsam
2a4a06ddb8 feat: add JWT authentication to gateway
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-28 18:37:31 +08:00
movingsam
564d664426 refactor: move project to src/ and add slnx
Some checks failed
Build and Deploy / build (push) Successful in 22s
Build and Deploy / docker (push) Successful in 26m23s
Build and Deploy / deploy (push) Failing after 3s
- Add YarpGateway.slnx solution file
- Move all project files to src/ directory
- Update Dockerfile for new src/ path structure
- Update CI/CD workflow with src/ project path
- Fix NuGet package references (use Gitea NuGet packages)
- Add CPM (Central Package Management) with Directory.Packages.props
2026-02-28 13:10:41 +08:00