Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
language_models: Store Bedrock credentials under `https://amazonaws.com` in the keychain (#25565)
Marshall Bowers21fc3c07b6d2
diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rsindex c2b33216310..fe4ae044aab 100644--- a/crates/language_models/src/provider/bedrock.rs+++ b/crates/language_models/src/provider/bedrock.rs@@ -68,6 +68,12 @@ pub struct AvailableModel {pub default_temperature: Option<f32>,}+/// The URL of the base AWS service.+///+/// Right now we're just using this as the key to store the AWS credentials+/// under in the keychain.+const AMAZON_AWS_URL: &str = "https://amazonaws.com";+// These environment variables all use a `ZED_` prefix because we don't want to overwrite the user's AWS credentials.const ZED_BEDROCK_ACCESS_KEY_ID_VAR: &str = "ZED_ACCESS_KEY_ID";const ZED_BEDROCK_SECRET_ACCESS_KEY_VAR: &str = "ZED_SECRET_ACCESS_KEY";@@ -86,7 +92,7 @@ impl State {let credentials_provider = <dyn CredentialsProvider>::global(cx);cx.spawn(|this, mut cx| async move {credentials_provider- .delete_credentials(ZED_AWS_CREDENTIALS_VAR, &cx)+ .delete_credentials(AMAZON_AWS_URL, &cx).await.log_err();this.update(&mut cx, |this, cx| {@@ -106,7 +112,7 @@ impl State {cx.spawn(|this, mut cx| async move {credentials_provider.write_credentials(- ZED_AWS_CREDENTIALS_VAR,+ AMAZON_AWS_URL,"Bearer",&serde_json::to_vec(&credentials)?,&cx,@@ -135,7 +141,7 @@ impl State {(credentials, true)} else {let (_, credentials) = credentials_provider- .read_credentials(ZED_AWS_CREDENTIALS_VAR, &cx)+ .read_credentials(AMAZON_AWS_URL, &cx).await?.ok_or_else(|| AuthenticateError::CredentialsNotFound)?;(