You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add AWS Bedrock API key (bearer token) authentication support
Fixes#41312
This adds support for AWS Bedrock API keys (bearer tokens) as an
authentication method. Users can now authenticate using:
- Traditional access keys (existing)
- Bearer tokens via ZED_AWS_BEARER_TOKEN_BEDROCK environment variable (new)
- Bearer tokens via UI input field (new)
Changes:
- Added bearer_token field to BedrockCredentials struct
- Added ZED_AWS_BEARER_TOKEN_BEDROCK environment variable constant
- Updated authentication logic to check for bearer tokens (read-only from ENV)
- Implemented BearerTokenProvider using AWS SDK's ResolveIdentity trait
- Modified client initialization to use token_provider when bearer token is present
- Enhanced UI with bearer token input field and updated instructions
- Updated all help text and tooltips to mention bearer token option
Bearer tokens are:
- Read from environment variables (never written)
- Stored in Zed's credential store when provided via UI
- Passed to AWS SDK using the proper token_provider configuration
Also includes fix for duplicate Region field (issue #41313).
References:
- AWS Bedrock API Key Documentation: https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-use.html
Co-authored-by: Ona <[email protected]>
format!("Access Key ID is set in {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, Secret Key is set in {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR}, Region is set in {ZED_BEDROCK_REGION_VAR} environment variables.")
1234
+
format!("Credentials are set via environment variables ({ZED_BEDROCK_ACCESS_KEY_ID_VAR}/{ZED_AWS_BEARER_TOKEN_BEDROCK} and {ZED_BEDROCK_REGION_VAR}).")
1173
1235
}else{
1174
1236
match bedrock_method {
1175
1237
Some(BedrockAuthMethod::Automatic) => "You are using automatic credentials".into(),
@@ -1188,7 +1250,7 @@ impl Render for ConfigurationView {
this.tooltip(Tooltip::text(format!("To reset your credentials, unset the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR}, and {ZED_BEDROCK_REGION_VAR} environment variables.")))
1253
+
this.tooltip(Tooltip::text(format!("To reset your credentials, unset the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}/{ZED_AWS_BEARER_TOKEN_BEDROCK} and {ZED_BEDROCK_REGION_VAR} environment variables.")))
1192
1254
})
1193
1255
.when(bedrock_method.is_some(), |this| {
1194
1256
this.tooltip(Tooltip::text("You cannot reset credentials as they're being derived, check Zed settings to understand how"))
@@ -1221,10 +1283,9 @@ impl Render for ConfigurationView {
1221
1283
)
1222
1284
)
1223
1285
.child(self.render_static_credentials_ui())
1224
-
.child(self.region_editor.clone())
1225
1286
.child(
1226
1287
Label::new(
1227
-
format!("You can also assign the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR} AND {ZED_BEDROCK_REGION_VAR} environment variables and restart Zed."),
1288
+
format!("You can also assign the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR} AND {ZED_BEDROCK_REGION_VAR} environment variables (or {ZED_AWS_BEARER_TOKEN_BEDROCK} for bearer token authentication) and restart Zed."),
1228
1289
)
1229
1290
.size(LabelSize::Small)
1230
1291
.color(Color::Muted)
@@ -1253,31 +1314,40 @@ impl ConfigurationView {
1253
1314
)
1254
1315
.child(
1255
1316
Label::new(
1256
-
"This method uses your AWS access key ID and secret access key directly.",
1317
+
"This method uses your AWS access key ID and secret access key, or a bearer token (API key).",
1257
1318
)
1258
1319
)
1259
1320
.child(
1260
1321
List::new()
1261
1322
.child(InstructionListItem::new(
1262
-
"Create an IAM user in the AWS console with programmatic access",
1323
+
"For access keys: Create an IAM user in the AWS console with programmatic access",
0 commit comments