"backend/git@web.lueluesay.top:chenxi/sub2api.git" did not exist on "8fb7d476b8fe10e74cdc2784029c0e8b88e33118"
Commit 49be9d08 authored by cyhhao's avatar cyhhao
Browse files

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

parent 02db4c76
......@@ -2759,7 +2759,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 {
......@@ -2812,7 +2812,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)
}
......@@ -4112,7 +4112,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")
......@@ -4147,7 +4147,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)
......@@ -4161,7 +4161,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