Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): [nmi] webhook source verification (#8946)
Pa1NarKa0a4b9239dd2
diff --git a/crates/hyperswitch_connectors/src/connectors/nmi.rs b/crates/hyperswitch_connectors/src/connectors/nmi.rsindex 7ae21664e7..50e5db86e5 100644--- a/crates/hyperswitch_connectors/src/connectors/nmi.rs+++ b/crates/hyperswitch_connectors/src/connectors/nmi.rs@@ -9,6 +9,7 @@ use common_utils::{types::{AmountConvertor, FloatMajorUnit, FloatMajorUnitForConnector},};use error_stack::{report, ResultExt};+use hex;use hyperswitch_domain_models::{router_data::{AccessToken, ErrorResponse, RouterData},router_flow_types::{@@ -859,13 +860,15 @@ impl IncomingWebhook for Nmi {.captures(sig_header){let signature = captures- .get(1)+ .get(2).ok_or(ConnectorError::WebhookSignatureNotFound)?.as_str();- return Ok(signature.as_bytes().to_vec());- }- Err(report!(ConnectorError::WebhookSignatureNotFound))+ // Decode hex signature to bytes+ hex::decode(signature).change_context(ConnectorError::WebhookSignatureNotFound)+ } else {+ Err(report!(ConnectorError::WebhookSignatureNotFound))+ }}fn get_webhook_source_verification_message(@@ -883,15 +886,16 @@ impl IncomingWebhook for Nmi {.captures(sig_header){let nonce = captures- .get(0)+ .get(1).ok_or(ConnectorError::WebhookSignatureNotFound)?.as_str();let message = format!("{}.{}", nonce, String::from_utf8_lossy(request.body));- return Ok(message.into_bytes());+ Ok(message.into_bytes())+ } else {+ Err(report!(ConnectorError::WebhookSignatureNotFound))}- Err(report!(ConnectorError::WebhookSignatureNotFound))}fn get_webhook_object_reference_id(