feat(auth): add proxy URL override support to auth constructors and executors

- Introduced `WithProxyURL` variants for `CodexAuth`, `ClaudeAuth`, `IFlowAuth`, and `DeviceFlowClient`.
- Updated executors to use proxy-aware constructors for improved configurability.
- Added unit tests to validate proxy override precedence and functionality.

Closes: #2823
This commit is contained in:
Luis Pater
2026-04-16 22:11:39 +08:00
parent 7b03f04670
commit d949921143
12 changed files with 226 additions and 9 deletions
+16 -1
View File
@@ -48,8 +48,23 @@ type IFlowAuth struct {
// NewIFlowAuth constructs a new IFlowAuth with proxy-aware transport.
func NewIFlowAuth(cfg *config.Config) *IFlowAuth {
return NewIFlowAuthWithProxyURL(cfg, "")
}
// NewIFlowAuthWithProxyURL constructs a new IFlowAuth with a proxy override.
// proxyURL takes precedence over cfg.ProxyURL when non-empty.
func NewIFlowAuthWithProxyURL(cfg *config.Config, proxyURL string) *IFlowAuth {
client := &http.Client{Timeout: 30 * time.Second}
return &IFlowAuth{httpClient: util.SetProxy(&cfg.SDKConfig, client)}
effectiveProxyURL := strings.TrimSpace(proxyURL)
var sdkCfg config.SDKConfig
if cfg != nil {
sdkCfg = cfg.SDKConfig
if effectiveProxyURL == "" {
effectiveProxyURL = strings.TrimSpace(cfg.ProxyURL)
}
}
sdkCfg.ProxyURL = effectiveProxyURL
return &IFlowAuth{httpClient: util.SetProxy(&sdkCfg, client)}
}
// AuthorizationURL builds the authorization URL and matching redirect URI.