fengling-console/docs/plans/fengling-console-plan.md

158 lines
3.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Fengling.Console 运管中心规划
## 项目概述
**项目名称**: Fengling.Console
**中文名称**: 风铃运管中心
**定位**: 统一运维管理平台
## 架构整合
### 1. 后端整合
- **原项目**: `src/YarpGateway/` (YARP Gateway)
- **整合到**: `src/Fengling.Console/` (新建)
- **新增功能**: OAuth Client管理
### 2. 前端整合
- **原项目**: `src/YarpGateway.Admin/` (Vue 3 + Vite)
- **整合到**: `src/Fengling.Console.Web/` (新建)
- **功能扩展**:
- 网关路由管理
- 租户管理
- OAuth Client管理
- 用户管理通过AuthService API
## 功能模块
### 模块1: 网关管理
- 租户列表
- 租户路由配置
- 集群实例管理
- 全局路由配置
- 负载均衡策略
### 模块2: OAuth Client管理
- Client ID/Secret管理
- 重定向URI配置
- 授权类型配置
- Scope配置
- Client状态管理
### 模块3: 用户管理
- 用户列表
- 用户角色分配
- 租户分配
- 用户状态管理
## 认证集成
### Fengling.Console作为OAuth Client
需要在AuthService初始化时注册
```csharp
// Client配置
ClientId: "fengling-console"
ClientSecret: "console-secret-xxx"
RedirectUris: ["http://console.fengling.local/auth/callback"]
PostLogoutRedirectUris: ["http://console.fengling.local/"]
Scopes: ["api", "offline_access"]
GrantTypes: ["authorization_code", "refresh_token"]
```
## 目录结构
```
src/
├── Fengling.AuthService/ # 认证服务(已完成部分)
├── Fengling.Console/ # 运管中心后端(新建)
│ ├── Controllers/
│ │ ├── Gateway/ # 网关管理
│ │ ├── OAuth/ # OAuth Client管理
│ │ └── Users/ # 用户管理代理
│ ├── Services/
│ └── Data/
├── Fengling.Console.Web/ # 运管中心前端(新建)
│ ├── src/
│ │ ├── views/
│ │ │ ├── gateway/ # 网关管理
│ │ │ ├── oauth/ # OAuth管理
│ │ │ └── users/ # 用户管理
│ │ └── components/
│ └── YarpGateway.Admin/ # 原有代码迁移
└── YarpGateway/ # 网关服务(保留)
```
## 技术栈
### 后端 (Fengling.Console)
- .NET 10.0
- ASP.NET Core Web API
- EF Core 10.0
- PostgreSQL
- OpenTelemetry
### 前端 (Fengling.Console.Web)
- Vue 3 + TypeScript
- Vite
- Element Plus
- Pinia
- Vue Router
## 实施计划
### Phase 1: 认证服务扩展
1. [ ] Task 5-9: 完成AuthService基础功能
2. [ ] Task 10: 添加OAuth Client模型和管理
3. [ ] Task 11: 预注册Fengling.Console作为Client
### Phase 2: 运管中心后端
1. [ ] Task 12: 创建Fengling.Console项目
2. [ ] Task 13: 迁移网关管理功能
3. [ ] Task 14: 添加OAuth Client管理API
4. [ ] Task 15: 添加用户管理代理API
### Phase 3: 运管中心前端
1. [ ] Task 16: 创建Fengling.Console.Web项目
2. [ ] Task 17: 迁移YarpGateway.Admin代码
3. [ ] Task 18: 添加OAuth管理界面
4. [ ] Task 19: 集成OAuth认证登录
## 依赖关系
```
Fengling.Console.Web
↓ (OAuth 2.0)
Fengling.Console
↓ (数据库)
PostgreSQL
↓ (路由配置)
YarpGateway
```
## 数据库设计
### OAuth Applications表
```sql
CREATE TABLE oauth_applications (
id BIGSERIAL PRIMARY KEY,
client_id VARCHAR(100) UNIQUE NOT NULL,
client_secret VARCHAR(200),
display_name VARCHAR(100),
redirect_uris TEXT[],
post_logout_redirect_uris TEXT[],
scopes TEXT[],
grant_types TEXT[],
client_type VARCHAR(20),
consent_type VARCHAR(20),
status VARCHAR(20),
created_at TIMESTAMP DEFAULT NOW()
);
```
## 注意事项
1. **向后兼容**: YarpGateway继续独立运行
2. **渐进式迁移**: 先完成Console后端再迁移前端
3. **统一认证**: 所有管理界面通过AuthService OAuth登录
4. **权限控制**: Console内部API也需要认证