feat: 支持按品牌配置微信登录凭据 #11

Merged
que01 merged 1 commits from feat/brand-wechat-login-credentials into main 2026-10-23 14:14:03 +00:00
Owner

背景

小程序 wx.login 失败并提示「微信登录尚未配置」,根因是登录只读取全局 WECHAT_APP_ID/WECHAT_APP_SECRET,而生产未配置且多品牌场景下不应共用凭据。

改动

  • 微信登录按 brandSlug 读取该品牌 miniAppSettings 中的 AppID 与加密 AppSecret,不做跨品牌回退
  • AppSecret 使用 AES-256-GCM 加密保存(MINIAPP_CREDENTIAL_ENCRYPTION_KEY,回退 SESSION_SECRET)
  • Admin「发布 → 小程序配置」新增 AppSecret 输入与登录配置状态提示,留空保持原值
  • 修改 AppID 时必须同时提供对应 AppSecret,避免凭据错配
  • 移除全局 WECHAT_APP_ID/WECHAT_APP_SECRET 环境变量与文档
  • 新增单元测试与集成测试:缺凭据 503、按品牌换取 OpenID、密文不落明文

验证

  • pnpm --filter @personal-brand/api test:95/95 通过
  • pnpm --filter @personal-brand/api test:integration:全部通过
  • pnpm test:api-client:17/17 通过
  • pnpm lint、pnpm format:check、API/Admin/API Client typecheck 与 Admin build 均通过

部署后

需要在 Admin 为对应品牌填写真实 AppSecret;仅部署代码不会自动修复登录。

## 背景 小程序 `wx.login` 失败并提示「微信登录尚未配置」,根因是登录只读取全局 `WECHAT_APP_ID/WECHAT_APP_SECRET`,而生产未配置且多品牌场景下不应共用凭据。 ## 改动 - 微信登录按 `brandSlug` 读取该品牌 `miniAppSettings` 中的 AppID 与加密 AppSecret,不做跨品牌回退 - AppSecret 使用 AES-256-GCM 加密保存(`MINIAPP_CREDENTIAL_ENCRYPTION_KEY`,回退 `SESSION_SECRET`) - Admin「发布 → 小程序配置」新增 AppSecret 输入与登录配置状态提示,留空保持原值 - 修改 AppID 时必须同时提供对应 AppSecret,避免凭据错配 - 移除全局 `WECHAT_APP_ID/WECHAT_APP_SECRET` 环境变量与文档 - 新增单元测试与集成测试:缺凭据 503、按品牌换取 OpenID、密文不落明文 ## 验证 - `pnpm --filter @personal-brand/api test`:95/95 通过 - `pnpm --filter @personal-brand/api test:integration`:全部通过 - `pnpm test:api-client`:17/17 通过 - `pnpm lint`、`pnpm format:check`、API/Admin/API Client typecheck 与 Admin build 均通过 ## 部署后 需要在 Admin 为对应品牌填写真实 AppSecret;仅部署代码不会自动修复登录。
que01 added 1 commit 2026-10-23 14:08:38 +00:00
feat: 支持按品牌配置微信登录凭据
CI / Browser smoke (pull_request) Successful in 58s
CI / Static checks (pull_request) Successful in 1m32s
CI / API integration (pull_request) Successful in 1m27s
CI / Production build (pull_request) Successful in 2m7s
d0a0eeea8c
que01 merged commit a3730ee8fc into main 2026-10-23 14:14:03 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: que01/persionalBrand#11