Merge pull request #137 from geen02/fix/idc-auth-method-case-sensitivity

fix: case-insensitive auth_method comparison for IDC tokens
This commit is contained in:
Luis Pater
2026-01-27 20:38:03 +08:00
committed by GitHub
2 changed files with 8 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package kiro
import (
"context"
"log"
"strings"
"sync"
"time"
@@ -58,7 +59,7 @@ type BackgroundRefresher struct {
wg sync.WaitGroup
oauth *KiroOAuth
ssoClient *SSOOIDCClient
callbackMu sync.RWMutex // 保护回调函数的并发访问
callbackMu sync.RWMutex // 保护回调函数的并发访问
onTokenRefreshed func(tokenID string, tokenData *KiroTokenData) // 刷新成功回调
}
@@ -163,7 +164,10 @@ func (r *BackgroundRefresher) refreshSingle(ctx context.Context, token *Token) {
var newTokenData *KiroTokenData
var err error
switch token.AuthMethod {
// Normalize auth method to lowercase for case-insensitive matching
authMethod := strings.ToLower(token.AuthMethod)
switch authMethod {
case "idc":
newTokenData, err = r.ssoClient.RefreshTokenWithRegion(
ctx,

View File

@@ -187,8 +187,9 @@ func (r *FileTokenRepository) readTokenFile(path string) (*Token, error) {
return nil, nil
}
// 检查 auth_method
// 检查 auth_method (case-insensitive comparison to handle "IdC", "IDC", "idc", etc.)
authMethod, _ := metadata["auth_method"].(string)
authMethod = strings.ToLower(authMethod)
if authMethod != "idc" && authMethod != "builder-id" {
return nil, nil // 只处理 IDC 和 Builder ID token
}