- Dockerfile 全部改为 npm install + 全局 tsc,解决 pnpm 符号链接问题 - docker-compose 添加 Redis 服务、OAuth 环境变量透传、web 端口改为可配置 - MCP URL 改用 window.location.origin 适配反向代理 - tsconfig 添加 paths 映射解决 Docker 内模块引用 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3.3 KiB
3.3 KiB
OAuth 第三方登录注册指南
1. Google OAuth
步骤:
- 创建项目(或选已有项目)
- 左侧菜单 → "OAuth consent screen" → 选 External → 填写应用名称(AgentFox)、用户支持邮箱
- 左侧菜单 → "Credentials" → "Create Credentials" → "OAuth 2.0 Client ID"
- 应用类型选 Web application
- 名称填
AgentFox Web - "Authorized redirect URIs" 添加:
- 开发:
http://localhost:3000/api/auth/oauth/google/callback - 生产:
https://你的域名/api/auth/oauth/google/callback
- 开发:
- 创建后拿到 Client ID 和 Client Secret
写入 .env:
GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPx-xxx
2. GitHub OAuth
步骤:
- "OAuth Apps" → "New OAuth App"
- 填写:
- Application name:
AgentFox - Homepage URL:
http://localhost:5173(开发) - Authorization callback URL:
http://localhost:3000/api/auth/oauth/github/callback
- Application name:
- 创建后拿到 Client ID,点击 "Generate a new client secret" 拿到 Client Secret
写入 .env:
GITHUB_CLIENT_ID=Ov23li...
GITHUB_CLIENT_SECRET=xxx
生产环境需要再创建一个 OAuth App,callback URL 改为生产域名。
3. Apple Sign In
需要 Apple Developer Program 付费账号($99/年)。如果暂时没有,可以先跳过,按钮已在前端显示但会报错提示。
前往: Apple Developer - Certificates, Identifiers & Profiles
3a. 注册 App ID
- "Identifiers" → "+" → 选 "App IDs" → "App"
- Description:
AgentFox - Bundle ID:
com.agentfox.web(Explicit) - 勾选 "Sign In with Apple" → Continue → Register
3b. 创建 Services ID
- "Identifiers" → "+" → 选 "Services IDs"
- Description:
AgentFox Web Login - Identifier:
com.agentfox.web.login← 这就是 APPLE_CLIENT_ID - 勾选 "Sign In with Apple" → Configure:
- Primary App ID: 选上面创建的 App ID
- Domains:
你的域名(开发时用 ngrok) - Return URLs:
https://你的域名/api/auth/oauth/apple/callback
- Save → Continue → Register
3c. 创建 Key
- "Keys" → "+" → 名称
AgentFox Auth Key - 勾选 "Sign In with Apple" → Configure → 选 Primary App ID → Save
- Continue → Register → 下载 .p8 文件(只能下载一次!)
- 记下 Key ID
3d. 找到 Team ID
- 右上角账户名 → "Membership details"
- 记下 Team ID
写入 .env:
APPLE_CLIENT_ID=com.agentfox.web.login
APPLE_TEAM_ID=XXXXXXXXXX
APPLE_KEY_ID=XXXXXXXXXX
APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIGT...这里是.p8文件内容...\n-----END PRIVATE KEY-----"
Apple 回调必须 HTTPS。本地开发可以用
ngrok http 3000获取临时 HTTPS 域名,然后设置OAUTH_CALLBACK_BASE_URL=https://xxx.ngrok.io。
通用配置
.env 中还需要设置回调基础 URL:
OAUTH_CALLBACK_BASE_URL=http://localhost:3000
FRONTEND_URL=http://localhost:5173
生产环境改为实际域名即可。
验证
配置好后启动 pnpm dev:server + pnpm dev:web,访问 /login 页面点击对应按钮即可测试。