diff --git a/src-tauri/yaak-ws/src/commands.rs b/src-tauri/yaak-ws/src/commands.rs index 11429a45..270ebfae 100644 --- a/src-tauri/yaak-ws/src/commands.rs +++ b/src-tauri/yaak-ws/src/commands.rs @@ -226,30 +226,38 @@ pub(crate) async fn connect( ); } - if let Some(auth_name) = authentication_type.clone() { - let auth = authentication.clone(); - let plugin_req = CallHttpAuthenticationRequest { - context_id: format!("{:x}", md5::compute(request_id.to_string())), - values: serde_json::from_value(serde_json::to_value(&auth).unwrap()).unwrap(), - method: "POST".to_string(), - url: request.url.clone(), - headers: request - .headers - .clone() - .into_iter() - .map(|h| HttpHeader { - name: h.name, - value: h.value, - }) - .collect(), - }; - let plugin_result = - plugin_manager.call_http_authentication(&window, &auth_name, plugin_req).await?; - for header in plugin_result.set_headers { - headers.insert( - HeaderName::from_str(&header.name).unwrap(), - HeaderValue::from_str(&header.value).unwrap(), - ); + match authentication_type { + None => { + // No authentication found. Not even inherited + } + Some(authentication_type) if authentication_type == "none" => { + // Explicitly no authentication + } + Some(authentication_type) => { + let auth = authentication.clone(); + let plugin_req = CallHttpAuthenticationRequest { + context_id: format!("{:x}", md5::compute(request_id.to_string())), + values: serde_json::from_value(serde_json::to_value(&auth).unwrap()).unwrap(), + method: "POST".to_string(), + url: request.url.clone(), + headers: request + .headers + .clone() + .into_iter() + .map(|h| HttpHeader { + name: h.name, + value: h.value, + }) + .collect(), + }; + let plugin_result = + plugin_manager.call_http_authentication(&window, &authentication_type, plugin_req).await?; + for header in plugin_result.set_headers { + headers.insert( + HeaderName::from_str(&header.name).unwrap(), + HeaderValue::from_str(&header.value).unwrap(), + ); + } } }