Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor: Added api-key auth for routing APIs (#8083)
Sarthak Soni278618cc1e20
diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rsindex c65a8c6b9e..e5cbd1b653 100644--- a/crates/router/src/core/routing/helpers.rs+++ b/crates/router/src/core/routing/helpers.rs@@ -1752,10 +1752,13 @@ wherelet algo_type_enabled_features = algo_type.get_enabled_features();if *algo_type_enabled_features == feature_to_enable {// algorithm already has the required feature- return Err(errors::ApiErrorResponse::PreconditionFailed {- message: format!("{} is already enabled", dynamic_routing_type),- }- .into());+ let routing_algorithm = db+ .find_routing_algorithm_by_profile_id_algorithm_id(&profile_id, &algo_type_algorithm_id)+ .await+ .to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?;+ let updated_routing_record = routing_algorithm.foreign_into();++ return Ok(ApplicationResponse::Json(updated_routing_record));};*algo_type_enabled_features = feature_to_enable;dynamic_routing_algo_ref.update_enabled_features(dynamic_routing_type, feature_to_enable);diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rsindex 3dcc947d13..ba041cbe5a 100644--- a/crates/router/src/routes/routing.rs+++ b/crates/router/src/routes/routing.rs@@ -42,7 +42,6 @@ pub async fn routing_create_config(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -53,10 +52,6 @@ pub async fn routing_create_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::ProfileRoutingWrite,- },api_locking::LockAction::NotApplicable,)).await@@ -134,7 +129,6 @@ pub async fn routing_link_config(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -145,10 +139,6 @@ pub async fn routing_link_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::ProfileRoutingWrite,- },api_locking::LockAction::NotApplicable,)).await@@ -233,7 +223,6 @@ pub async fn routing_retrieve_config(algorithm_id,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -244,10 +233,6 @@ pub async fn routing_retrieve_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::ProfileRoutingRead,- },api_locking::LockAction::NotApplicable,)).await@@ -324,7 +309,6 @@ pub async fn list_routing_configs(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -335,10 +319,6 @@ pub async fn list_routing_configs(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::MerchantRoutingRead,- },api_locking::LockAction::NotApplicable,)).await@@ -370,7 +350,6 @@ pub async fn list_routing_configs_for_profile(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -381,10 +360,6 @@ pub async fn list_routing_configs_for_profile(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::ProfileRoutingRead,- },api_locking::LockAction::NotApplicable,)).await@@ -464,7 +439,6 @@ pub async fn routing_unlink_config(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -475,10 +449,6 @@ pub async fn routing_unlink_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::ProfileRoutingWrite,- },api_locking::LockAction::NotApplicable,)).await@@ -556,7 +526,6 @@ pub async fn routing_update_default_config(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -567,10 +536,6 @@ pub async fn routing_update_default_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::MerchantRoutingWrite,- },api_locking::LockAction::NotApplicable,)).await@@ -644,9 +609,16 @@ pub async fn routing_retrieve_default_config(transaction_type,)},- &auth::JWTAuth {- permission: Permission::ProfileRoutingRead,- },+ auth::auth_type(+ &auth::HeaderAuth(auth::ApiKeyAuth {+ is_connected_allowed: false,+ is_platform_allowed: false,+ }),+ &auth::JWTAuth {+ permission: Permission::ProfileRoutingRead,+ },+ req.headers(),+ ),api_locking::LockAction::NotApplicable,)).await@@ -992,7 +964,6 @@ pub async fn routing_retrieve_linked_config(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -1004,11 +975,6 @@ pub async fn routing_retrieve_linked_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuthProfileFromRoute {- profile_id,- required_permission: Permission::ProfileRoutingRead,- },api_locking::LockAction::NotApplicable,)).await@@ -1030,7 +996,6 @@ pub async fn routing_retrieve_linked_config(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -1041,10 +1006,6 @@ pub async fn routing_retrieve_linked_config(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuth {- permission: Permission::ProfileRoutingRead,- },api_locking::LockAction::NotApplicable,)).await@@ -1184,7 +1145,6 @@ pub async fn routing_update_default_config_for_profile(transaction_type,)},- #[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -1196,11 +1156,6 @@ pub async fn routing_update_default_config_for_profile(},req.headers(),),- #[cfg(feature = "release")]- &auth::JWTAuthProfileFromRoute {- profile_id: routing_payload_wrapper.profile_id,- required_permission: Permission::ProfileRoutingWrite,- },api_locking::LockAction::NotApplicable,)).await