"frontend/vscode:/vscode.git/clone" did not exist on "a087f089b8da920c4fec54e85c6178701cb6b67e"
Commit bba5b3c0 authored by cyhhao's avatar cyhhao
Browse files

fix(网关): OAuth 请求统一 user_id 与指纹

parent 26298c4a
......@@ -2904,7 +2904,7 @@ func (s *GatewayService) buildUpstreamRequest(ctx context.Context, c *gin.Contex
// OAuth账号:应用统一指纹
var fingerprint *Fingerprint
if account.IsOAuth() && mimicClaudeCode && s.identityService != nil {
if account.IsOAuth() && s.identityService != nil {
// 1. 获取或创建指纹(包含随机生成的ClientID)
fp, err := s.identityService.GetOrCreateFingerprint(ctx, account.ID, c.Request.Header)
if err != nil {
......@@ -2957,7 +2957,7 @@ func (s *GatewayService) buildUpstreamRequest(ctx context.Context, c *gin.Contex
if req.Header.Get("anthropic-version") == "" {
req.Header.Set("anthropic-version", "2023-06-01")
}
if tokenType == "oauth" && mimicClaudeCode {
if tokenType == "oauth" {
applyClaudeOAuthHeaderDefaults(req, reqStream)
}
......@@ -4257,7 +4257,7 @@ func (s *GatewayService) buildCountTokensRequest(ctx context.Context, c *gin.Con
}
// OAuth 账号:应用统一指纹和重写 userID
if account.IsOAuth() && mimicClaudeCode && s.identityService != nil {
if account.IsOAuth() && s.identityService != nil {
fp, err := s.identityService.GetOrCreateFingerprint(ctx, account.ID, c.Request.Header)
if err == nil {
accountUUID := account.GetExtraString("account_uuid")
......@@ -4292,7 +4292,7 @@ func (s *GatewayService) buildCountTokensRequest(ctx context.Context, c *gin.Con
}
// OAuth 账号:应用指纹到请求头
if account.IsOAuth() && mimicClaudeCode && s.identityService != nil {
if account.IsOAuth() && s.identityService != nil {
fp, _ := s.identityService.GetOrCreateFingerprint(ctx, account.ID, c.Request.Header)
if fp != nil {
s.identityService.ApplyFingerprint(req, fp)
......@@ -4306,7 +4306,7 @@ func (s *GatewayService) buildCountTokensRequest(ctx context.Context, c *gin.Con
if req.Header.Get("anthropic-version") == "" {
req.Header.Set("anthropic-version", "2023-06-01")
}
if tokenType == "oauth" && mimicClaudeCode {
if tokenType == "oauth" {
applyClaudeOAuthHeaderDefaults(req, false)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment