Files
CLIProxyAPI/sdk/cliproxy/auth/credential_policy.go
Luis Pater 198a26737c feat(codex): add Alpha Search API key support with configurable endpoint
- 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
2026-08-01 00:31:26 +08:00

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
}
}