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

@@ -710,6 +710,13 @@ class EndpointAPIKeyUpdate(BaseModel):
return v.strip()
class OAuthOrganizationResponse(BaseModel):
id: str | None = Field(default=None, description="OAuth 组织/工作区 ID")
title: str | None = Field(default=None, description="OAuth 组织/工作区标题")
is_default: bool = Field(default=False, description="是否为默认组织/工作区")
role: str | None = Field(default=None, description="当前账号在组织中的角色")
class EndpointAPIKeyResponse(BaseModel):
"""Endpoint API Key 响应"""
@@ -753,6 +760,14 @@ class EndpointAPIKeyResponse(BaseModel):
default=None, description="OAuth 账号套餐类型(如 free/plus/team/enterprise"
)
oauth_account_id: str | None = Field(default=None, description="OAuth 账号 ID")
oauth_account_user_id: str | None = Field(
default=None,
description="OAuth 账号-工作区联合 ID如 Codex chatgpt_account_user_id",
)
oauth_organizations: list[OAuthOrganizationResponse] = Field(
default_factory=list,
description="OAuth 关联的组织/工作区摘要列表",
)
oauth_invalid_at: int | None = Field(
default=None, description="OAuth Token 失效时间Unix 时间戳),如账号被封、授权撤销等"
)