|
1 | 1 | use std::{fs::File, io::Read, time::Duration};
|
2 | 2 |
|
3 | 3 | // Note: Uncomment the following lines for AWS SDK for authentication
|
4 |
| -// use aws_config::BehaviorVersion; |
5 |
| -// use aws_credential_types::provider::ProvideCredentials; |
6 |
| -// use aws_types::sdk_config::SharedCredentialsProvider; |
| 4 | +use aws_config::BehaviorVersion; |
| 5 | +use aws_credential_types::provider::ProvideCredentials; |
| 6 | +use aws_types::sdk_config::SharedCredentialsProvider; |
7 | 7 | use chrono::{offset::Utc, DateTime};
|
8 | 8 | use hmac::Hmac;
|
9 | 9 | use once_cell::sync::Lazy;
|
@@ -111,29 +111,21 @@ async fn authenticate_stream_inner(
|
111 | 111 | )
|
112 | 112 | } else {
|
113 | 113 | // If credentials are not provided in the URI, use the AWS SDK to load
|
114 |
| - // Note: Untested but compiles |
115 |
| - // let creds = aws_config::load_defaults(BehaviorVersion::latest()) |
116 |
| - // .await |
117 |
| - // .credentials_provider() |
118 |
| - // .expect("no credential provider configured") |
119 |
| - // .provide_credentials() |
120 |
| - // .await |
121 |
| - // .map_err(|e| { |
122 |
| - // Error::authentication_error(MECH_NAME, &format!("failed to get creds: {e}")) |
123 |
| - // })?; |
124 |
| - // AwsCredential::from_sdk_creds( |
125 |
| - // creds.access_key_id().to_string(), |
126 |
| - // creds.secret_access_key().to_string(), |
127 |
| - // creds.session_token().map(|s| s.to_string()), |
128 |
| - // None, |
129 |
| - // ) |
130 |
| - |
131 |
| - // For now, throw an error |
132 |
| - return Err(Error::authentication_error( |
133 |
| - MECH_NAME, |
134 |
| - "Credentials must be provided in the MongoDB URI - methods supported by the AWS SDK \ |
135 |
| - are not yet tested", |
136 |
| - )); |
| 114 | + let creds = aws_config::load_defaults(BehaviorVersion::latest()) |
| 115 | + .await |
| 116 | + .credentials_provider() |
| 117 | + .expect("no credential provider configured") |
| 118 | + .provide_credentials() |
| 119 | + .await |
| 120 | + .map_err(|e| { |
| 121 | + Error::authentication_error(MECH_NAME, &format!("failed to get creds: {e}")) |
| 122 | + })?; |
| 123 | + AwsCredential::from_sdk_creds( |
| 124 | + creds.access_key_id().to_string(), |
| 125 | + creds.secret_access_key().to_string(), |
| 126 | + creds.session_token().map(|s| s.to_string()), |
| 127 | + None, |
| 128 | + ) |
137 | 129 | };
|
138 | 130 | #[cfg(not(feature = "aws-sdk-auth"))]
|
139 | 131 | let aws_credential = {
|
|
0 commit comments