feat: 集成Google OAuth认证和完善Stripe支付系统
- 新增Google OAuth 2.0认证模块 - 实现Google Strategy和AuthController - 添加Google平台适配器和用户统一管理 - 支持OAuth回调和token交换机制 - 完善Stripe支付集成 - 新增Stripe支付适配器和控制器 - 实现webhook事件处理和支付确认 - 支持多币种和国际化支付 - 扩展平台类型支持 - 在PlatformType中新增GOOGLE和STRIPE - 更新适配器工厂注册机制 - 完善跨平台用户身份管理 - 增强依赖和配置 - 添加@nestjs/passport和passport-google-oauth20 - 更新支付方法枚举和货币支持 - 完善订单号生成和回调URL构建
This commit is contained in:
63
auth.md
Normal file
63
auth.md
Normal file
@@ -0,0 +1,63 @@
|
||||
当前项目架构分析
|
||||
|
||||
现有认证系统:
|
||||
- 基于适配器模式的多平台用户认证系统
|
||||
- 支持微信、字节跳动等小程序平台登录
|
||||
- 统一用户实体(UserEntity)和平台用户实体(PlatformUserEntity)
|
||||
- 无Passport.js依赖,采用自定义适配器架构
|
||||
|
||||
缺失依赖:
|
||||
- 项目未安装@nestjs/passport和passport-google-oauth20
|
||||
- 需要安装Google OAuth相关依赖
|
||||
|
||||
Google登录集成实施方案
|
||||
|
||||
第一阶段:依赖安装
|
||||
|
||||
1. 安装必要依赖包
|
||||
pnpm add @nestjs/passport passport passport-google-oauth20 @types/passport-google-oauth20
|
||||
|
||||
第二阶段:平台类型扩展
|
||||
|
||||
2. 更新PlatformType枚举 (src/entities/platform-user.entity.ts:29)
|
||||
- 添加GOOGLE = 'google'选项
|
||||
|
||||
第三阶段:Google OAuth适配器实现
|
||||
|
||||
3. 创建Google适配器 (src/platform/adapters/google.adapter.ts)
|
||||
- 继承BaseAdapter基类
|
||||
- 实现Google OAuth 2.0认证流程
|
||||
- 支持访问令牌和刷新令牌管理
|
||||
4. 创建Google Strategy (src/auth/strategies/google.strategy.ts)
|
||||
- 实现Passport Google OAuth2.0策略
|
||||
- 与适配器系统集成
|
||||
|
||||
第四阶段:认证模块构建
|
||||
|
||||
5. 创建Auth模块 (src/auth/)
|
||||
- auth.module.ts: 配置Passport和Google Strategy
|
||||
- auth.controller.ts: Google OAuth路由端点
|
||||
- auth.guard.ts: Google认证守卫
|
||||
|
||||
第五阶段:系统集成
|
||||
|
||||
6. 更新PlatformModule (src/platform/platform.module.ts:66)
|
||||
- 注册GoogleAdapter到适配器工厂
|
||||
7. 更新AppModule (src/app.module.ts:58)
|
||||
- 导入新建的AuthModule
|
||||
|
||||
第六阶段:环境配置
|
||||
|
||||
8. 配置环境变量
|
||||
- GOOGLE_CLIENT_ID: Google OAuth客户端ID
|
||||
- GOOGLE_CLIENT_SECRET: Google OAuth客户端密钥
|
||||
- GOOGLE_CALLBACK_URL: OAuth回调URL
|
||||
|
||||
第七阶段:API端点
|
||||
|
||||
9. 实现Google登录端点
|
||||
- GET /auth/google: 启动Google OAuth流程
|
||||
- GET /auth/google/callback: 处理OAuth回调
|
||||
- POST /auth/google/token: 处理移动端token交换
|
||||
|
||||
这个方案将Google登录无缝集成到现有的多平台认证架构中,保持系统的一致性和可扩展性。
|
||||
Reference in New Issue
Block a user