mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-25 04:44:12 +02:00
fix: AWS4 authentication method didn't sign request body (#430)
Co-authored-by: Gregory Schier <gschier1990@gmail.com>
This commit is contained in:
co-authored by
Gregory Schier
parent
2383f06e71
commit
68671377fd
@@ -80,6 +80,7 @@ pub(crate) async fn build_metadata<R: Runtime>(
|
|||||||
value: value.to_string(),
|
value: value.to_string(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
body: None,
|
||||||
};
|
};
|
||||||
let plugin_result = plugin_manager
|
let plugin_result = plugin_manager
|
||||||
.call_http_authentication(
|
.call_http_authentication(
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ pub async fn cmd_ws_connect<R: Runtime>(
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|h| HttpHeader { name: h.name, value: h.value })
|
.map(|h| HttpHeader { name: h.name, value: h.value })
|
||||||
.collect(),
|
.collect(),
|
||||||
|
body: None,
|
||||||
};
|
};
|
||||||
let plugin_result = plugin_manager
|
let plugin_result = plugin_manager
|
||||||
.call_http_authentication(
|
.call_http_authentication(
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ export type CallHttpAuthenticationActionArgs = { contextId: string, values: { [k
|
|||||||
|
|
||||||
export type CallHttpAuthenticationActionRequest = { index: number, pluginRefId: string, args: CallHttpAuthenticationActionArgs, };
|
export type CallHttpAuthenticationActionRequest = { index: number, pluginRefId: string, args: CallHttpAuthenticationActionArgs, };
|
||||||
|
|
||||||
export type CallHttpAuthenticationRequest = { contextId: string, values: { [key in string]?: JsonPrimitive }, method: string, url: string, headers: Array<HttpHeader>, };
|
export type CallHttpAuthenticationRequest = { contextId: string, values: { [key in string]?: JsonPrimitive }, method: string, url: string, headers: Array<HttpHeader>, body: string | null, };
|
||||||
|
|
||||||
export type CallHttpAuthenticationResponse = {
|
export type CallHttpAuthenticationResponse = {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -746,6 +746,7 @@ pub struct CallHttpAuthenticationRequest {
|
|||||||
pub method: String,
|
pub method: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub headers: Vec<HttpHeader>,
|
pub headers: Vec<HttpHeader>,
|
||||||
|
pub body: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ use yaak_tls::find_client_certificate;
|
|||||||
const HTTP_EVENT_CHANNEL_CAPACITY: usize = 100;
|
const HTTP_EVENT_CHANNEL_CAPACITY: usize = 100;
|
||||||
const REQUEST_BODY_CHUNK_SIZE: usize = 1024 * 1024;
|
const REQUEST_BODY_CHUNK_SIZE: usize = 1024 * 1024;
|
||||||
const RESPONSE_PROGRESS_UPDATE_INTERVAL_MS: u128 = 100;
|
const RESPONSE_PROGRESS_UPDATE_INTERVAL_MS: u128 = 100;
|
||||||
|
const MAX_AUTH_BODY_BYTES: usize = 10 * 1024 * 1024;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum SendHttpRequestError {
|
pub enum SendHttpRequestError {
|
||||||
@@ -1086,6 +1087,17 @@ pub async fn apply_plugin_authentication(
|
|||||||
value: value.to_string(),
|
value: value.to_string(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
body: match &sendable_request.body {
|
||||||
|
// Bodies above the cap are not passed to auth plugins. Copying
|
||||||
|
// them across the plugin IPC is too expensive, and payloads that
|
||||||
|
// large are usually uploads that signing schemes treat as
|
||||||
|
// unsigned anyway. Streamed bodies (files, multipart) are never
|
||||||
|
// passed for the same reason.
|
||||||
|
Some(SendableBody::Bytes(bytes)) if bytes.len() <= MAX_AUTH_BODY_BYTES => {
|
||||||
|
String::from_utf8(bytes.to_vec()).ok()
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let plugin_result = plugin_manager
|
let plugin_result = plugin_manager
|
||||||
.call_http_authentication(plugin_context, authentication_type, req)
|
.call_http_authentication(plugin_context, authentication_type, req)
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ export type CallHttpAuthenticationActionArgs = { contextId: string, values: { [k
|
|||||||
|
|
||||||
export type CallHttpAuthenticationActionRequest = { index: number, pluginRefId: string, args: CallHttpAuthenticationActionArgs, };
|
export type CallHttpAuthenticationActionRequest = { index: number, pluginRefId: string, args: CallHttpAuthenticationActionArgs, };
|
||||||
|
|
||||||
export type CallHttpAuthenticationRequest = { contextId: string, values: { [key in string]?: JsonPrimitive }, method: string, url: string, headers: Array<HttpHeader>, };
|
export type CallHttpAuthenticationRequest = { contextId: string, values: { [key in string]?: JsonPrimitive }, method: string, url: string, headers: Array<HttpHeader>, body: string | null, };
|
||||||
|
|
||||||
export type CallHttpAuthenticationResponse = {
|
export type CallHttpAuthenticationResponse = {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export const plugin: PluginDefinition = {
|
|||||||
service: String(values.service || "sts"),
|
service: String(values.service || "sts"),
|
||||||
region: values.region ? String(values.region) : undefined,
|
region: values.region ? String(values.region) : undefined,
|
||||||
headers,
|
headers,
|
||||||
|
body: args.body ?? undefined,
|
||||||
doNotEncodePath: true,
|
doNotEncodePath: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user