feat(auth): 新增微信同步登录接口 wechat-sync(小程序BFF用) #185

Merged
xiaoxia merged 27 commits from feat/wechat-sync-login into develop 2026-07-07 00:37:07 +08:00
Owner

功能说明

新增系统级内部接口 POST /api/v1/auth/wechat-sync,供小程序BFF层调用,实现微信 openid → 查找/创建SaaS用户 → 返回 token 的完整链路。

改动清单

领域层 (Domain)

  • packages/domain/entities.py:User 实体新增 wechat_openidwechat_unionid 字段

端口层 (Ports)

  • packages/ports/user_repository.py:新增 find_by_wechat_openid()find_by_wechat_unionid() 抽象方法

适配器层 (Adapters)

  • packages/adapters/sqlalchemy_impl/user_repository.py:实现微信openid/unionid查询方法,save和_to_entity同步映射

应用层 (Application)

  • packages/application/auth/wechat_sync_use_case.py(新增):微信同步登录用例
    • openid匹配 → unionid匹配 → 自动创建新用户
    • 返回 access_token + refresh_token + 用户信息 + is_new_user标记

路由层 (API Routes)

  • apps/api/app/api/routes/auth.py:新增 /wechat-sync 路由
    • X-API-Key 系统级鉴权(INTERNAL_API_KEYS 环境变量配置)
    • include_in_schema=False 不对外暴露

数据库

  • alembic 迁移 025_add_user_wechat_fields 已在 develop 分支上

安全设计

  • 接口不直接暴露给终端用户,仅BFF层通过内部API Key调用
  • API Key支持环境变量配置和文件持久化两种方式
  • 生产环境未配置Key时直接拒绝

关联项目

小虾智剪微信小程序(miniapp)BFF层依赖此接口

## 功能说明 新增系统级内部接口 `POST /api/v1/auth/wechat-sync`,供小程序BFF层调用,实现微信 openid → 查找/创建SaaS用户 → 返回 token 的完整链路。 ## 改动清单 ### 领域层 (Domain) - `packages/domain/entities.py`:User 实体新增 `wechat_openid`、`wechat_unionid` 字段 ### 端口层 (Ports) - `packages/ports/user_repository.py`:新增 `find_by_wechat_openid()`、`find_by_wechat_unionid()` 抽象方法 ### 适配器层 (Adapters) - `packages/adapters/sqlalchemy_impl/user_repository.py`:实现微信openid/unionid查询方法,save和_to_entity同步映射 ### 应用层 (Application) - `packages/application/auth/wechat_sync_use_case.py`(新增):微信同步登录用例 - openid匹配 → unionid匹配 → 自动创建新用户 - 返回 access_token + refresh_token + 用户信息 + is_new_user标记 ### 路由层 (API Routes) - `apps/api/app/api/routes/auth.py`:新增 `/wechat-sync` 路由 - X-API-Key 系统级鉴权(INTERNAL_API_KEYS 环境变量配置) - include_in_schema=False 不对外暴露 ### 数据库 - alembic 迁移 `025_add_user_wechat_fields` 已在 develop 分支上 ## 安全设计 - 接口不直接暴露给终端用户,仅BFF层通过内部API Key调用 - API Key支持环境变量配置和文件持久化两种方式 - 生产环境未配置Key时直接拒绝 ## 关联项目 小虾智剪微信小程序(miniapp)BFF层依赖此接口
xiaoxia self-assigned this 2026-07-06 22:10:51 +08:00
xiaoxia added 27 commits 2026-07-06 22:10:51 +08:00
Merge pull request 'Merge develop → main: 阶段0-3 全量上线(V21 UI + Phase 8 + CosyVoice)' (#176) from develop into main
Auto Merge PRs / auto-merge (push) Failing after 36s
CI/CD Pipeline / Frontend Lint (push) Failing after 161h11m29s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 161h11m36s
Deploy / Deploy Staging (push) Failing after 161h10m56s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
8b2ba8dc16
fix(api): add response_class=Response to DELETE endpoint for 204 status
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Failing after 160h22m25s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 160h22m27s
bb21990173
fix(api): move Response import to correct position after other imports
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 160h15m5s
CI/CD Pipeline / Frontend Lint (push) Failing after 160h15m38s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 160h15m45s
87a5ce84d3
hotfix: 移除 delete 路由的 response_class=Response 修复 204 断言崩溃
Tests / lint (pull_request) Failing after 159h56m48s
Tests / test (pull_request) Failing after 159h56m48s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 159h57m21s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 159h57m26s
CI/CD Pipeline / Frontend Lint (push) Failing after 159h58m2s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 159h58m8s
dd2808d17a
FastAPI 不允许 status_code=204 同时指定 response_class=Response,
导致 API 容器启动时 AssertionError 不断重启。

修复 8 处 @router.delete 装饰器:
- duplication.py:242
- recipes.py:177
- templates.py:198, 276
- titles.py:146
- tts.py:179
- voice_clones.py:194
- voices.py:319
Merge pull request 'hotfix: 修复 204 状态码 response_class=Response 导致 API 容器崩溃' (#177) from hotfix/fix-204-response-class into main
CI/CD Pipeline / Frontend Lint (push) Failing after 159h51m4s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 159h51m11s
Deploy / Deploy Staging (push) Failing after 159h50m29s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
d0e4235828
fix: correct 204 response in edit_plans delete endpoint
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
167ee9a9d7
Remove response_class=Response, change return type to Response, add explicit return Response(status_code=204)
fix: correct 204 response in edit_templates delete endpoint
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 159h30m34s
CI/CD Pipeline / Frontend Lint (push) Failing after 159h31m5s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 159h31m10s
4d1a0925d3
Change return type to Response, add explicit return Response(status_code=204)
Merge pull request 'Merge develop into main (v0.1.105: Worker healthcheck fix)' (#178) from develop into main
Auto Merge PRs / auto-merge (push) Failing after 35s
CI/CD Pipeline / Frontend Lint (push) Failing after 157h17m5s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 157h17m12s
Deploy / Deploy Staging (push) Failing after 157h16m17s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
f15e049f37
Merge pull request 'Release: 安全修复 + 代码优化 + Mock替换 (2026-07-03)' (#181) from develop into main
CI/CD Pipeline / Frontend Lint (push) Failing after 147h8m46s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 147h8m55s
Deploy / Deploy Staging (push) Failing after 147h8m22s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
8858a137b1
Merge pull request 'Release: 补齐 timeline API (P2收尾) (2026-07-03)' (#182) from develop into main
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 146h48m34s
CI/CD Pipeline / Frontend Lint (push) Failing after 146h49m2s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 146h49m11s
54c88e58a3
Merge pull request 'fix(infra): Worker healthcheck YAML 修复 + APP_VERSION 默认值' (#183) from develop into main
CI/CD Pipeline / Frontend Lint (push) Failing after 145h39m20s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 145h39m27s
Deploy / Deploy Staging (push) Failing after 145h38m57s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
faec1791ad
Merge pull request 'Merge develop: nginx proxy_pass 永久修复' (#184) from develop into main
Auto Merge PRs / auto-merge (push) Failing after 42s
CI/CD Pipeline / Frontend Lint (push) Failing after 143h17m54s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 143h18m2s
Deploy / Deploy Staging (push) Failing after 143h17m27s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
0d07febb78
Merge develop → main: Phase 1-3 全量上线 + workspace清理(v0.1.109)
Auto Merge PRs / auto-merge (push) Failing after 1m31s
CI/CD Pipeline / Frontend Lint (push) Failing after 140h1m30s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 140h1m30s
Deploy / Deploy Staging (push) Failing after 140h1m20s
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
c126daeda5
Merge branch 'develop'
CI/CD Pipeline / Frontend Lint (push) Failing after 118h26m35s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 118h26m35s
Deploy / Deploy Staging (push) Failing after 118h26m0s
Deploy / Staging E2E Tests (push) Failing after 118h23m16s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
c4e7d9a6f9
Merge branch 'develop'
Auto Merge PRs / auto-merge (push) Failing after 1m40s
CI/CD Pipeline / Frontend Lint (push) Failing after 114h52m39s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 114h52m57s
Deploy / Deploy Staging (push) Has been skipped
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Failing after 114h50m35s
Deploy / Deploy Production (push) Failing after 114h34m27s
Deploy / Production Browser E2E (push) Failing after 114h33m48s
dd2db817bc
Merge branch 'develop' - v0.1.113: 安全审计修复(P1越权) + UI打磨三批 + 测试污染修复
CI/CD Pipeline / Frontend Lint (push) Failing after 97h55m54s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 97h55m54s
Deploy / Deploy Staging (push) Failing after 97h55m45s
Deploy / Staging E2E Tests (push) Failing after 97h52m0s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
a6e809600e
Merge branch 'develop' - v0.1.114: 修复API容器启动失败(worker模块导入问题)
CI/CD Pipeline / Frontend Lint (push) Failing after 97h29m8s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 97h29m17s
Deploy / Deploy Staging (push) Failing after 97h28m35s
Deploy / Staging E2E Tests (push) Failing after 97h21m3s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
dd1a83ec51
Merge branch 'develop' - v0.1.115: V21一键生成页面 + 测试修复
Auto Merge PRs / auto-merge (push) Failing after 2m25s
CI/CD Pipeline / Frontend Lint (push) Failing after 96h6m41s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 96h6m41s
Deploy / Deploy Staging (push) Has been skipped
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Failing after 96h6m8s
Deploy / Deploy Production (push) Failing after 95h48m59s
Deploy / Production Browser E2E (push) Failing after 95h47m14s
ea40b41c05
Merge branch 'develop' - v0.1.116: API/Worker依赖拆分,API镜像瘦身
CI/CD Pipeline / Frontend Lint (push) Failing after 93h13m54s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 93h13m54s
Deploy / Deploy Staging (push) Failing after 93h13m46s
Deploy / Staging E2E Tests (push) Failing after 93h11m44s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
f06c7f9d33
Merge branch 'develop' - v0.1.117: 补025号迁移文件
CI/CD Pipeline / Frontend Lint (push) Failing after 92h24m4s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 92h24m13s
Deploy / Deploy Staging (push) Failing after 92h23m36s
Deploy / Staging E2E Tests (push) Failing after 92h21m21s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
6a7fde9d90
Merge branch 'develop' - v0.1.118: TTS失败返回格式统一 + StrEnum反序列化修复
Auto Merge PRs / auto-merge (push) Failing after 1m28s
CI/CD Pipeline / Frontend Lint (push) Failing after 90h26m10s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 90h26m10s
Deploy / Deploy Staging (push) Failing after 90h26m3s
Deploy / Staging E2E Tests (push) Failing after 90h19m22s
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
8e60c412f7
Merge develop into main - v0.1.119: V21 UI全局改造 + CI门禁 + E2E修复 + 暗色模式修复
Auto Merge PRs / auto-merge (push) Failing after 3m20s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 72h14m13s
CI/CD Pipeline / Frontend Lint (push) Failing after 72h13m26s
CI/CD Pipeline / Deploy Staging (push) Failing after 72h11m37s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 71h57m3s
CI/CD Pipeline / Build Production Runtime Images (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
d8770ba57f
Merge develop into main - v0.1.120
Auto Merge PRs / auto-merge (push) Failing after 1m32s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 67h39m58s
CI/CD Pipeline / Frontend Lint (push) Failing after 67h39m12s
CI/CD Pipeline / Deploy Staging (push) Failing after 67h37m24s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 67h22m51s
CI/CD Pipeline / Build Production Runtime Images (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
8a386f6172
feat(auth): 新增微信同步登录接口wechat-sync(内部系统级接口,支持openid查找/创建用户并返回SaaS token)
CI/CD Pipeline / Deploy Staging (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 62h22m48s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 62h22m56s
46d98f369d
xiaoxia merged commit ed6150fa52 into develop 2026-07-07 00:37:07 +08:00
Sign in to join this conversation.