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(disputes): enforce profile scope for connector fetch (#15098)

Ayush Anand82def1d7aa38
diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rs
index 4f531dd1fd..0c5f90b35e 100644
--- a/crates/router/src/core/disputes.rs
+++ b/crates/router/src/core/disputes.rs
@@ -915,6 +915,7 @@ pub async fn get_aggregates_for_disputes(
pub async fn connector_sync_disputes(
state: SessionState,
platform: domain::Platform,
+ profile_id: Option<common_utils::id_type::ProfileId>,
merchant_connector_id: String,
payload: disputes::DisputeFetchQueryData,
) -> RouterResponse<FetchDisputesResponse> {
@@ -942,6 +943,7 @@ pub async fn connector_sync_disputes(
Box::pin(fetch_disputes_from_connector(
state,
platform,
+ profile_id,
connector_id,
fetch_dispute_request,
))
@@ -953,6 +955,7 @@ pub async fn connector_sync_disputes(
pub async fn fetch_disputes_from_connector(
state: SessionState,
platform: domain::Platform,
+ profile_id: Option<common_utils::id_type::ProfileId>,
merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
req: FetchDisputesRequestData,
) -> RouterResponse<FetchDisputesResponse> {
@@ -967,6 +970,7 @@ pub async fn fetch_disputes_from_connector(
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: merchant_connector_id.get_string_repr().to_string(),
})?;
+ core_utils::validate_profile_id_from_auth_layer(profile_id, &merchant_connector_account)?;
let connector_name = merchant_connector_account.connector_name.clone();
let connector_data = api::ConnectorData::get_connector_by_name(
&state.conf.connectors,
diff --git a/crates/router/src/routes/disputes.rs b/crates/router/src/routes/disputes.rs
index 1bed97b69f..d4de2baaec 100644
--- a/crates/router/src/routes/disputes.rs
+++ b/crates/router/src/routes/disputes.rs
@@ -86,7 +86,14 @@ pub async fn fetch_disputes(
&req,
payload,
|state, auth: auth::AuthenticationData, req, _| {
- disputes::connector_sync_disputes(state, auth.platform, connector_id.clone(), req)
+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());
+ disputes::connector_sync_disputes(
+ state,
+ auth.platform,
+ profile_id,
+ connector_id.clone(),
+ req,
+ )
},
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth {
diff --git a/crates/router/src/workflows/dispute_list.rs b/crates/router/src/workflows/dispute_list.rs
index 2be0fe896f..be2cf8bfba 100644
--- a/crates/router/src/workflows/dispute_list.rs
+++ b/crates/router/src/workflows/dispute_list.rs
@@ -117,6 +117,7 @@ impl ProcessTrackerWorkflow<SessionState> for DisputeListWorkflow {
let response = Box::pin(disputes::fetch_disputes_from_connector(
state.clone(),
platform,
+ None,
tracking_data.merchant_connector_id,
hyperswitch_domain_models::router_request_types::FetchDisputesRequestData {
created_from: tracking_data.created_from,