mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-11-17 15:20:55 +08:00
- Introduced `alpha-search` flag for Codex API keys to enable Alpha Search functionality. - Added `CredentialPolicyCodexAlphaSearchV1` for filtering and validating API keys compatible with Alpha Search. - Extended configuration, synthesizer, and watcher functionality to track and manage `alpha-search` flag changes. - Updated Codex executor to dynamically construct Alpha Search endpoint based on API key attributes. - Enhanced tests to validate Alpha Search flag handling, endpoint construction, and credential filtering. Closes: #4692
40 lines
897 B
Go
40 lines
897 B
Go
package auth
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
// CredentialPolicyCodexAlphaSearchV1 selects credentials supported by Codex Alpha Search.
|
|
CredentialPolicyCodexAlphaSearchV1 = "codex_alpha_search_v1"
|
|
)
|
|
|
|
func normalizeCredentialPolicy(policy string) string {
|
|
switch strings.ToLower(strings.TrimSpace(policy)) {
|
|
case CredentialPolicyCodexAlphaSearchV1:
|
|
return CredentialPolicyCodexAlphaSearchV1
|
|
default:
|
|
return ""
|
|
}
|
|
}
|
|
|
|
func credentialPolicyAllows(policy string, auth *Auth) bool {
|
|
if auth == nil {
|
|
return false
|
|
}
|
|
switch policy {
|
|
case CredentialPolicyCodexAlphaSearchV1:
|
|
if !strings.EqualFold(strings.TrimSpace(auth.Provider), "codex") {
|
|
return false
|
|
}
|
|
switch auth.AuthKind() {
|
|
case AuthKindOAuth:
|
|
return true
|
|
case AuthKindAPIKey:
|
|
return strings.EqualFold(authAttribute(auth, AttributeCodexAlphaSearch), "true")
|
|
default:
|
|
return false
|
|
}
|
|
default:
|
|
return false
|
|
}
|
|
}
|