From 26bbdd1d8e056b62ef6d40561f0e945b78e451d9 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 23 Sep 2024 18:22:25 +0300 Subject: [PATCH 1/2] fix: remove remote_addr logs bumpup version --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- affinidi-messaging-mediator/src/common/errors.rs | 1 - affinidi-messaging-mediator/src/common/jwt_auth.rs | 13 +++++-------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e176470..23812ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "affinidi-messaging-didcomm" -version = "0.7.4" +version = "0.7.5" dependencies = [ "affinidi-did-resolver-cache-sdk", "anyhow", @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "affinidi-messaging-mediator" -version = "0.7.4" +version = "0.7.5" dependencies = [ "affinidi-did-resolver-cache-sdk", "affinidi-messaging-didcomm", @@ -167,11 +167,11 @@ dependencies = [ [[package]] name = "affinidi-messaging-processor" -version = "0.7.4" +version = "0.7.5" [[package]] name = "affinidi-messaging-sdk" -version = "0.7.4" +version = "0.7.5" dependencies = [ "affinidi-did-resolver-cache-sdk", "affinidi-messaging-didcomm", diff --git a/Cargo.toml b/Cargo.toml index b75ce61..62306bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ resolver = "2" [workspace.package] -version = '0.7.4' +version = '0.7.5' edition = "2021" authors = ["Glenn Gore "] description = "Affinidi Trusted Messaging" diff --git a/affinidi-messaging-mediator/src/common/errors.rs b/affinidi-messaging-mediator/src/common/errors.rs index 77fb0c2..e58b270 100644 --- a/affinidi-messaging-mediator/src/common/errors.rs +++ b/affinidi-messaging-mediator/src/common/errors.rs @@ -251,7 +251,6 @@ impl IntoResponse for AppError { #[derive(Clone, Debug, Serialize)] pub struct Session { pub session_id: String, // Unique session transaction ID - pub remote_addr: String, // Remote Socket address pub authenticated: bool, // Has this session been authenticated? pub challenge_sent: Option, // Challenge sent to the client pub did: String, // DID of the client diff --git a/affinidi-messaging-mediator/src/common/jwt_auth.rs b/affinidi-messaging-mediator/src/common/jwt_auth.rs index 2f581fb..8f41140 100644 --- a/affinidi-messaging-mediator/src/common/jwt_auth.rs +++ b/affinidi-messaging-mediator/src/common/jwt_auth.rs @@ -98,7 +98,7 @@ where )) })?; - let remote_addr = if let Some(address) = parts + if let Some(address) = parts .extensions .get::>() .map(|ci| ci.0) @@ -118,8 +118,7 @@ where .await .map_err(|_| { warn!( - "{}: No Authorization Bearer header in request!", - remote_addr + "No Authorization Bearer header in request!" ); AuthError::MissingCredentials })?; @@ -132,8 +131,7 @@ where Err(err) => { event!( Level::WARN, - "{}: decoding JWT failed {:?}", - remote_addr, + "Decoding JWT failed {:?}", err ); return Err(AuthError::InvalidToken); @@ -148,13 +146,12 @@ where let did_hash = digest(&did); info!( - "{}: Protected connection accepted from address({}) did_hash({})", - &session_id, &remote_addr, &did_hash + "{}: Protected connection accepted from did_hash({})", + &session_id, &did_hash ); let session = Session { session_id, - remote_addr, authenticated: true, challenge_sent: None, did, From 5c78a6184bf62ca64968819fac6f22a1a6ffdc96 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 23 Sep 2024 18:24:12 +0300 Subject: [PATCH 2/2] fix: make linter happy --- affinidi-messaging-mediator/src/common/jwt_auth.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/affinidi-messaging-mediator/src/common/jwt_auth.rs b/affinidi-messaging-mediator/src/common/jwt_auth.rs index 8f41140..dfd75fb 100644 --- a/affinidi-messaging-mediator/src/common/jwt_auth.rs +++ b/affinidi-messaging-mediator/src/common/jwt_auth.rs @@ -117,9 +117,7 @@ where .extract::>>() .await .map_err(|_| { - warn!( - "No Authorization Bearer header in request!" - ); + warn!("No Authorization Bearer header in request!"); AuthError::MissingCredentials })?; @@ -129,11 +127,7 @@ where match jsonwebtoken::decode::(bearer.token(), decoding_key, &validation) { Ok(token_data) => token_data, Err(err) => { - event!( - Level::WARN, - "Decoding JWT failed {:?}", - err - ); + event!(Level::WARN, "Decoding JWT failed {:?}", err); return Err(AuthError::InvalidToken); } }