From 4d80c8d9930c1b8b0d7533f83e9fe14d73e3e291 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 3 Feb 2025 12:53:11 -0800 Subject: [PATCH] Actually handle "enabled" checkbox on auth form --- src-tauri/yaak-plugins/src/manager.rs | 38 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src-tauri/yaak-plugins/src/manager.rs b/src-tauri/yaak-plugins/src/manager.rs index 31aa60fb..0419c000 100644 --- a/src-tauri/yaak-plugins/src/manager.rs +++ b/src-tauri/yaak-plugins/src/manager.rs @@ -534,19 +534,18 @@ impl PluginManager { .ok_or(PluginNotFoundErr(auth_name.into()))?; let context_id = format!("{:x}", md5::compute(request_id.to_string())); - self - .send_to_plugin_and_wait( - &WindowContext::from_window(window), - &plugin, - &InternalEventPayload::CallHttpAuthenticationActionRequest( - CallHttpAuthenticationActionRequest { - index: action_index, - plugin_ref_id: plugin.clone().ref_id, - args: CallHttpAuthenticationActionArgs { context_id, values }, - }, - ), - ) - .await?; + self.send_to_plugin_and_wait( + &WindowContext::from_window(window), + &plugin, + &InternalEventPayload::CallHttpAuthenticationActionRequest( + CallHttpAuthenticationActionRequest { + index: action_index, + plugin_ref_id: plugin.clone().ref_id, + args: CallHttpAuthenticationActionArgs { context_id, values }, + }, + ), + ) + .await?; Ok(()) } @@ -556,6 +555,19 @@ impl PluginManager { auth_name: &str, req: CallHttpAuthenticationRequest, ) -> Result { + let disabled = match req.values.get("disabled") { + Some(JsonPrimitive::Boolean(v)) => v.clone(), + _ => false, + }; + + // Auth is disabled, so don't do anything + if disabled { + info!("Not applying disabled auth {:?}", auth_name); + return Ok(CallHttpAuthenticationResponse { + set_headers: Vec::new(), + }); + } + let handlers = self.get_http_authentication_summaries(window).await?; let (plugin, _) = handlers .iter()