Skip to content

Commit 070b5b5

Browse files
committed
Merge branch 'main' into RUST-1529-aws-sdk-signature
2 parents 9c96dde + 65070c6 commit 070b5b5

File tree

100 files changed

+525
-748
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+525
-748
lines changed

.evergreen/check-clippy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o errexit
55
source ./.evergreen/env.sh
66

77
# Pin clippy to the latest version. This should be updated when new versions of Rust are released.
8-
CLIPPY_VERSION=1.85.0
8+
CLIPPY_VERSION=1.88.0
99

1010
rustup install $CLIPPY_VERSION
1111

Cargo.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ features = ["sync"]
5555
| `in-use-encryption` | Enable support for client-side field level encryption and queryable encryption. Note that re-exports from the `mongocrypt` crate may change in backwards-incompatible ways while that crate is below version 1.0. |
5656
| `tracing-unstable` | Enable support for emitting [`tracing`](https://docs.rs/tracing/latest/tracing/) events. This API is unstable and may be subject to breaking changes in minor releases. |
5757
| `compat-3-0-0` | Required for future compatibility if default features are disabled. |
58+
| `azure-oidc` | Enable support for Azure OIDC environment authentication. |
59+
| `gcp-oidc` | Enable support for GCP OIDC environment authentication. |
5860

5961
## Web Framework Examples
6062

src/action/insert_one.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<T: Serialize + Send + Sync> crate::sync::Collection<T> {
6060
}
6161
}
6262

63-
/// Inserts a document into a collection. Construct with ['Collection::insert_one`].
63+
/// Inserts a document into a collection. Construct with [`Collection::insert_one`].
6464
#[must_use]
6565
pub struct InsertOne<'a> {
6666
coll: CollRef<'a>,

src/action/search_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'a> Action for CreateSearchIndex<'a, Single> {
204204
.await?;
205205
match names.len() {
206206
1 => Ok(names.pop().unwrap()),
207-
n => Err(Error::internal(format!("expected 1 index name, got {}", n))),
207+
n => Err(Error::internal(format!("expected 1 index name, got {n}"))),
208208
}
209209
}
210210
}

src/bson_util.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ pub(crate) fn extend_raw_document_buf(
196196
for result in other.iter() {
197197
let (k, v) = result?;
198198
if keys.contains(k) {
199-
return Err(Error::internal(format!(
200-
"duplicate raw document key {:?}",
201-
k
202-
)));
199+
return Err(Error::internal(format!("duplicate raw document key {k:?}")));
203200
}
204201
this.append(k, v.to_raw_bson());
205202
}

src/checked.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<T> Checked<T> {
4343
value
4444
.try_into()
4545
.map(|v| Self(Some(v)))
46-
.map_err(|e| crate::error::Error::invalid_argument(format! {"{}", e}))
46+
.map_err(|e| crate::error::Error::invalid_argument(format! {"{e}"}))
4747
}
4848

4949
pub fn get(self) -> crate::error::Result<T> {
@@ -58,7 +58,7 @@ impl<T> Checked<T> {
5858
{
5959
self.get().and_then(|v| {
6060
v.try_into()
61-
.map_err(|e| crate::error::Error::invalid_argument(format!("{}", e)))
61+
.map_err(|e| crate::error::Error::invalid_argument(format!("{e}")))
6262
})
6363
}
6464
}

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl Client {
556556
state
557557
.servers()
558558
.keys()
559-
.map(|stream_address| format!("{}", stream_address))
559+
.map(|stream_address| format!("{stream_address}"))
560560
.collect()
561561
}
562562

src/client/auth.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
pub(crate) mod aws;
66
#[cfg(feature = "gssapi-auth")]
77
mod gssapi;
8-
/// Contains the functionality for [`OIDC`](https://openid.net/developers/how-connect-works/) authorization and authentication.
98
pub mod oidc;
109
mod plain;
1110
mod sasl;
@@ -350,24 +349,21 @@ impl AuthMechanism {
350349
| AuthMechanism::Plain
351350
| AuthMechanism::MongoDbCr => Err(ErrorKind::Authentication {
352351
message: format!(
353-
"Reauthentication for authentication mechanism {:?} is not supported.",
354-
self
352+
"Reauthentication for authentication mechanism {self:?} is not supported."
355353
),
356354
}
357355
.into()),
358356
#[cfg(feature = "gssapi-auth")]
359357
AuthMechanism::Gssapi => Err(ErrorKind::Authentication {
360358
message: format!(
361-
"Reauthentication for authentication mechanism {:?} is not supported.",
362-
self
359+
"Reauthentication for authentication mechanism {self:?} is not supported."
363360
),
364361
}
365362
.into()),
366363
#[cfg(feature = "aws-auth")]
367364
AuthMechanism::MongoDbAws => Err(ErrorKind::Authentication {
368365
message: format!(
369-
"Reauthentication for authentication mechanism {:?} is not supported.",
370-
self
366+
"Reauthentication for authentication mechanism {self:?} is not supported."
371367
),
372368
}
373369
.into()),
@@ -407,7 +403,7 @@ impl FromStr for AuthMechanism {
407403
.into()),
408404

409405
_ => Err(ErrorKind::InvalidArgument {
410-
message: format!("invalid mechanism string: {}", str),
406+
message: format!("invalid mechanism string: {str}"),
411407
}
412408
.into()),
413409
}

src/client/auth/aws.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl AwsCredential {
482482
/// Obtains credentials from the ECS endpoint.
483483
async fn get_from_ecs(relative_uri: String, http_client: &HttpClient) -> Result<Self> {
484484
// Use the local IP address that AWS uses for ECS agents.
485-
let uri = format!("http://{}/{}", AWS_ECS_IP, relative_uri);
485+
let uri = format!("http://{AWS_ECS_IP}/{relative_uri}");
486486

487487
http_client
488488
.get(&uri)
@@ -494,16 +494,14 @@ impl AwsCredential {
494494
/// Obtains temporary credentials for an EC2 instance to use for authentication.
495495
async fn get_from_ec2(http_client: &HttpClient) -> Result<Self> {
496496
let temporary_token = http_client
497-
.put(format!("http://{}/latest/api/token", AWS_EC2_IP))
497+
.put(format!("http://{AWS_EC2_IP}/latest/api/token"))
498498
.headers(&[("X-aws-ec2-metadata-token-ttl-seconds", "30")])
499499
.send_and_get_string()
500500
.await
501501
.map_err(|_| Error::unknown_authentication_error(MECH_NAME))?;
502502

503-
let role_name_uri = format!(
504-
"http://{}/latest/meta-data/iam/security-credentials/",
505-
AWS_EC2_IP
506-
);
503+
let role_name_uri =
504+
format!("http://{AWS_EC2_IP}/latest/meta-data/iam/security-credentials/");
507505

508506
let role_name = http_client
509507
.get(&role_name_uri)
@@ -512,7 +510,7 @@ impl AwsCredential {
512510
.await
513511
.map_err(|_| Error::unknown_authentication_error(MECH_NAME))?;
514512

515-
let credential_uri = format!("{}/{}", role_name_uri, role_name);
513+
let credential_uri = format!("{role_name_uri}/{role_name}");
516514

517515
http_client
518516
.get(&credential_uri)
@@ -537,7 +535,7 @@ impl AwsCredential {
537535
let token = self
538536
.session_token
539537
.as_ref()
540-
.map(|s| format!("x-amz-security-token:{}\n", s))
538+
.map(|s| format!("x-amz-security-token:{s}\n"))
541539
.unwrap_or_default();
542540

543541
// Similarly, we need to put "x-amz-security-token" into the list of signed headers if the
@@ -560,7 +558,6 @@ impl AwsCredential {
560558
x-mongodb-gs2-cb-flag;\
561559
x-mongodb-server-nonce\
562560
",
563-
token_signed_header = token_signed_header,
564561
);
565562

566563
let body = "Action=GetCallerIdentity&Version=2011-06-15";
@@ -576,19 +573,13 @@ impl AwsCredential {
576573
content-length:43\n\
577574
content-type:application/x-www-form-urlencoded\n\
578575
host:{host}\n\
579-
x-amz-date:{date}\n\
576+
x-amz-date:{date_str}\n\
580577
{token}\
581578
x-mongodb-gs2-cb-flag:n\n\
582579
x-mongodb-server-nonce:{nonce}\n\n\
583580
{signed_headers}\n\
584581
{hashed_body}\
585582
",
586-
host = host,
587-
date = date_str,
588-
token = token,
589-
nonce = nonce,
590-
signed_headers = signed_headers,
591-
hashed_body = hashed_body,
592583
);
593584

594585
let hashed_request = hex::encode(Sha256::digest(request.as_bytes()));
@@ -606,14 +597,10 @@ impl AwsCredential {
606597
let string_to_sign = format!(
607598
"\
608599
AWS4-HMAC-SHA256\n\
609-
{full_date}\n\
600+
{date_str}\n\
610601
{small_date}/{region}/sts/aws4_request\n\
611602
{hashed_request}\
612603
",
613-
full_date = date_str,
614-
small_date = small_date,
615-
region = region,
616-
hashed_request = hashed_request,
617604
);
618605

619606
let first_hmac_key = format!("AWS4{}", self.secret_access_key);

0 commit comments

Comments
 (0)