feat(oauth): 新增 Codex account_user_id 和 organizations 字段采集、展示与判重

- 从 Codex id_token claims 和 token_response 中提取 account_user_id 和 organizations
- OAuth 判重逻辑改为优先按 account_user_id 匹配,支持同用户不同 Team 不误判
- 号池和 Provider 详情页展示组织标签、account ID 和 account_user_id
- 前端重复的 OAuth identity 工具函数提取到 utils/oauthIdentity.ts
- 后端重复的 normalize_oauth_organizations 提取到 core/provider_oauth_utils.py
This commit is contained in:
fawney19
2026-03-11 21:37:08 +08:00
parent b45f021bba
commit 0d770d1c4d
16 changed files with 546 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
import client from '../client'
import { dedupedRequest } from '@/utils/cache'
import type { AllowedModels, ProxyConfig } from './types/provider'
import type { AllowedModels, OAuthOrganizationInfo, ProxyConfig } from './types/provider'
const POOL_BATCH_ACTION_TIMEOUT_MS = 5 * 60 * 1000
@@ -102,6 +102,9 @@ export interface PoolKeyDetail {
oauth_invalid_at?: number | null
oauth_invalid_reason?: string | null
oauth_plan_type?: string | null
oauth_account_id?: string | null
oauth_account_user_id?: string | null
oauth_organizations?: OAuthOrganizationInfo[] | null
quota_updated_at?: number | null
health_score?: number
circuit_breaker_open?: boolean

View File

@@ -12,6 +12,13 @@ export interface ProxyConfig {
enabled?: boolean // 是否启用代理false 时保留配置但不使用)
}
export interface OAuthOrganizationInfo {
id?: string | null
title?: string | null
is_default?: boolean | null
role?: string | null
}
/**
* 请求头规则类型
* - set: 设置/覆盖请求头
@@ -264,6 +271,8 @@ export interface EndpointAPIKey {
oauth_email?: string | null // OAuth 授权的邮箱
oauth_plan_type?: string | null // Codex 订阅类型: plus/free/team/enterprise
oauth_account_id?: string | null // Codex ChatGPT 账号 ID
oauth_account_user_id?: string | null // Codex ChatGPT account-user 联合 ID
oauth_organizations?: OAuthOrganizationInfo[] | null // OAuth 关联组织/工作区摘要
oauth_invalid_at?: number | null // OAuth Token 失效时间Unix 时间戳)
oauth_invalid_reason?: string | null // OAuth Token 失效原因
// 上游元数据(由上游响应采集,如 Codex 额度信息 / Antigravity 配额信息)