diff --git a/Cargo.lock b/Cargo.lock index bb3cb8c..fb04ecc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1900,6 +1900,7 @@ name = "webhook_bridge" version = "0.0.1" dependencies = [ "axum", + "base64 0.22.1", "hmac", "http-body-util", "k8s-openapi", diff --git a/Cargo.toml b/Cargo.toml index b04dd8a..84aa584 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ include = [ [dependencies] # default form, http1, json, matched-path, original-uri, query, tokio, tower-log, tracing axum = { version = "0.7.5", default-features = false, features = ["tokio", "http1", "http2", "json"] } +base64 = "0.22.1" hmac = "0.12.1" http-body-util = "0.1.2" k8s-openapi = { version = "0.22.0", default-features = false, features = ["v1_30"] } diff --git a/src/webhook.rs b/src/webhook.rs index c4775a8..86f46ef 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -12,6 +12,7 @@ use axum::response::IntoResponse; use axum::response::Response; use axum::Json; use axum::RequestExt; +use base64::{engine::general_purpose, Engine as _}; use hmac::Hmac; use hmac::Mac; use http_body_util::BodyExt; @@ -126,7 +127,7 @@ where async fn check_hash(body: Bytes, secret: String, signature: Vec) -> Result { tracing::info!("Checking signature {:02x?}", signature.as_slice()); tracing::info!("Using secret {:?}", secret); - tracing::info!("and body {:02x?}", body); + tracing::info!("and body {}", general_purpose::STANDARD.encode(&body)); let mut mac = HmacSha256::new_from_slice(secret.as_bytes()) .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response())?; mac.update(&body);