Skip to content

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

fix(authentication): allow netcetera webhook to enter without signature verification (#15023)

Sahkal Poddar11a6925a05f0
diff --git a/crates/hyperswitch_connectors/src/connectors/netcetera.rs b/crates/hyperswitch_connectors/src/connectors/netcetera.rs
index 581bc82155..dfb312e27f 100644
--- a/crates/hyperswitch_connectors/src/connectors/netcetera.rs
+++ b/crates/hyperswitch_connectors/src/connectors/netcetera.rs
@@ -5,6 +5,7 @@ use std::fmt::Debug;
use api_models::webhooks::{AuthenticationIdType, IncomingWebhookEvent, ObjectReferenceId};
use common_utils::{
+ crypto,
errors::CustomResult,
ext_traits::ByteSliceExt,
request::{Method, Request, RequestBuilder, RequestContent},
@@ -241,6 +242,19 @@ impl IncomingWebhook for Netcetera {
challenge_code_reason,
})
}
+
+ async fn verify_webhook_source(
+ &self,
+ _request: &IncomingWebhookRequestDetails<'_>,
+ _merchant_id: &common_utils::id_type::MerchantId,
+ _connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,
+ _connector_account_details: crypto::Encryptable<
+ hyperswitch_masking::Secret<serde_json::Value>,
+ >,
+ _connector_name: &str,
+ ) -> CustomResult<bool, ConnectorError> {
+ Ok(true)
+ }
}
impl ConnectorPreAuthentication for Netcetera {}
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 232494a523..fe6e3cf88a 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -552,6 +552,11 @@ async fn process_webhook_business_logic(
} else if connector.is_webhook_source_verification_mandatory() {
// if webhook consumption is mandatory for connector, fail webhook
// so that merchant can retrigger it after updating merchant_secret
+ logger::warn!(
+ connector = %connector_name,
+ merchant_id = ?platform.get_processor().get_account().get_id(),
+ "Incoming webhook blocked: source verification failed and verification is mandatory for this connector"
+ );
return Err(errors::ApiErrorResponse::WebhookAuthenticationFailed.into());
} else {
// Unverified webhooks fall back to syncing with the connector, so cap how many of them
diff --git a/crates/router/src/core/webhooks/incoming_v2.rs b/crates/router/src/core/webhooks/incoming_v2.rs
index e46d9e4839..84a111d89a 100644
--- a/crates/router/src/core/webhooks/incoming_v2.rs
+++ b/crates/router/src/core/webhooks/incoming_v2.rs
@@ -11,7 +11,10 @@ use hyperswitch_domain_models::{
router_request_types::VerifyWebhookSourceRequestData,
router_response_types::{VerifyWebhookSourceResponseData, VerifyWebhookStatus},
};
-use hyperswitch_interfaces::webhooks::{IncomingWebhookRequestDetails, WebhookResourceData};
+use hyperswitch_interfaces::{
+ api::ConnectorCommon,
+ webhooks::{IncomingWebhookRequestDetails, WebhookResourceData},
+};
use hyperswitch_masking::Secret;
use router_env::{instrument, tracing};
@@ -305,7 +308,14 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
connector.is_webhook_source_verification_mandatory(),
source_verified,
) {
- (true, false) => Err(errors::ApiErrorResponse::WebhookAuthenticationFailed)?,
+ (true, false) => {
+ logger::warn!(
+ connector = %connector.id(),
+ merchant_id = ?platform.get_processor().get_account().get_id(),
+ "Incoming webhook blocked: source verification failed and verification is mandatory for this connector"
+ );
+ Err(errors::ApiErrorResponse::WebhookAuthenticationFailed)?
+ }
_ => {
// Unverified webhooks fall back to syncing with the connector, so cap how many of
// them each merchant, profile and merchant connector account can push through