feat: add Vertex AI authentication support for provider API keys

- Add auth_type field to ProviderAPIKey model (api_key or vertex_ai)
- Implement Vertex AI OAuth token generation with service account
- Update transport layer to handle Vertex AI authentication
- Add Vertex AI endpoint URL generation in request builder
- Update frontend KeyFormDialog to support auth_type selection
- Add migration for auth_type column in provider_api_keys table
This commit is contained in:
fawney19
2026-01-30 02:43:50 +08:00
parent 3e75bc8964
commit 32b293ef3e
16 changed files with 956 additions and 65 deletions

View File

@@ -270,9 +270,15 @@ async def test_connection(
# 定义请求函数
async def test_request_func(_prov, endpoint, key, _candidate):
from src.api.handlers.base.request_builder import get_provider_auth
# 获取认证信息(处理 Service Account 等异步认证场景)
auth_info = await get_provider_auth(endpoint, key)
request_builder = PassthroughRequestBuilder()
provider_payload, provider_headers = request_builder.build(
payload, {}, endpoint, key, is_stream=False
payload, {}, endpoint, key, is_stream=False,
pre_computed_auth=auth_info.as_tuple() if auth_info else None,
)
url = build_provider_url(
@@ -280,6 +286,8 @@ async def test_connection(
query_params=dict(request.query_params),
path_params={"model": model},
is_stream=False,
key=key,
decrypted_auth_config=auth_info.decrypted_auth_config if auth_info else None,
)
async with httpx.AsyncClient(timeout=30.0, verify=get_ssl_context()) as client: