mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
* fix(secrets): verify provider API request and payload contracts * wip * fix(secrets): unify backend reads and route secret resolution * feat(secrets): bind built-in managers to retained Rust backends * refactor(secrets): centralize catalog dispatch and native binding * test(secrets): split provider integration tests * refactor(secrets): enforce cache and rotation contracts * test(secrets): stub parent packages in failing resolver fixture Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(secrets): pass manager settings through the interop boundary Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): align cloud KMS auth and harden provider reads * ci(rust): raise native wheel size gate to 40 MB for secrets backends Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): treat unset google kms flag as disabled like the old loader Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): preserve certificate credentials and disabled KMS flags * test(secrets): cover certificate validation and bounded auth retries * test(secrets): cover Python dispatch without the native extension * test(proxy): skip legacy secret manager cases when the optional SDK is missing Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): port Python parity tests and preserve provider behavior * fix(secrets): store the captured native config without setattr to satisfy the strict lint budget Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): preserve missing Azure manager values Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(secrets): pin typed values and recovery failure precedence * refactor(secrets): organize provider internals and behavioral test suites * refactor(secrets): simplify recovery and isolate Python compatibility * fix(secrets): distinguish Azure callback absence from HTTP not found * fix(secrets): preserve Python AWS read results at the bridge * fix(secrets): route public reads through the native catalog bridge * fix(secrets): keep JSON selection outside the bridge Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): preserve provider JSON reads at the bridge Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): preserve Python primary JSON semantics Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(secrets): preserve CyberArk mutation behavior through the native bridge * docs(secrets): record public API replacement gaps * refactor(secrets): share Vault write payload preparation * feat(secrets): route Vault mutations through the native bridge * fix(secrets): preserve typed Vault rotation failures * refactor(secrets): move Python dispatch into bridge * refactor(secrets): move CyberArk Python policy into bridge * refactor(secrets): move Vault Python policy into bridge * test(secrets): assert Vault rotation request paths * fix(secrets): keep bridge JSON interop centralized Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Yujong Lee <yujong@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
82 lines
2.8 KiB
Rust
82 lines
2.8 KiB
Rust
use litellm_core_utils::settings::Lookup;
|
|
use litellm_python_compat::{Value, literal::literal_eval};
|
|
use litellm_secrets_types::PythonSecretRead;
|
|
|
|
use crate::{
|
|
Error, KeyManagementSettings, KeyManagementSystem, Secret, SecretManager, SecretValue,
|
|
get_secret_from_manager,
|
|
};
|
|
|
|
pub async fn get_secret_from_python_manager(
|
|
manager: &SecretManager,
|
|
name: &str,
|
|
settings: &KeyManagementSettings,
|
|
environment: &(dyn Lookup + Send + Sync),
|
|
) -> Result<Option<Secret>, Error> {
|
|
#[cfg(feature = "aws")]
|
|
if let SecretManager::AwsSecretsManagerV2(client) = manager {
|
|
return client
|
|
.read_secret_for_python(name, settings.primary_secret_name.as_deref(), environment)
|
|
.await
|
|
.map_err(Error::from);
|
|
}
|
|
let result = match manager {
|
|
#[cfg(feature = "cyberark")]
|
|
SecretManager::Cyberark(client) => Ok(client
|
|
.read_with_retry(
|
|
name,
|
|
&Default::default(),
|
|
litellm_secrets_cyberark::AuthenticationRetry::Never,
|
|
)
|
|
.await
|
|
.unwrap_or(None)
|
|
.map(Secret::String)),
|
|
#[cfg(feature = "google")]
|
|
SecretManager::GoogleSecretManager(client) => client
|
|
.get_secret_for_python(name)
|
|
.await
|
|
.map_err(Error::from),
|
|
_ => get_secret_from_manager(manager, name, settings, environment).await,
|
|
};
|
|
match result {
|
|
#[cfg(feature = "google")]
|
|
Err(Error::Google(litellm_secrets_google::Error::Status(404))) => {
|
|
Err(Error::ManagedSecretMissing)
|
|
}
|
|
#[cfg(feature = "azure")]
|
|
Err(Error::Azure(litellm_secrets_azure::Error::MissingValue)) => Ok(None),
|
|
Ok(None)
|
|
if matches!(manager, SecretManager::External(_))
|
|
&& manager.system() == KeyManagementSystem::AzureKeyVault =>
|
|
{
|
|
Ok(None)
|
|
}
|
|
Ok(None) => Err(Error::ManagedSecretMissing),
|
|
result => result,
|
|
}
|
|
}
|
|
|
|
pub(crate) fn python_manager_string(value: SecretValue) -> Secret {
|
|
match literal_eval(value.expose()) {
|
|
Ok(Value::Bool(boolean)) => Secret::Bool(boolean),
|
|
_ => Secret::String(value),
|
|
}
|
|
}
|
|
|
|
pub async fn read_secret_from_python_manager(
|
|
manager: &SecretManager,
|
|
name: &str,
|
|
settings: &KeyManagementSettings,
|
|
environment: &(dyn Lookup + Send + Sync),
|
|
) -> Result<PythonSecretRead, Error> {
|
|
#[cfg(feature = "aws")]
|
|
if let SecretManager::AwsSecretsManagerV2(client) = manager {
|
|
return client
|
|
.read_payload_for_python(name, settings.primary_secret_name.as_deref(), environment)
|
|
.await
|
|
.map_err(Error::from);
|
|
}
|
|
get_secret_from_python_manager(manager, name, settings, environment)
|
|
.await
|
|
.map(PythonSecretRead::Value)
|
|
}
|