Skip to content

Commit e5549b2

Browse files
committed
Change service to sts and add content-length header for request
1 parent 06183ea commit e5549b2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/client/auth/aws.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,25 @@ async fn authenticate_stream_inner(
136136
);
137137

138138
let date = Utc::now();
139-
// Generate authorization header using original implementation without AWS SDK
140139

140+
// Generate authorization header using original implementation without AWS SDK
141141
// let authorization_header = aws_credential.compute_authorization_header(
142142
// date,
143143
// &server_first.sts_host,
144144
// &server_first.server_nonce,
145145
// )?;
146146

147+
// dbg!("authorization header: {}", &authorization_header);
148+
149+
// let mut client_second_payload = doc! {
150+
// "a": authorization_header,
151+
// "d": date.format(AWS_LONG_DATE_FMT).to_string(),
152+
// };
153+
154+
// if let Some(security_token) = aws_credential.session_token {
155+
// client_second_payload.insert("t", security_token);
156+
// }
157+
147158
let sigv4_headers = compute_aws_sigv4_headers(
148159
creds,
149160
date,
@@ -243,9 +254,9 @@ pub async fn compute_aws_sigv4_headers(
243254
};
244255

245256
let url = format!("https://{}", host);
246-
let service = "execute-api";
257+
let service = "sts";
247258
let body_str = "Action=GetCallerIdentity&Version=2011-06-15";
248-
// let body_bytes = body_str.as_bytes();
259+
let body_bytes = body_str.as_bytes();
249260
let nonce_b64 = base64::encode(server_nonce);
250261

251262
// Create the HTTP request
@@ -254,7 +265,7 @@ pub async fn compute_aws_sigv4_headers(
254265
.uri(&url)
255266
.header("host", host)
256267
.header("content-type", "application/x-www-form-urlencoded")
257-
// .header("content-length", body_bytes.len())
268+
.header("content-length", body_bytes.len())
258269
.header("x-amz-date", date_str.clone())
259270
.header("x-mongodb-gs2-cb-flag", "n")
260271
.header("x-mongodb-server-nonce", nonce_b64.clone());

0 commit comments

Comments
 (0)