Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Release dates use Australia/Brisbane time (UTC+10).

## [Unreleased]

### Changed

- Use dedicated Basic, Bearer, and API Key authentication fields, with a password
reveal toggle and Header / Query Params placement selector. Preserve imported
authentication settings while removing unsupported Inherit from new choices.

## [2.4.1] - 2026-11-03

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions crates/desktop/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ use gpui_kit::{
#[cfg(target_os = "macos")]
use gpui_kit::{Menu, MenuItem, OsAction, SystemMenuType};
use probe_core::{
AuthenticationKind, AuthenticationValue, Body, Environment, EnvironmentVariable, FileReference,
FormField, Header, ItemKind, MultipartPart, MultipartPartKind, MultipartValue, QueryParameter,
RawBodyKind, Request, RequestBody, RequestKey, SecretVariable, Variable, VariableValue,
VariableValueSet, WorkspaceItemRef, add_path_parameter, ensure_path_parameters_from_url,
AuthenticationKind, Body, Environment, EnvironmentVariable, FileReference, FormField, Header,
ItemKind, MultipartPart, MultipartPartKind, MultipartValue, QueryParameter, RawBodyKind,
Request, RequestBody, RequestKey, SecretVariable, Variable, VariableValue, VariableValueSet,
WorkspaceItemRef, add_path_parameter, ensure_path_parameters_from_url,
remove_path_parameter_at, rename_path_parameter_at, resolve_environment,
};
use probe_http::{ExecutionOptions, HttpError, HttpResponse};
Expand Down
211 changes: 98 additions & 113 deletions crates/desktop/src/app/render/request_editor/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ impl ProbeApp {
.map(|auth| auth_label(&auth.kind));
let choices = [
("None", None),
("Inherit", Some(AuthenticationKind::Inherit)),
("Basic", Some(AuthenticationKind::Basic)),
("Bearer", Some(AuthenticationKind::Bearer)),
("API Key", Some(AuthenticationKind::ApiKey)),
Expand All @@ -40,143 +39,129 @@ impl ProbeApp {
));
}

let mut editor = div()
let editor = div()
.flex()
.flex_col()
.gap(px(theme.metrics.spacing_2))
.child(kind_buttons);
let mut form = div()
.flex()
.flex_col()
.w_full()
.max_w(px(560.0 + 2.0 * theme.metrics.spacing_2))
.px(px(theme.metrics.spacing_2))
.gap(px(theme.metrics.spacing_2));
if let Some(authentication) = &request.authentication {
for (index, (property_name, value)) in authentication.properties.iter().enumerate() {
let old_name = property_name.clone();
let name_view = cx.weak_entity();
let value_name = property_name.clone();
let fields: &[(&str, &str)] = match authentication.kind {
AuthenticationKind::Basic => &[("username", "Username"), ("password", "Password")],
AuthenticationKind::Bearer => &[("token", "Token")],
AuthenticationKind::ApiKey => &[("key", "Key"), ("value", "Value")],
_ => &[],
};
for &(property, label) in fields {
let value_view = cx.weak_entity();
let remove_name = property_name.clone();
let remove_view = cx.weak_entity();
editor = editor.child(
components::editor_key_value_row(theme)
let value = authentication
.properties
.get(property)
.map(auth_value)
.unwrap_or_default();
form = form.child(
div()
.id(property)
.debug_selector(move || format!("authentication-{property}"))
.flex()
.flex_col()
.gap(px(theme.metrics.spacing_1))
.child(label)
.child(
div().flex_1().min_w(px(0.0)).child(
components::variable_text_input(
theme,
("authentication-property-name", index),
property_name.clone(),
"Property",
self.variable_context(cx),
move |value, _, input_cx| {
let old_name = old_name.clone();
let _ = name_view.update(input_cx, |view, cx| {
view.edit_request(
key,
|request| {
let Some(authentication) =
request.authentication.as_mut()
else {
return;
};
if let Some(old_value) =
authentication.properties.remove(&old_name)
{
authentication
.properties
.insert(value.to_string(), old_value);
}
},
cx,
);
});
},
)
.list_scroll(list_scroll),
),
)
components::variable_text_input(
theme,
SharedString::from(format!("authentication-{key:?}-{property}")),
value,
label,
self.variable_context(cx),
move |value, _, input_cx| {
let _ = value_view.update(input_cx, |view, cx| {
view.edit_request(
key,
|request| {
set_auth_property(
request,
property.to_owned(),
value.to_string(),
)
},
cx,
);
});
},
)
.password(property == "password")
.list_scroll(list_scroll),
),
);
}
if authentication.kind == AuthenticationKind::ApiKey {
let placement = authentication.properties.get("placement").map(auth_value);
let mut options = vec![
("header".to_owned(), "Header".to_owned()),
("query".to_owned(), "Query Params".to_owned()),
];
if let Some(value) = &placement
&& !matches!(value.as_str(), "header" | "query")
{
options.push((value.clone(), value.clone()));
}
let placement_view = cx.weak_entity();
form = form.child(
div()
.flex()
.flex_col()
.gap(px(theme.metrics.spacing_1))
.child("Add to")
.child(
div().flex_1().min_w(px(0.0)).child(
components::variable_text_input(
theme,
("authentication-property-value", index),
auth_value(value),
"Value",
self.variable_context(cx),
move |value, _, input_cx| {
let value_name = value_name.clone();
let _ = value_view.update(input_cx, |view, cx| {
components::dropdown(
theme,
"authentication-placement",
"Add to",
placement,
options,
180.0,
move |placement, _, cx| {
if let Some(placement) = placement {
let _ = placement_view.update(cx, |view, cx| {
view.edit_request(
key,
|request| {
set_auth_property(
request,
value_name,
value.to_string(),
"placement".to_owned(),
placement.clone(),
)
},
cx,
);
});
},
)
.list_scroll(list_scroll),
),
)
.child(components::remove_row_button(
theme,
("remove-authentication-property", index),
"Remove authentication property",
move |_, window, cx| {
let remove_name = remove_name.clone();
let _ = remove_view.update(cx, |view, cx| {
view.edit_request(
key,
|request| {
if let Some(authentication) =
request.authentication.as_mut()
{
authentication.properties.remove(&remove_name);
}
},
cx,
);
view.focus_handle.focus(window, cx);
});
},
)),
}
},
)
.placeholder("Not set"),
),
);
}
let add_view = cx.weak_entity();
editor = editor.child(components::editor_add_button(
theme,
"add-authentication-property",
"Add property",
move |_, _, cx| {
let _ = add_view.update(cx, |view, cx| {
view.edit_request(
key,
|request| {
let Some(authentication) = request.authentication.as_mut() else {
return;
};
let mut index = authentication.properties.len() + 1;
let mut name = "property".to_owned();
while authentication.properties.contains_key(&name) {
name = format!("property{index}");
index += 1;
}
authentication
.properties
.insert(name, AuthenticationValue::String(String::new()));
},
cx,
);
});
},
));
if fields.is_empty() {
form = form.child(div().text_color(theme.colors.text.muted).child(format!(
"{} authentication is not supported for execution. Imported configuration is preserved.",
auth_label(&authentication.kind),
)));
}
} else {
editor = editor.child(
form = form.child(
div()
.text_color(theme.colors.text.muted)
.child("This request does not use authentication."),
);
}
editor.into_any_element()
editor.child(form).into_any_element()
}
}
101 changes: 101 additions & 0 deletions crates/desktop/src/app/tests/editor_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,104 @@ fn websocket_variant_reload_resets_message_undo_but_keeps_composer(cx: &mut Test
})
.unwrap();
}

#[gpui_kit::test]
fn authentication_fields_map_edits_and_preserve_imported_properties(cx: &mut TestAppContext) {
use crate::request_editor::set_authentication;
use probe_core::{AuthenticationKind, AuthenticationValue as Value};

let (window, [http, _, _]) = editor_workspace(cx);
window
.update(cx, |view, _, cx| {
view.select_request(http, cx);
view.request_editor
.set_section(http, EditorSection::Authentication);
cx.notify();
})
.unwrap();
let imported = Value::Object(BTreeMap::from([(
"nested".to_owned(),
Value::Sequence(vec![Value::Boolean(true)]),
)]));
for (kind, fields) in [
(AuthenticationKind::Basic, vec!["username", "password"]),
(AuthenticationKind::Bearer, vec!["token"]),
(AuthenticationKind::ApiKey, vec!["key", "value"]),
] {
window
.update(cx, |view, _, cx| {
view.edit_request(
http,
|request| {
set_authentication(request, Some(kind.clone()));
request
.authentication
.as_mut()
.unwrap()
.properties
.insert("unsupported".to_owned(), imported.clone());
},
cx,
);
})
.unwrap();
cx.run_until_parked();
for field in &fields {
let mut visual = VisualTestContext::from_window(window.into(), cx);
let bounds = visual
.debug_bounds(match *field {
"username" => "authentication-username",
"password" => "authentication-password",
"token" => "authentication-token",
"key" => "authentication-key",
"value" => "authentication-value",
_ => unreachable!(),
})
.unwrap();
visual.simulate_click(
point(bounds.center().x, bounds.bottom() - px(12.0)),
Modifiers::default(),
);
cx.simulate_input(window.into(), &format!("{{{{{field}}}}}"));
cx.run_until_parked();
}
if kind == AuthenticationKind::ApiKey {
let mut visual = VisualTestContext::from_window(window.into(), cx);
let trigger = visual
.debug_bounds("authentication-placement-trigger")
.unwrap();
visual.simulate_click(trigger.center(), Modifiers::default());
cx.simulate_keystrokes(window.into(), "down enter");
cx.run_until_parked();
}
window
.update(cx, |view, _, cx| {
let auth = view
.active_request()
.unwrap()
.authentication
.as_ref()
.unwrap();
for field in &fields {
assert_eq!(
auth.properties[*field],
Value::String(format!("{{{{{field}}}}}"))
);
}
assert_eq!(auth.properties["unsupported"], imported);
if kind == AuthenticationKind::ApiKey {
assert_eq!(
auth.properties["placement"],
Value::String("query".to_owned())
);
}
let before = auth.clone();
view.edit_request(http, |request| set_authentication(request, Some(kind)), cx);
assert_eq!(
view.active_request().unwrap().authentication.as_ref(),
Some(&before)
);
})
.unwrap();
}
}
Loading
Loading