From 42ee6a41c992fe46edcd9277310238199ebd30dd Mon Sep 17 00:00:00 2001 From: Mason Gup Date: Mon, 30 Jun 2025 15:24:31 -0400 Subject: [PATCH 1/4] Use Rust improvements --- src/config.rs | 2 +- src/validate_incoming.rs | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/config.rs b/src/config.rs index dfcded8..9832735 100644 --- a/src/config.rs +++ b/src/config.rs @@ -124,7 +124,7 @@ impl From for ConfigReadError { fn from(err: mauth_core::error::Error) -> ConfigReadError { match err { mauth_core::error::Error::PrivateKeyDecodeError(pkey_err) => { - ConfigReadError::PrivateKeyDecodeError(format!("{}", pkey_err)) + ConfigReadError::PrivateKeyDecodeError(format!("{pkey_err}")) } _ => panic!("should not be possible to get this error type from signer construction"), } diff --git a/src/validate_incoming.rs b/src/validate_incoming.rs index 2077765..a99cefd 100644 --- a/src/validate_incoming.rs +++ b/src/validate_incoming.rs @@ -259,22 +259,16 @@ impl MAuthInfo { match mauth_response { Err(_) => None, Ok(response) => { - if let Ok(response_obj) = response.json::().await { - if let Some(pub_key_str) = response_obj + if let Ok(response_obj) = response.json::().await + && let Some(pub_key_str) = response_obj .pointer("/security_token/public_key_str") .and_then(|s| s.as_str()) .map(|st| st.to_owned()) - { - if let Ok(verifier) = Verifier::new(*app_uuid, pub_key_str) { - let mut key_store = PUBKEY_CACHE.write().unwrap(); - key_store.insert(*app_uuid, verifier.clone()); - Some(verifier) - } else { - None - } - } else { - None - } + && let Ok(verifier) = Verifier::new(*app_uuid, pub_key_str) + { + let mut key_store = PUBKEY_CACHE.write().unwrap(); + key_store.insert(*app_uuid, verifier.clone()); + Some(verifier) } else { None } From 0309153004a5b0ad74b03f43626c74284f77c44d Mon Sep 17 00:00:00 2001 From: Mason Gup Date: Mon, 30 Jun 2025 15:33:35 -0400 Subject: [PATCH 2/4] Bump to newer versions, support newer otel --- Cargo.toml | 8 +++++--- README.md | 2 +- src/config.rs | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a2555c..f73516d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,17 +15,17 @@ categories = ["authentication", "web-programming"] [dependencies] reqwest = { version = "0.12", features = ["json"] } reqwest-middleware = "0.4" -reqwest-tracing = { version = "0.5.6", optional = true } +reqwest-tracing = { version = "0.5.8", optional = true } async-trait = ">= 0.1.83" url = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" -serde_yml = "0.0.10" +serde_yml = ">= 0.0.10" uuid = { version = "1", features = ["v4"] } dirs = "5" chrono = "0.4" tokio = { version = "1", features = ["fs"] } -tower = { version = "0.4", optional = true } +tower = { version = ">= 0.4", optional = true } axum = { version = ">= 0.8", optional = true } futures-core = { version = "0.3", optional = true } http = "1" @@ -42,3 +42,5 @@ axum-service = ["tower", "futures-core", "axum", "bytes", "tracing"] tracing-otel-26 = ["reqwest-tracing/opentelemetry_0_26"] tracing-otel-27 = ["reqwest-tracing/opentelemetry_0_27"] tracing-otel-28 = ["reqwest-tracing/opentelemetry_0_28"] +tracing-otel-29 = ["reqwest-tracing/opentelemetry_0_29"] +tracing-otel-30 = ["reqwest-tracing/opentelemetry_0_30"] diff --git a/README.md b/README.md index 008ab6e..ff6e6e2 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ implements Axum's `OptionalFromRequestParts`, so you can more easily retrieve it ### OpenTelemetry Integration -There are also optional features `tracing-otel-26`, `tracing-otel-27`, and `tracing-otel-28` +There are also optional features `tracing-otel-26` through `tracing-otel-30` that pair with the `axum-service` feature to ensure that any outgoing requests for credentials that take place in the context of an incoming web request also include the proper OpenTelemetry span information in any requests to MAudit services. Note that it is critical to use the same diff --git a/src/config.rs b/src/config.rs index 9832735..55e24c0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,7 +65,9 @@ impl MAuthInfo { #[cfg(any( feature = "tracing-otel-26", feature = "tracing-otel-27", - feature = "tracing-otel-28" + feature = "tracing-otel-28", + feature = "tracing-otel-29", + feature = "tracing-otel-30", ))] let builder = builder.with(reqwest_tracing::TracingMiddleware::default()); builder.build() From a5f36c60ec6d77cb606ddb136b134990f08d5379 Mon Sep 17 00:00:00 2001 From: Mason Gup Date: Mon, 30 Jun 2025 15:38:25 -0400 Subject: [PATCH 3/4] Specify rust version --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index f73516d..7e2aa0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "mauth-client" version = "0.6.1" authors = ["Mason Gup "] edition = "2024" +rust-version = "1.88" documentation = "https://docs.rs/mauth-client/" license = "MIT" description = "Sign requests and validate responses using the Medidata MAuth protocol" From b1a067d7f51171648916ec3440110faa683dd59e Mon Sep 17 00:00:00 2001 From: Mason Gup Date: Mon, 30 Jun 2025 16:12:23 -0400 Subject: [PATCH 4/4] Bump crate version too --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7e2aa0c..ee400b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mauth-client" -version = "0.6.1" +version = "0.7.0" authors = ["Mason Gup "] edition = "2024" rust-version = "1.88"