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

feat(platform): JWT Authentication for Platform Operations (#11195)

Ankit Kumar Gupta163ed86816c0
diff --git a/crates/router/src/analytics.rs b/crates/router/src/analytics.rs
index 29c1a1ea31..298bef320c 100644
--- a/crates/router/src/analytics.rs
+++ b/crates/router/src/analytics.rs
@@ -536,6 +536,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -590,6 +592,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -650,6 +654,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -700,6 +706,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -754,6 +762,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -814,6 +824,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -864,6 +876,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -918,6 +932,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -978,6 +994,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1016,6 +1034,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1055,6 +1075,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1095,6 +1117,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1137,6 +1161,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1185,6 +1211,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1229,6 +1257,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1261,6 +1291,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1292,6 +1324,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1327,6 +1361,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1367,6 +1403,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1401,6 +1439,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1441,6 +1481,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1475,6 +1517,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1507,6 +1551,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1541,6 +1587,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1581,6 +1629,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1609,6 +1659,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1638,6 +1690,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1685,6 +1739,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1728,6 +1784,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1766,6 +1824,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1817,6 +1877,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1866,6 +1928,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1924,6 +1988,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1974,6 +2040,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2022,6 +2090,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2080,6 +2150,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2131,6 +2203,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2180,6 +2254,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2237,6 +2313,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2288,6 +2366,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2337,6 +2417,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2394,6 +2476,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2445,6 +2529,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2494,6 +2580,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2551,6 +2639,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2589,6 +2679,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2617,6 +2709,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2658,6 +2752,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2703,6 +2799,8 @@ pub mod routes {
}),
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -2852,6 +2950,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -3002,6 +3102,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -3032,6 +3134,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3070,6 +3174,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3104,6 +3210,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -3146,6 +3254,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3194,6 +3304,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3238,6 +3350,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -3271,6 +3385,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3302,6 +3418,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::MerchantAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3337,6 +3455,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -3378,6 +3498,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3413,6 +3535,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::OrganizationAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -3454,6 +3578,8 @@ pub mod routes {
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rs
index 13ce44bbcd..26b56b2dbd 100644
--- a/crates/router/src/routes/admin.rs
+++ b/crates/router/src/routes/admin.rs
@@ -310,6 +310,8 @@ pub async fn retrieve_merchant_account(
// this API call for profile level users.
// TODO: Convert this to MerchantAccountRead once FE changes are done.
required_permission: Permission::ProfileAccountRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -348,6 +350,8 @@ pub async fn retrieve_merchant_account(
// this API call for profile level users.
// TODO: Convert this to MerchantAccountRead once FE changes are done.
required_permission: Permission::ProfileAccountRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -379,6 +383,8 @@ pub async fn merchant_account_list(
&auth::V2AdminApiAuth,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantAccountRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -409,6 +415,8 @@ pub async fn merchant_account_list(
},
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantAccountRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -441,6 +449,8 @@ pub async fn update_merchant_account(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -472,6 +482,8 @@ pub async fn update_merchant_account(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -561,6 +573,8 @@ pub async fn connector_create(
&auth::JWTAndEmbeddedAuth {
merchant_id_from_route: Some(merchant_id.clone()),
permission: Some(Permission::ProfileConnectorWrite),
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -592,6 +606,8 @@ pub async fn connector_create(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantConnectorWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -641,6 +657,8 @@ pub async fn connector_retrieve(
// sensitive data, keeping this as ProfileConnectorWrite
// TODO: Convert this to ProfileConnectorRead once data is masked.
permission: Some(Permission::ProfileConnectorWrite),
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -674,6 +692,8 @@ pub async fn connector_retrieve(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantConnectorRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -708,6 +728,8 @@ pub async fn connector_list(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantConnectorRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -742,6 +764,8 @@ pub async fn connector_list(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantConnectorRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -780,6 +804,8 @@ pub async fn connector_list_profile(
&auth::JWTAndEmbeddedAuth {
merchant_id_from_route: Some(merchant_id),
permission: Some(Permission::ProfileConnectorRead),
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -824,6 +850,8 @@ pub async fn connector_update(
&auth::JWTAndEmbeddedAuth {
merchant_id_from_route: Some(merchant_id.clone()),
permission: Some(Permission::ProfileConnectorWrite),
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -859,6 +887,8 @@ pub async fn connector_update(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::MerchantConnectorWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -898,6 +928,8 @@ pub async fn connector_delete(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantConnectorWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -931,6 +963,8 @@ pub async fn connector_delete(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantConnectorWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1119,6 +1153,8 @@ pub async fn connector_webhook_register(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::ProfileConnectorWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/api_keys.rs b/crates/router/src/routes/api_keys.rs
index 1abca9b8d7..f919c43c5b 100644
--- a/crates/router/src/routes/api_keys.rs
+++ b/crates/router/src/routes/api_keys.rs
@@ -37,6 +37,8 @@ pub async fn api_key_create(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::MerchantApiKeyWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -67,6 +69,8 @@ pub async fn api_key_create(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantApiKeyWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -106,6 +110,8 @@ pub async fn api_key_retrieve(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantApiKeyRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -141,6 +147,8 @@ pub async fn api_key_retrieve(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::MerchantApiKeyRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -180,6 +188,8 @@ pub async fn api_key_update(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantApiKeyWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -218,6 +228,8 @@ pub async fn api_key_update(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantApiKeyRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -255,6 +267,8 @@ pub async fn api_key_revoke(
&auth::JWTAuthMerchantFromRoute {
merchant_id: merchant_id.clone(),
required_permission: Permission::MerchantApiKeyWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -288,6 +302,8 @@ pub async fn api_key_revoke(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantApiKeyWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -326,6 +342,8 @@ pub async fn api_key_list(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantApiKeyRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -361,6 +379,8 @@ pub async fn api_key_list(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: Permission::MerchantApiKeyRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
diff --git a/crates/router/src/routes/blocklist.rs b/crates/router/src/routes/blocklist.rs
index fdee5d9035..e50503daf0 100644
--- a/crates/router/src/routes/blocklist.rs
+++ b/crates/router/src/routes/blocklist.rs
@@ -42,6 +42,8 @@ pub async fn add_entry_to_blocklist(
}),
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -83,6 +85,8 @@ pub async fn remove_entry_from_blocklist(
}),
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -140,6 +144,8 @@ pub async fn list_blocked_payment_methods(
&*auth_type,
&auth::JWTAuth {
permission: Permission::MerchantAccountRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -183,6 +189,8 @@ pub async fn toggle_blocklist_guard(
}),
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/chat.rs b/crates/router/src/routes/chat.rs
index f670bb8e16..efb8f082d6 100644
--- a/crates/router/src/routes/chat.rs
+++ b/crates/router/src/routes/chat.rs
@@ -40,6 +40,8 @@ pub async fn get_data_from_hyperswitch_ai_workflow(
// At present, the AI service retrieves data scoped to the merchant level
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -61,7 +63,10 @@ pub async fn get_all_conversations(
|state, user: auth::UserFromToken, payload, _| {
chat_core::list_chat_conversations(state, user, payload)
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
api_locking::LockAction::NotApplicable,
))
.await
diff --git a/crates/router/src/routes/connector_onboarding.rs b/crates/router/src/routes/connector_onboarding.rs
index 8ecd321df9..20ea4fa5e6 100644
--- a/crates/router/src/routes/connector_onboarding.rs
+++ b/crates/router/src/routes/connector_onboarding.rs
@@ -23,6 +23,8 @@ pub async fn get_action_url(
core::get_action_url,
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -44,6 +46,8 @@ pub async fn sync_onboarding_status(
core::sync_onboarding_status,
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -65,6 +69,8 @@ pub async fn reset_tracking_id(
core::reset_tracking_id,
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/currency.rs b/crates/router/src/routes/currency.rs
index 10f72d8dd8..91a497b924 100644
--- a/crates/router/src/routes/currency.rs
+++ b/crates/router/src/routes/currency.rs
@@ -21,7 +21,10 @@ pub async fn retrieve_forex(state: web::Data<AppState>, req: HttpRequest) -> Htt
allow_connected_scope_operation: false,
allow_platform_self_operation: false,
}),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
req.headers(),
),
api_locking::LockAction::NotApplicable,
@@ -57,7 +60,10 @@ pub async fn convert_forex(
allow_connected_scope_operation: false,
allow_platform_self_operation: false,
}),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
req.headers(),
),
api_locking::LockAction::NotApplicable,
diff --git a/crates/router/src/routes/customers.rs b/crates/router/src/routes/customers.rs
index 8dab9ab6dc..0aeaec95ed 100644
--- a/crates/router/src/routes/customers.rs
+++ b/crates/router/src/routes/customers.rs
@@ -31,6 +31,8 @@ pub async fn customers_create(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -61,6 +63,8 @@ pub async fn customers_create(
}),
&auth::JWTAuth {
permission: Permission::MerchantCustomerWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -83,6 +87,8 @@ pub async fn customers_retrieve(
let auth = if auth::is_jwt_auth(req.headers()) {
Box::new(auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
})
} else {
let api_auth = auth::ApiKeyAuth {
@@ -139,6 +145,8 @@ pub async fn customers_retrieve(
let auth = if auth::is_jwt_auth(req.headers()) {
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
}
} else {
sdk_or_api_or_client_auth(
@@ -190,6 +198,8 @@ pub async fn customers_list(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -222,6 +232,8 @@ pub async fn customers_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -255,6 +267,8 @@ pub async fn customers_list_with_count(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -287,6 +301,8 @@ pub async fn customers_list_with_count(
}),
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -330,6 +346,8 @@ pub async fn customers_update(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -370,6 +388,8 @@ pub async fn customers_update(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -403,6 +423,8 @@ pub async fn customers_delete(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -436,6 +458,8 @@ pub async fn customers_delete(
}),
&auth::JWTAuth {
permission: Permission::MerchantCustomerWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -469,6 +493,8 @@ pub async fn get_customer_mandates(
}),
&auth::JWTAuth {
permission: Permission::MerchantMandateRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/disputes.rs b/crates/router/src/routes/disputes.rs
index 57034ba7c7..5dac2dda60 100644
--- a/crates/router/src/routes/disputes.rs
+++ b/crates/router/src/routes/disputes.rs
@@ -58,6 +58,8 @@ pub async fn retrieve_dispute(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -93,6 +95,8 @@ pub async fn fetch_disputes(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -148,6 +152,8 @@ pub async fn retrieve_disputes_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantDisputeRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -209,6 +215,8 @@ pub async fn retrieve_disputes_list_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -247,6 +255,8 @@ pub async fn get_disputes_filters(state: web::Data<AppState>, req: HttpRequest)
}),
&auth::JWTAuth {
permission: Permission::MerchantDisputeRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -292,6 +302,8 @@ pub async fn get_disputes_filters_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -342,6 +354,8 @@ pub async fn accept_dispute(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -387,6 +401,8 @@ pub async fn submit_dispute_evidence(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -439,6 +455,8 @@ pub async fn attach_dispute_evidence(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -489,6 +507,8 @@ pub async fn retrieve_dispute_evidence(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -534,6 +554,8 @@ pub async fn delete_dispute_evidence(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -566,6 +588,8 @@ pub async fn get_disputes_aggregate(
}),
&auth::JWTAuth {
permission: Permission::MerchantDisputeRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -604,6 +628,8 @@ pub async fn get_disputes_aggregate_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileDisputeRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/files.rs b/crates/router/src/routes/files.rs
index f612f71f6f..231c388d66 100644
--- a/crates/router/src/routes/files.rs
+++ b/crates/router/src/routes/files.rs
@@ -54,7 +54,10 @@ pub async fn files_create(
allow_connected_scope_operation: false,
allow_platform_self_operation: false,
}),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
req.headers(),
),
api_locking::LockAction::NotApplicable,
@@ -103,7 +106,10 @@ pub async fn files_delete(
allow_connected_scope_operation: false,
allow_platform_self_operation: false,
}),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
req.headers(),
),
api_locking::LockAction::NotApplicable,
@@ -154,7 +160,10 @@ pub async fn files_retrieve(
allow_connected_scope_operation: false,
allow_platform_self_operation: false,
}),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
req.headers(),
),
api_locking::LockAction::NotApplicable,
diff --git a/crates/router/src/routes/hypersense.rs b/crates/router/src/routes/hypersense.rs
index a018dfa660..a1b3feef9d 100644
--- a/crates/router/src/routes/hypersense.rs
+++ b/crates/router/src/routes/hypersense.rs
@@ -25,7 +25,10 @@ pub async fn get_hypersense_token(state: web::Data<AppState>, req: HttpRequest)
ExternalServiceType::Hypersense,
)
},
- &authentication::DashboardNoPermissionAuth,
+ &authentication::DashboardNoPermissionAuth {
+ allow_connected: false,
+ allow_platform: false,
+ },
api_locking::LockAction::NotApplicable,
))
.await
diff --git a/crates/router/src/routes/mandates.rs b/crates/router/src/routes/mandates.rs
index 6caecdd211..ae5e5bc314 100644
--- a/crates/router/src/routes/mandates.rs
+++ b/crates/router/src/routes/mandates.rs
@@ -90,6 +90,8 @@ pub async fn retrieve_mandates_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantMandateRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/oidc.rs b/crates/router/src/routes/oidc.rs
index a1de0352e0..79cf6cb51a 100644
--- a/crates/router/src/routes/oidc.rs
+++ b/crates/router/src/routes/oidc.rs
@@ -55,7 +55,10 @@ pub async fn oidc_authorize(
_| oidc_provider::process_authorize_request(state, req_payload, user),
auth::auth_type(
&auth::NoAuth,
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
req.headers(),
),
api_locking::LockAction::NotApplicable,
diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs
index 9894452f03..71e764aa9d 100644
--- a/crates/router/src/routes/payment_methods.rs
+++ b/crates/router/src/routes/payment_methods.rs
@@ -848,6 +848,8 @@ pub async fn list_customer_payment_method_api(
};
let jwt_auth = auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
};
let (auth_type, api_key_type) =
match auth::check_internal_api_key_or_dashboard_auth_no_client_secret(
@@ -912,6 +914,8 @@ pub async fn get_payment_method_token_data(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -946,6 +950,8 @@ pub async fn get_total_payment_method_count(
},
&auth::JWTAuth {
permission: Permission::MerchantCustomerRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -1135,12 +1141,16 @@ pub async fn list_countries_currencies_for_connector_payment_method(
}),
&auth::JWTAuth {
permission: Permission::ProfileConnectorWrite,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::ProfileConnectorWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -1176,12 +1186,16 @@ pub async fn list_countries_currencies_for_connector_payment_method(
},
&auth::JWTAuth {
permission: Permission::ProfileConnectorRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::ProfileConnectorRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index e23b415795..59a7a15903 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -105,6 +105,8 @@ pub async fn payments_create(
})),
&auth::InternalMerchantIdProfileIdAuth(auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: true,
+ allow_platform: false,
}),
req.headers(),
),
@@ -218,6 +220,8 @@ pub async fn payments_create_intent(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -284,6 +288,8 @@ pub async fn payments_get_intent(
)),
&auth::JWTAuth {
permission: Permission::ProfileRevenueRecoveryRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -342,6 +348,8 @@ pub async fn revenue_recovery_get_intent(
)),
&auth::JWTAuth {
permission: Permission::ProfileRevenueRecoveryRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -403,6 +411,8 @@ pub async fn list_payment_attempts(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -441,6 +451,8 @@ pub async fn payments_create_and_confirm_intent(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -668,6 +680,8 @@ pub async fn payments_retrieve(
&*auth_type,
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1747,6 +1761,8 @@ pub async fn payments_cancel(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1831,6 +1847,8 @@ pub async fn payments_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1863,6 +1881,8 @@ pub async fn revenue_recovery_invoices_list(
},
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1894,6 +1914,8 @@ pub async fn payments_list(
},
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1931,6 +1953,8 @@ pub async fn profile_payments_list(
}),
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1958,6 +1982,8 @@ pub async fn payments_list_by_filter(
},
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1988,6 +2014,8 @@ pub async fn profile_payments_list_by_filter(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2013,6 +2041,8 @@ pub async fn get_filters_for_payments(
},
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2036,6 +2066,8 @@ pub async fn get_payment_filters(
},
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2063,6 +2095,8 @@ pub async fn get_payment_filters_profile(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2090,6 +2124,8 @@ pub async fn get_payment_filters_profile(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2115,6 +2151,8 @@ pub async fn get_payments_aggregates(
},
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -2181,6 +2219,8 @@ pub async fn payments_approve(
}),
&auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: true,
+ allow_platform: false,
},
http_req.headers(),
),
@@ -2251,6 +2291,8 @@ pub async fn payments_reject(
}),
&auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: true,
+ allow_platform: false,
},
http_req.headers(),
),
@@ -3124,6 +3166,8 @@ pub async fn get_payments_aggregates_profile(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3153,6 +3197,8 @@ pub async fn get_payments_aggregates_profile(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -3608,6 +3654,8 @@ pub async fn payment_status(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -3664,6 +3712,8 @@ pub async fn payments_status_with_gateway_creds(
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -3872,6 +3922,8 @@ pub async fn payments_capture(
},
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/payouts.rs b/crates/router/src/routes/payouts.rs
index 94067b58c2..bf8b83f3d5 100644
--- a/crates/router/src/routes/payouts.rs
+++ b/crates/router/src/routes/payouts.rs
@@ -96,6 +96,8 @@ pub async fn payouts_retrieve(
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -285,6 +287,8 @@ pub async fn payouts_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantPayoutRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -324,6 +328,8 @@ pub async fn payouts_list_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -358,6 +364,8 @@ pub async fn payouts_list_by_filter(
}),
&auth::JWTAuth {
permission: Permission::MerchantPayoutRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -397,6 +405,8 @@ pub async fn payouts_list_by_filter_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -431,6 +441,8 @@ pub async fn payouts_list_available_filters_for_merchant(
}),
&auth::JWTAuth {
permission: Permission::MerchantPayoutRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -470,6 +482,8 @@ pub async fn payouts_list_available_filters_for_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -508,6 +522,8 @@ pub async fn get_payout_filters(state: web::Data<AppState>, req: HttpRequest) ->
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -590,6 +606,8 @@ pub async fn get_payouts_aggregates(
},
&auth::JWTAuth {
permission: Permission::MerchantPayoutRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -620,6 +638,8 @@ pub async fn get_payouts_aggregates_profile(
},
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/process_tracker/revenue_recovery.rs b/crates/router/src/routes/process_tracker/revenue_recovery.rs
index db939436c6..a65ef5f1d7 100644
--- a/crates/router/src/routes/process_tracker/revenue_recovery.rs
+++ b/crates/router/src/routes/process_tracker/revenue_recovery.rs
@@ -32,6 +32,8 @@ pub async fn revenue_recovery_pt_retrieve_api(
},
&auth::JWTAuth {
permission: Permission::ProfileRevenueRecoveryRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/profile_acquirer.rs b/crates/router/src/routes/profile_acquirer.rs
index 1d279f2ae4..c924038d85 100644
--- a/crates/router/src/routes/profile_acquirer.rs
+++ b/crates/router/src/routes/profile_acquirer.rs
@@ -33,6 +33,8 @@ pub async fn create_profile_acquirer(
}),
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -77,6 +79,8 @@ pub async fn profile_acquirer_update(
}),
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/profiles.rs b/crates/router/src/routes/profiles.rs
index 66e55fbf2b..f3eca84c74 100644
--- a/crates/router/src/routes/profiles.rs
+++ b/crates/router/src/routes/profiles.rs
@@ -57,6 +57,8 @@ pub async fn profile_create(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: permissions::Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -112,6 +114,8 @@ pub async fn profile_create(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: permissions::Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -156,6 +160,8 @@ pub async fn profile_retrieve(
&auth::JWTAndEmbeddedAuth {
merchant_id_from_route: Some(merchant_id.clone()),
permission: Some(permissions::Permission::ProfileAccountRead),
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -197,6 +203,8 @@ pub async fn profile_retrieve(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: permissions::Permission::MerchantAccountRead,
+ allow_connected: true,
+ allow_platform: true,
},
req.headers(),
),
@@ -270,6 +278,8 @@ pub async fn profile_update(
merchant_id: merchant_id.clone(),
profile_id: profile_id.clone(),
required_permission: permissions::Permission::ProfileAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -326,6 +336,8 @@ pub async fn profile_update(
&auth::AdminApiAuthWithMerchantIdFromHeader,
&auth::JWTAuthMerchantFromHeader {
required_permission: permissions::Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -385,6 +397,8 @@ pub async fn profiles_list(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: permissions::Permission::MerchantAccountRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -416,6 +430,8 @@ pub async fn profiles_list(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: permissions::Permission::MerchantAccountRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -451,6 +467,8 @@ pub async fn profiles_list_at_profile_level(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: permissions::Permission::ProfileAccountRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -487,6 +505,8 @@ pub async fn toggle_connector_agnostic_mit(
}),
&auth::JWTAuth {
permission: permissions::Permission::MerchantRoutingWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -547,6 +567,8 @@ pub async fn payment_connector_list_profile(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: permissions::Permission::ProfileConnectorRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/recon.rs b/crates/router/src/routes/recon.rs
index a5320c5b61..1e1bdf44be 100644
--- a/crates/router/src/routes/recon.rs
+++ b/crates/router/src/routes/recon.rs
@@ -41,6 +41,8 @@ pub async fn request_for_recon(state: web::Data<AppState>, http_req: HttpRequest
|state, user, _, _| recon::send_recon_request(state, user),
&authentication::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -57,6 +59,8 @@ pub async fn get_recon_token(state: web::Data<AppState>, req: HttpRequest) -> Ht
|state, user, _, _| recon::generate_recon_token(state, user),
&authentication::JWTAuth {
permission: Permission::MerchantReconTokenRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -74,6 +78,8 @@ pub async fn verify_recon_token(state: web::Data<AppState>, http_req: HttpReques
|state, user, _req, _| recon::verify_recon_token(state, user),
&authentication::JWTAuth {
permission: Permission::MerchantReconTokenRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/refunds.rs b/crates/router/src/routes/refunds.rs
index 5977063a71..40bd361932 100644
--- a/crates/router/src/routes/refunds.rs
+++ b/crates/router/src/routes/refunds.rs
@@ -71,6 +71,8 @@ pub async fn refunds_create(
}),
&auth::JWTAuth {
permission: Permission::ProfileRefundWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -110,6 +112,8 @@ pub async fn refunds_create(
},
&auth::JWTAuth {
permission: Permission::ProfileRefundWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
)
@@ -176,6 +180,8 @@ pub async fn refunds_retrieve(
}),
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -220,6 +226,8 @@ pub async fn refunds_retrieve(
},
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -260,6 +268,8 @@ pub async fn refunds_retrieve_with_gateway_creds(
},
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
)
@@ -418,6 +428,8 @@ pub async fn refunds_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -454,6 +466,8 @@ pub async fn refunds_list(
},
&auth::JWTAuth {
permission: Permission::MerchantRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -493,6 +507,8 @@ pub async fn refunds_list_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -527,6 +543,8 @@ pub async fn refunds_filter_list(
}),
&auth::JWTAuth {
permission: Permission::MerchantRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -557,6 +575,8 @@ pub async fn get_refunds_filters(state: web::Data<AppState>, req: HttpRequest) -
}),
&auth::JWTAuth {
permission: Permission::MerchantRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -594,6 +614,8 @@ pub async fn get_refunds_filters_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -626,6 +648,8 @@ pub async fn get_refunds_aggregates(
}),
&auth::JWTAuth {
permission: Permission::MerchantRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -686,6 +710,8 @@ pub async fn get_refunds_aggregate_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index ede56adf8e..cdafbb0228 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -64,6 +64,8 @@ pub async fn routing_create_config(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -103,12 +105,16 @@ pub async fn routing_create_config(
},
&auth::JWTAuth {
permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -149,6 +155,8 @@ pub async fn routing_link_config(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -195,6 +203,8 @@ pub async fn routing_link_config(
&auth::JWTAuthProfileFromRoute {
profile_id: wrapper.profile_id,
required_permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -202,6 +212,8 @@ pub async fn routing_link_config(
&auth::JWTAuthProfileFromRoute {
profile_id: wrapper.profile_id,
required_permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -238,6 +250,8 @@ pub async fn routing_retrieve_config(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -276,12 +290,16 @@ pub async fn routing_retrieve_config(
},
&auth::JWTAuth {
permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -320,6 +338,8 @@ pub async fn list_routing_configs(
}),
&auth::JWTAuth {
permission: Permission::MerchantRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -360,6 +380,8 @@ pub async fn list_routing_configs_for_profile(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -400,6 +422,8 @@ pub async fn routing_unlink_config(
&auth::JWTAuthProfileFromRoute {
profile_id: path,
required_permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -407,6 +431,8 @@ pub async fn routing_unlink_config(
&auth::JWTAuthProfileFromRoute {
profile_id: path,
required_permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -446,6 +472,8 @@ pub async fn routing_unlink_config(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -487,12 +515,16 @@ pub async fn routing_update_default_config(
},
&auth::JWTAuth {
permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -527,6 +559,8 @@ pub async fn routing_update_default_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -564,6 +598,8 @@ pub async fn routing_retrieve_default_config(
&auth::JWTAuthProfileFromRoute {
profile_id: path,
required_permission: Permission::MerchantRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -571,6 +607,8 @@ pub async fn routing_retrieve_default_config(
&auth::JWTAuthProfileFromRoute {
profile_id: path,
required_permission: Permission::MerchantRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -605,6 +643,8 @@ pub async fn routing_retrieve_default_config(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -641,12 +681,16 @@ pub async fn upsert_surcharge_decision_manager_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantSurchargeDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantSurchargeDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -675,12 +719,16 @@ pub async fn delete_surcharge_decision_manager_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantSurchargeDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantSurchargeDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -710,12 +758,16 @@ pub async fn retrieve_surcharge_decision_manager_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantSurchargeDecisionManagerRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantSurchargeDecisionManagerRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -746,12 +798,16 @@ pub async fn upsert_decision_manager_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -787,12 +843,16 @@ pub async fn upsert_decision_manager_config(
},
&auth::JWTAuth {
permission: Permission::ProfileThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::ProfileThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -822,12 +882,16 @@ pub async fn delete_decision_manager_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -862,12 +926,16 @@ pub async fn retrieve_decision_manager_config(
},
&auth::JWTAuth {
permission: Permission::ProfileThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::ProfileThreeDsDecisionManagerWrite,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -898,12 +966,16 @@ pub async fn retrieve_decision_manager_config(
}),
&auth::JWTAuth {
permission: Permission::MerchantThreeDsDecisionManagerRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
#[cfg(feature = "release")]
&auth::JWTAuth {
permission: Permission::MerchantThreeDsDecisionManagerRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -947,6 +1019,8 @@ pub async fn routing_retrieve_linked_config(
&auth::JWTAuthProfileFromRoute {
profile_id,
required_permission: Permission::ProfileRoutingRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -978,6 +1052,8 @@ pub async fn routing_retrieve_linked_config(
}),
&auth::JWTAuth {
permission: Permission::ProfileRoutingRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -1025,6 +1101,8 @@ pub async fn routing_retrieve_linked_config(
&auth::JWTAuthProfileFromRoute {
profile_id: wrapper.profile_id,
required_permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1032,6 +1110,8 @@ pub async fn routing_retrieve_linked_config(
&auth::JWTAuthProfileFromRoute {
profile_id: wrapper.profile_id,
required_permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -1065,6 +1145,8 @@ pub async fn routing_retrieve_default_config_for_profiles(
}),
&auth::JWTAuth {
permission: Permission::MerchantRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1076,6 +1158,8 @@ pub async fn routing_retrieve_default_config_for_profiles(
}),
&auth::JWTAuth {
permission: Permission::MerchantRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1119,6 +1203,8 @@ pub async fn routing_update_default_config_for_profile(
&auth::JWTAuthProfileFromRoute {
profile_id: routing_payload_wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1172,6 +1258,8 @@ pub async fn create_success_based_routing(
&auth::JWTAuthProfileFromRoute {
profile_id: wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1216,6 +1304,8 @@ pub async fn success_based_routing_update_configs(
&auth::JWTAuthProfileFromRoute {
profile_id: routing_payload_wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1260,6 +1350,8 @@ pub async fn elimination_routing_update_configs(
&auth::JWTAuthProfileFromRoute {
profile_id: routing_payload_wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1307,6 +1399,8 @@ pub async fn contract_based_routing_setup_config(
allow_platform_self_operation: false,
}),
&auth::JWTAuthProfileFromRoute {
+ allow_connected: false,
+ allow_platform: false,
profile_id: routing_payload_wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
},
@@ -1357,6 +1451,8 @@ pub async fn contract_based_routing_update_configs(
&auth::JWTAuthProfileFromRoute {
profile_id: routing_payload_wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1410,6 +1506,8 @@ pub async fn create_elimination_routing(
&auth::JWTAuthProfileFromRoute {
profile_id: wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1460,6 +1558,8 @@ pub async fn set_dynamic_routing_volume_split(
&auth::JWTAuthProfileFromRoute {
profile_id: payload.profile_id,
required_permission: Permission::ProfileRoutingWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -1494,6 +1594,8 @@ pub async fn get_dynamic_routing_volume_split(
&auth::JWTAuthProfileFromRoute {
profile_id: payload.profile_id,
required_permission: Permission::ProfileRoutingRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/subscription.rs b/crates/router/src/routes/subscription.rs
index c584e5a5e6..d7bd07ccf2 100644
--- a/crates/router/src/routes/subscription.rs
+++ b/crates/router/src/routes/subscription.rs
@@ -81,6 +81,8 @@ pub async fn create_subscription(
}),
&auth::JWTAuth {
permission: Permission::ProfileSubscriptionWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -257,6 +259,8 @@ pub async fn confirm_subscription(
&*auth_type,
&auth::JWTAuth {
permission: Permission::ProfileSubscriptionWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -321,6 +325,8 @@ pub async fn get_subscription_items(
&*auth_type,
&auth::JWTAuth {
permission: Permission::ProfileSubscriptionRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -363,6 +369,8 @@ pub async fn get_subscription(
}),
&auth::JWTAuth {
permission: Permission::ProfileSubscriptionRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -402,6 +410,8 @@ pub async fn create_and_confirm_subscription(
}),
&auth::JWTAuth {
permission: Permission::ProfileSubscriptionWrite,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
@@ -514,6 +524,8 @@ pub async fn list_subscriptions(
}),
&auth::JWTAuth {
permission: Permission::ProfileSubscriptionRead,
+ allow_connected: false,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/user.rs b/crates/router/src/routes/user.rs
index 0d19e3c7f1..1bb0d88154 100644
--- a/crates/router/src/routes/user.rs
+++ b/crates/router/src/routes/user.rs
@@ -30,7 +30,10 @@ pub async fn get_user_details(state: web::Data<AppState>, req: HttpRequest) -> H
&req,
(),
|state, user, _, _| user_core::get_user_details(state, user),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -162,7 +165,10 @@ pub async fn change_password(
&http_req,
json_payload.into_inner(),
|state, user, req, _| user_core::change_password(state, req, user),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -191,6 +197,8 @@ pub async fn set_dashboard_metadata(
user_core::dashboard_metadata::set_metadata,
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -217,7 +225,10 @@ pub async fn get_multiple_dashboard_metadata(
&req,
payload,
user_core::dashboard_metadata::get_multiple_metadata,
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -276,6 +287,8 @@ pub async fn create_platform(
},
&auth::JWTAuth {
permission: Permission::OrganizationAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -299,6 +312,8 @@ pub async fn user_org_create(
},
&auth::JWTAuth {
permission: Permission::TenantAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -321,6 +336,8 @@ pub async fn user_merchant_account_create(
},
&auth::JWTAuth {
permission: Permission::OrganizationAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -344,6 +361,8 @@ pub async fn generate_sample_data(
sample_data::generate_sample_data_for_user,
&auth::JWTAuth {
permission: Permission::MerchantPaymentWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -367,6 +386,8 @@ pub async fn delete_sample_data(
sample_data::delete_sample_data_for_user,
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -387,6 +408,8 @@ pub async fn list_user_roles_details(
user_core::list_user_roles_details,
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -476,6 +499,8 @@ pub async fn invite_multiple_user(
},
&auth::JWTAuth {
permission: Permission::ProfileUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -501,6 +526,8 @@ pub async fn resend_invite(
},
&auth::JWTAuth {
permission: Permission::ProfileUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -616,7 +643,10 @@ pub async fn update_user_account_details(
&req,
json_payload.into_inner(),
user_core::update_user_details,
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -663,7 +693,10 @@ pub async fn totp_reset(state: web::Data<AppState>, req: HttpRequest) -> HttpRes
&req,
(),
|state, user, _, _| user_core::reset_totp(state, user),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -768,7 +801,10 @@ pub async fn check_two_factor_auth_status(
&req,
(),
|state, user, _, _| user_core::check_two_factor_auth_status(state, user),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -940,7 +976,10 @@ pub async fn list_orgs_for_user(state: web::Data<AppState>, req: HttpRequest) ->
&req,
(),
|state, user_from_token, _, _| user_core::list_orgs_for_user(state, user_from_token),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -960,7 +999,10 @@ pub async fn list_merchants_for_user_in_org(
|state, user_from_token, _, _| {
user_core::list_merchants_for_user_in_org(state, user_from_token)
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -980,7 +1022,10 @@ pub async fn list_profiles_for_user_in_org_and_merchant(
|state, user_from_token, _, _| {
user_core::list_profiles_for_user_in_org_and_merchant_account(state, user_from_token)
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -998,7 +1043,10 @@ pub async fn switch_org_for_user(
&http_req,
json_payload.into_inner(),
|state, user, req, _| user_core::switch_org_for_user(state, req, user),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -1016,7 +1064,10 @@ pub async fn switch_merchant_for_user_in_org(
&http_req,
json_payload.into_inner(),
|state, user, req, _| user_core::switch_merchant_for_user_in_org(state, req, user),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -1036,7 +1087,10 @@ pub async fn switch_profile_for_user_in_org_and_merchant(
|state, user, req, _| {
user_core::switch_profile_for_user_in_org_and_merchant(state, req, user)
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -1058,6 +1112,8 @@ pub async fn clone_connector(
|state, _: auth::UserFromToken, req, _| user_core::clone_connector(state, req),
&auth::JWTAuth {
permission: Permission::MerchantInternalConnectorWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -1112,6 +1168,8 @@ pub async fn embedded_token_info(
&auth::JWTAndEmbeddedAuth {
merchant_id_from_route: None,
permission: None,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/user/theme.rs b/crates/router/src/routes/user/theme.rs
index 2046df29ce..9a554e08e9 100644
--- a/crates/router/src/routes/user/theme.rs
+++ b/crates/router/src/routes/user/theme.rs
@@ -156,6 +156,8 @@ pub async fn create_user_theme(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -179,6 +181,8 @@ pub async fn get_user_theme_using_theme_id(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -205,6 +209,8 @@ pub async fn update_user_theme(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -229,6 +235,8 @@ pub async fn delete_user_theme(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -258,6 +266,8 @@ pub async fn upload_file_to_user_theme_storage(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -282,6 +292,8 @@ pub async fn list_all_themes_in_lineage(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -306,6 +318,8 @@ pub async fn get_user_theme_using_lineage(
},
&auth::JWTAuth {
permission: Permission::OrganizationThemeRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/user_role.rs b/crates/router/src/routes/user_role.rs
index 6247761d61..6db29a70dd 100644
--- a/crates/router/src/routes/user_role.rs
+++ b/crates/router/src/routes/user_role.rs
@@ -32,6 +32,8 @@ pub async fn get_authorization_info(
},
&auth::JWTAuth {
permission: Permission::MerchantUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -49,7 +51,10 @@ pub async fn get_role_from_token(state: web::Data<AppState>, req: HttpRequest) -
|state, user, _, _| async move {
role_core::get_role_from_token_with_groups(state, user).await
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -69,7 +74,10 @@ pub async fn get_groups_and_resources_for_role_from_token(
|state, user, _, _| async move {
role_core::get_groups_and_resources_for_role_from_token(state, user).await
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -89,7 +97,10 @@ pub async fn get_parent_groups_info_for_role_from_token(
|state, user, _, _| async move {
role_core::get_parent_groups_info_for_role_from_token(state, user).await
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -110,6 +121,8 @@ pub async fn create_role(
role_core::create_role,
&auth::JWTAuth {
permission: Permission::MerchantUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -130,6 +143,8 @@ pub async fn create_role_v2(
role_core::create_role_v2,
&auth::JWTAuth {
permission: Permission::MerchantUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -155,6 +170,8 @@ pub async fn get_role(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -180,6 +197,8 @@ pub async fn get_parent_info_for_role(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -203,6 +222,8 @@ pub async fn update_role(
|state, user, req, _| role_core::update_role(state, user, req, &role_id),
&auth::JWTAuth {
permission: Permission::MerchantUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -224,6 +245,8 @@ pub async fn update_user_role(
user_role_core::update_user_role,
&auth::JWTAuth {
permission: Permission::ProfileUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -243,7 +266,10 @@ pub async fn accept_invitations_v2(
&req,
payload,
|state, user, req_body, _| user_role_core::accept_invitations_v2(state, user, req_body),
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -284,6 +310,8 @@ pub async fn delete_user_role(
user_role_core::delete_user_role,
&auth::JWTAuth {
permission: Permission::ProfileUserWrite,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -306,6 +334,8 @@ pub async fn get_role_information(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -329,6 +359,8 @@ pub async fn get_parent_group_info(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -350,7 +382,10 @@ pub async fn list_users_in_lineage(
|state, user_from_token, request, _| {
user_role_core::list_users_in_lineage(state, user_from_token, request)
},
- &auth::DashboardNoPermissionAuth,
+ &auth::DashboardNoPermissionAuth {
+ allow_connected: true,
+ allow_platform: true,
+ },
api_locking::LockAction::NotApplicable,
))
.await
@@ -373,6 +408,8 @@ pub async fn list_roles_with_info(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -401,6 +438,8 @@ pub async fn list_invitable_roles_at_entity_level(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
@@ -429,6 +468,8 @@ pub async fn list_updatable_roles_at_entity_level(
},
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
+ allow_connected: true,
+ allow_platform: true,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/verification.rs b/crates/router/src/routes/verification.rs
index 9566a6f737..0b5cd8b1a0 100644
--- a/crates/router/src/routes/verification.rs
+++ b/crates/router/src/routes/verification.rs
@@ -38,6 +38,8 @@ pub async fn apple_pay_merchant_registration(
}),
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -76,6 +78,8 @@ pub async fn apple_pay_merchant_registration(
},
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -113,6 +117,8 @@ pub async fn retrieve_apple_pay_verified_domains(
}),
&auth::JWTAuth {
permission: Permission::MerchantAccountRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/routes/verify_connector.rs b/crates/router/src/routes/verify_connector.rs
index b7d44fd012..376cce0349 100644
--- a/crates/router/src/routes/verify_connector.rs
+++ b/crates/router/src/routes/verify_connector.rs
@@ -30,6 +30,8 @@ pub async fn payment_connector_verify(
},
&auth::JWTAuth {
permission: Permission::MerchantConnectorWrite,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
diff --git a/crates/router/src/routes/webhook_events.rs b/crates/router/src/routes/webhook_events.rs
index 27bec80589..f85389a409 100644
--- a/crates/router/src/routes/webhook_events.rs
+++ b/crates/router/src/routes/webhook_events.rs
@@ -48,6 +48,8 @@ pub async fn list_initial_webhook_delivery_attempts(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantWebhookEventRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -90,6 +92,8 @@ pub async fn list_initial_webhook_delivery_attempts_with_jwtauth(
},
&auth::JWTAuth {
permission: Permission::ProfileWebhookEventRead,
+ allow_connected: true,
+ allow_platform: false,
},
api_locking::LockAction::NotApplicable,
))
@@ -127,6 +131,8 @@ pub async fn list_webhook_delivery_attempts(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantWebhookEventRead,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
@@ -167,6 +173,8 @@ pub async fn retry_webhook_delivery_attempt(
&auth::JWTAuthMerchantFromRoute {
merchant_id,
required_permission: Permission::MerchantWebhookEventWrite,
+ allow_connected: true,
+ allow_platform: false,
},
req.headers(),
),
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 307cf2e3a6..4f46da7546 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -3534,6 +3534,8 @@ where
#[derive(Debug)]
pub(crate) struct JWTAuth {
pub permission: Permission,
+ pub allow_connected: bool,
+ pub allow_platform: bool,
}
#[async_trait]
@@ -3871,10 +3873,14 @@ where
pub struct JWTAuthMerchantFromRoute {
pub merchant_id: id_type::MerchantId,
pub required_permission: Permission,
+ pub allow_connected: bool,
+ pub allow_platform: bool,
}
pub struct JWTAuthMerchantFromHeader {
pub required_permission: Permission,
+ pub allow_connected: bool,
+ pub allow_platform: bool,
}
#[async_trait]
@@ -3973,6 +3979,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4102,6 +4115,13 @@ where
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4280,6 +4300,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4359,6 +4386,13 @@ where
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4446,6 +4480,8 @@ pub struct JWTAuthMerchantAndProfileFromRoute {
pub merchant_id: id_type::MerchantId,
pub profile_id: id_type::ProfileId,
pub required_permission: Permission,
+ pub allow_connected: bool,
+ pub allow_platform: bool,
}
#[cfg(feature = "v1")]
@@ -4506,6 +4542,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4538,6 +4581,8 @@ where
pub struct JWTAuthProfileFromRoute {
pub profile_id: id_type::ProfileId,
pub required_permission: Permission,
+ pub allow_connected: bool,
+ pub allow_platform: bool,
}
#[cfg(feature = "v1")]
@@ -4595,6 +4640,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4672,6 +4724,13 @@ where
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4779,6 +4838,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4860,6 +4926,13 @@ where
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4939,6 +5012,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -4966,7 +5046,10 @@ where
}
}
-pub struct DashboardNoPermissionAuth;
+pub struct DashboardNoPermissionAuth {
+ pub allow_connected: bool,
+ pub allow_platform: bool,
+}
#[cfg(feature = "olap")]
#[async_trait]
@@ -5094,6 +5177,13 @@ where
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = Some(domain::Initiator::Jwt {
user_id: payload.user_id.clone(),
});
@@ -5125,6 +5215,8 @@ where
pub struct JWTAndEmbeddedAuth {
pub merchant_id_from_route: Option<id_type::MerchantId>,
pub permission: Option<Permission>,
+ pub allow_connected: bool,
+ pub allow_platform: bool,
}
#[cfg(feature = "v1")]
@@ -5190,6 +5282,13 @@ where
|| Err(report!(errors::ApiErrorResponse::InvalidJwtToken)),
)?;
+ check_merchant_access_for_jwt(
+ state,
+ merchant.merchant_account_type,
+ self.allow_connected,
+ self.allow_platform,
+ )?;
+
let initiator = if let AuthOrEmbeddedClaims::AuthToken(ref auth_payload) = payload {
Some(domain::Initiator::Jwt {
user_id: auth_payload.user_id.clone(),
@@ -5968,6 +6067,52 @@ where
}
}
+/// Validates whether the merchant account type is authorized to access the resource for JWT authentication
+///
+/// # Access Control Logic for JWT:
+/// - **Connected Merchant**: Allowed if `allow_connected` is true
+/// - **Platform Merchant**: Allowed if `allow_platform` is true
+/// - **Standard Merchant**: Always allowed
+pub fn check_merchant_access_for_jwt<A>(
+ state: &A,
+ initiator_merchant_account_type: MerchantAccountType,
+ allow_connected: bool,
+ allow_platform: bool,
+) -> Result<(), error_stack::Report<errors::ApiErrorResponse>>
+where
+ A: SessionStateInfo + Sync,
+{
+ match initiator_merchant_account_type {
+ MerchantAccountType::Connected => {
+ // Check if platform feature is enabled
+ state.conf().platform.enabled.then_some(()).ok_or_else(|| {
+ report!(errors::ApiErrorResponse::ConnectedAccountAuthNotSupported)
+ .attach_printable("Platform feature is not enabled")
+ })?;
+
+ // Connected merchant can perform operation if allow_connected is true
+ allow_connected.then_some(()).ok_or_else(|| {
+ report!(errors::ApiErrorResponse::ConnectedAccountAuthNotSupported)
+ .attach_printable("Connected Merchant is not authorized to access the resource")
+ })
+ }
+ MerchantAccountType::Platform => {
+ // Check if platform feature is enabled
+ state.conf().platform.enabled.then_some(()).ok_or_else(|| {
+ report!(errors::ApiErrorResponse::PlatformAccountAuthNotSupported)
+ .attach_printable("Platform feature is not enabled")
+ })?;
+
+ // Platform merchant can perform operation if allow_platform is true
+ allow_platform.then_some(()).ok_or_else(|| {
+ report!(errors::ApiErrorResponse::PlatformAccountAuthNotSupported)
+ .attach_printable("Platform Merchant is not authorized to access the resource")
+ })
+ }
+ MerchantAccountType::Standard => Ok(()),
+ }
+}
+
/// Validates that a merchant account is a valid connected merchant for platform operations
fn validate_connected_merchant_account(
connected_merchant_account: &domain::MerchantAccount,