登录鉴权
ShipAny TanStack 基于 better-auth + Drizzle 适配器实现鉴权。配置位于 src/core/auth/index.ts,所有请求由 catch-all 路由 /api/auth/$(src/routes/api/auth/$.ts)处理。
以下所有服务商凭证均在 管理后台 → Settings → Auth 中配置(存储于 config 表);同名环境变量可作兜底。
邮箱密码登录
默认开启(email_auth_enabled)。可选开启邮箱验证:
- 打开
email_verification_enabled,并配置 Resend(resend_api_key、resend_sender_email) - 验证链接 24 小时过期;重发限制为 60 秒一次
未开启验证时,用户注册后自动登录。
Google 登录
- 在 Google Cloud Console 创建 OAuth 客户端(类型:Web application)
- 添加授权回调地址:
https://your-domain.com/api/auth/callback/google- 在管理后台 Settings 填入
google_client_id/google_client_secret - 可选开启 Google One Tap(
google_one_tap_enabled)
GitHub 登录
- 在 GitHub → Settings → Developer settings 创建 OAuth App
- 设置回调地址:
https://your-domain.com/api/auth/callback/github- 在管理后台 Settings 填入
github_client_id/github_client_secret
会话
会话存储在 session 表,以 httpOnly Cookie 形式下发,并记录 ipAddress 与 userAgent。user 表附带扩展字段:utmSource、ip、locale。