Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
39
backend/sdk/cliproxy/auth/credential_policy.go
Normal file
39
backend/sdk/cliproxy/auth/credential_policy.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue