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(core): use secrets for connector AuthType in connector integration (#1441)
Shankar Singh Cd068569f4deb
diff --git a/connector-template/transformers.rs b/connector-template/transformers.rsindex d76b63a1f3..ac51bb5e38 100644--- a/connector-template/transformers.rs+++ b/connector-template/transformers.rs@@ -53,7 +53,7 @@ impl TryFrom<&types::ConnectorAuthType> for {{project-name | downcase | pascal_cfn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: Secret::new(api_key.to_string()),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rsindex b6e37ca78e..5bed999903 100644--- a/crates/router/src/connector/aci.rs+++ b/crates/router/src/connector/aci.rs@@ -3,6 +3,7 @@ mod transformers;use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as aci;use super::utils::PaymentsAuthorizeRequestData;@@ -152,7 +153,7 @@ impl.get_connector_transaction_id().change_context(errors::ConnectorError::MissingConnectorTransactionID)?,"?entityId=",- auth.entity_id+ auth.entity_id.peek()))}diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rsindex 228506cdc0..96d1b3e3dc 100644--- a/crates/router/src/connector/aci/transformers.rs+++ b/crates/router/src/connector/aci/transformers.rs@@ -18,8 +18,8 @@ use crate::{type Error = error_stack::Report<errors::ConnectorError>;pub struct AciAuthType {- pub api_key: String,- pub entity_id: String,+ pub api_key: Secret<String>,+ pub entity_id: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for AciAuthType {@@ -27,8 +27,8 @@ impl TryFrom<&types::ConnectorAuthType> for AciAuthType {fn try_from(item: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::BodyKey { api_key, key1 } = item {Ok(Self {- api_key: api_key.to_string(),- entity_id: key1.to_string(),+ api_key: api_key.to_owned(),+ entity_id: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?@@ -51,7 +51,7 @@ pub struct AciPaymentsRequest {#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct TransactionDetails {- pub entity_id: String,+ pub entity_id: Secret<String>,pub amount: String,pub currency: String,pub payment_type: AciPaymentType,@@ -60,7 +60,7 @@ pub struct TransactionDetails {#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]pub struct AciCancelRequest {- pub entity_id: String,+ pub entity_id: Secret<String>,pub payment_type: AciPaymentType,}@@ -688,7 +688,7 @@ pub struct AciRefundRequest {pub amount: String,pub currency: String,pub payment_type: AciPaymentType,- pub entity_id: String,+ pub entity_id: Secret<String>,}impl<F> TryFrom<&types::RefundsRouterData<F>> for AciRefundRequest {diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rsindex b2fdc683e7..3d5b4d9609 100644--- a/crates/router/src/connector/adyen.rs+++ b/crates/router/src/connector/adyen.rs@@ -710,7 +710,7 @@ impl services::ConnectorIntegration<api::PoCancel, types::PayoutsData, types::Pa.change_context(errors::ConnectorError::FailedToObtainAuthType)?;let mut api_key = vec![(headers::X_API_KEY.to_string(),- auth.review_key.unwrap_or(auth.api_key).into(),+ auth.review_key.unwrap_or(auth.api_key).into_masked(),)];header.append(&mut api_key);Ok(header)@@ -980,8 +980,10 @@ impl services::ConnectorIntegration<api::PoFulfill, types::PayoutsData, types::Plet mut api_key = vec![(headers::X_API_KEY.to_string(),match req.request.payout_type {- storage_enums::PayoutType::Bank => auth.review_key.unwrap_or(auth.api_key).into(),- storage_enums::PayoutType::Card => auth.api_key.into(),+ storage_enums::PayoutType::Bank => {+ auth.review_key.unwrap_or(auth.api_key).into_masked()+ }+ storage_enums::PayoutType::Card => auth.api_key.into_masked(),},)];header.append(&mut api_key);diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 7ac4773fa8..0b5c39579e 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -109,7 +109,7 @@ pub struct LineItem {#[serde(rename_all = "camelCase")]pub struct AdyenPaymentRequest<'a> {amount: Amount,- merchant_account: String,+ merchant_account: Secret<String>,payment_method: AdyenPaymentMethod<'a>,reference: String,return_url: String,@@ -686,7 +686,7 @@ pub enum CardBrand {#[derive(Default, Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct AdyenCancelRequest {- merchant_account: String,+ merchant_account: Secret<String>,reference: String,}@@ -739,7 +739,7 @@ pub struct AdyenApplePay {#[derive(Default, Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct AdyenRefundRequest {- merchant_account: String,+ merchant_account: Secret<String>,amount: Amount,merchant_refund_reason: Option<String>,reference: String,@@ -762,10 +762,10 @@ pub struct QrCodeNextInstructions {}pub struct AdyenAuthType {- pub(super) api_key: String,- pub(super) merchant_account: String,+ pub(super) api_key: Secret<String>,+ pub(super) merchant_account: Secret<String>,#[allow(dead_code)]- pub(super) review_key: Option<String>,+ pub(super) review_key: Option<Secret<String>>,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -938,8 +938,8 @@ impl TryFrom<&types::ConnectorAuthType> for AdyenAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- api_key: api_key.to_string(),- merchant_account: key1.to_string(),+ api_key: api_key.to_owned(),+ merchant_account: key1.to_owned(),review_key: None,}),types::ConnectorAuthType::SignatureKey {@@ -947,9 +947,9 @@ impl TryFrom<&types::ConnectorAuthType> for AdyenAuthType {key1,api_secret,} => Ok(Self {- api_key: api_key.to_string(),- merchant_account: key1.to_string(),- review_key: Some(api_secret.to_string()),+ api_key: api_key.to_owned(),+ merchant_account: key1.to_owned(),+ review_key: Some(api_secret.to_owned()),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}@@ -2280,7 +2280,7 @@ impl<F, Req>#[derive(Default, Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct AdyenCaptureRequest {- merchant_account: String,+ merchant_account: Secret<String>,amount: Amount,reference: String,}@@ -2600,7 +2600,7 @@ impl From<AdyenNotificationRequestItemWH> for Response {pub struct AdyenPayoutCreateRequest {amount: Amount,recurring: RecurringContract,- merchant_account: String,+ merchant_account: Secret<String>,bank: PayoutBankDetails,reference: String,shopper_reference: String,@@ -2661,7 +2661,7 @@ pub struct AdyenPayoutResponse {#[serde(rename_all = "camelCase")]pub struct AdyenPayoutEligibilityRequest {amount: Amount,- merchant_account: String,+ merchant_account: Secret<String>,payment_method: PayoutCardDetails,reference: String,shopper_reference: String,@@ -2705,7 +2705,7 @@ pub enum AdyenPayoutFulfillRequest {#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct PayoutFulfillBankRequest {- merchant_account: String,+ merchant_account: Secret<String>,original_reference: String,}@@ -2716,7 +2716,7 @@ pub struct PayoutFulfillCardRequest {amount: Amount,card: PayoutCardDetails,billing_address: Option<Address>,- merchant_account: String,+ merchant_account: Secret<String>,reference: String,shopper_name: ShopperName,nationality: Option<storage_enums::CountryAlpha2>,@@ -2728,7 +2728,7 @@ pub struct PayoutFulfillCardRequest {#[serde(rename_all = "camelCase")]pub struct AdyenPayoutCancelRequest {original_reference: String,- merchant_account: String,+ merchant_account: Secret<String>,}// Payouts eligibility request transformdiff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rsindex 30ed42d448..7cd5eb7124 100644--- a/crates/router/src/connector/airwallex.rs+++ b/crates/router/src/connector/airwallex.rs@@ -4,6 +4,7 @@ use std::fmt::Debug;use common_utils::ext_traits::{ByteSliceExt, ValueExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as airwallex;use super::utils::{AccessTokenRequestInfo, RefundsRequestData};@@ -50,7 +51,7 @@ wherelet auth_header = (headers::AUTHORIZATION.to_string(),- format!("Bearer {}", access_token.token).into_masked(),+ format!("Bearer {}", access_token.token.peek()).into_masked(),);headers.push(auth_header);diff --git a/crates/router/src/connector/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rsindex f05e242a7c..68b990951b 100644--- a/crates/router/src/connector/airwallex/transformers.rs+++ b/crates/router/src/connector/airwallex/transformers.rs@@ -170,7 +170,7 @@ fn get_wallet_details(pub struct AirwallexAuthUpdateResponse {#[serde(with = "common_utils::custom_serde::iso8601")]expires_at: PrimitiveDateTime,- token: String,+ token: Secret<String>,}impl<F, T> TryFrom<types::ResponseRouterData<F, AirwallexAuthUpdateResponse, T, types::AccessToken>>diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rsindex e0924797e1..aaaadd77ed 100644--- a/crates/router/src/connector/authorizedotnet/transformers.rs+++ b/crates/router/src/connector/authorizedotnet/transformers.rs@@ -34,8 +34,8 @@ pub enum TransactionType {#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]struct MerchantAuthentication {- name: String,- transaction_key: String,+ name: Secret<String>,+ transaction_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for MerchantAuthentication {@@ -44,8 +44,8 @@ impl TryFrom<&types::ConnectorAuthType> for MerchantAuthentication {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {Ok(Self {- name: api_key.clone(),- transaction_key: key1.clone(),+ name: api_key.to_owned(),+ transaction_key: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/bambora/transformers.rs b/crates/router/src/connector/bambora/transformers.rsindex 61e3366c3d..d34dda73eb 100644--- a/crates/router/src/connector/bambora/transformers.rs+++ b/crates/router/src/connector/bambora/transformers.rs@@ -1,7 +1,7 @@use base64::Engine;use common_utils::ext_traits::ValueExt;use error_stack::{IntoReport, ResultExt};-use masking::Secret;+use masking::{PeekInterface, Secret};use serde::{Deserialize, Deserializer, Serialize};use crate::{@@ -149,17 +149,17 @@ impl TryFrom<&types::PaymentsCancelRouterData> for BamboraPaymentsRequest {}pub struct BamboraAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for BamboraAuthType {type Error = error_stack::Report<errors::ConnectorError>;fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {- let auth_key = format!("{key1}:{api_key}");+ let auth_key = format!("{}:{}", key1.peek(), api_key.peek());let auth_header = format!("Passcode {}", consts::BASE64_ENGINE.encode(auth_key));Ok(Self {- api_key: auth_header,+ api_key: Secret::new(auth_header),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/bitpay.rs b/crates/router/src/connector/bitpay.rsindex bc386b8ed9..eeb9802026 100644--- a/crates/router/src/connector/bitpay.rs+++ b/crates/router/src/connector/bitpay.rs@@ -4,6 +4,7 @@ use std::fmt::Debug;use common_utils::{errors::ReportSwitchExt, ext_traits::ByteSliceExt};use error_stack::ResultExt;+use masking::PeekInterface;use transformers as bitpay;use self::bitpay::BitpayWebhookDetails;@@ -247,7 +248,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe"{}/invoices/{}?token={}",self.base_url(connectors),connector_id,- auth.api_key+ auth.api_key.peek(),))}diff --git a/crates/router/src/connector/bitpay/transformers.rs b/crates/router/src/connector/bitpay/transformers.rsindex febafdf430..f99729da16 100644--- a/crates/router/src/connector/bitpay/transformers.rs+++ b/crates/router/src/connector/bitpay/transformers.rs@@ -40,7 +40,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BitpayPaymentsRequest {// Auth Structpub struct BitpayAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&ConnectorAuthType> for BitpayAuthType {@@ -48,7 +48,7 @@ impl TryFrom<&ConnectorAuthType> for BitpayAuthType {fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}@@ -242,7 +242,7 @@ fn get_crypto_specific_payment_data(let auth_type = item.connector_auth_type.clone();let token = match auth_type {ConnectorAuthType::HeaderKey { api_key } => api_key,- _ => String::default(),+ _ => String::default().into(),};Ok(BitpayPaymentsRequest {@@ -251,7 +251,7 @@ fn get_crypto_specific_payment_data(redirect_url,notification_url,transaction_speed,- token: Secret::new(token),+ token,})}diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rsindex 78a8b8dc2d..296b641e35 100644--- a/crates/router/src/connector/bluesnap.rs+++ b/crates/router/src/connector/bluesnap.rs@@ -8,6 +8,7 @@ use common_utils::{ext_traits::{StringExt, ValueExt},};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as bluesnap;use super::utils::{@@ -79,7 +80,7 @@ impl ConnectorCommon for Bluesnap {.try_into().change_context(errors::ConnectorError::FailedToObtainAuthType)?;let encoded_api_key =- consts::BASE64_ENGINE.encode(format!("{}:{}", auth.key1, auth.api_key));+ consts::BASE64_ENGINE.encode(format!("{}:{}", auth.key1.peek(), auth.api_key.peek()));Ok(vec![(headers::AUTHORIZATION.to_string(),format!("Basic {encoded_api_key}").into_masked(),diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rsindex c754ae6d1c..0b5f5eef40 100644--- a/crates/router/src/connector/bluesnap/transformers.rs+++ b/crates/router/src/connector/bluesnap/transformers.rs@@ -516,8 +516,8 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for BluesnapCaptureRequest {// Auth Structpub struct BluesnapAuthType {- pub(super) api_key: String,- pub(super) key1: String,+ pub(super) api_key: Secret<String>,+ pub(super) key1: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for BluesnapAuthType {@@ -525,8 +525,8 @@ impl TryFrom<&types::ConnectorAuthType> for BluesnapAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {Ok(Self {- api_key: api_key.to_string(),- key1: key1.to_string(),+ api_key: api_key.to_owned(),+ key1: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/boku/transformers.rs b/crates/router/src/connector/boku/transformers.rsindex 48cd694c15..885ba5172d 100644--- a/crates/router/src/connector/boku/transformers.rs+++ b/crates/router/src/connector/boku/transformers.rs@@ -56,7 +56,7 @@ impl TryFrom<&types::ConnectorAuthType> for BokuAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: Secret::new(api_key.to_string()),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rsindex 19c0295910..717bf1747c 100644--- a/crates/router/src/connector/braintree.rs+++ b/crates/router/src/connector/braintree.rs@@ -3,6 +3,7 @@ mod transformers;use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use self::transformers as braintree;use crate::{@@ -111,7 +112,7 @@ implOk(format!("{}/merchants/{}/client_token",self.base_url(connectors),- auth_type.merchant_id,+ auth_type.merchant_id.peek(),))}@@ -265,7 +266,7 @@ implOk(format!("{}/merchants/{}/transactions/{}",self.base_url(connectors),- auth_type.merchant_id,+ auth_type.merchant_id.peek(),connector_payment_id))}@@ -369,7 +370,7 @@ implOk(format!("{}merchants/{}/transactions",self.base_url(connectors),- auth_type.merchant_id+ auth_type.merchant_id.peek()))}@@ -485,7 +486,7 @@ implOk(format!("{}merchants/{}/transactions/{}/void",self.base_url(connectors),- auth_type.merchant_id,+ auth_type.merchant_id.peek(),req.request.connector_transaction_id))}@@ -593,7 +594,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::RefOk(format!("{}merchants/{}/transactions/{}",self.base_url(connectors),- auth_type.merchant_id,+ auth_type.merchant_id.peek(),connector_payment_id))}diff --git a/crates/router/src/connector/braintree/transformers.rs b/crates/router/src/connector/braintree/transformers.rsindex 57d8755b2d..4f37bcc171 100644--- a/crates/router/src/connector/braintree/transformers.rs+++ b/crates/router/src/connector/braintree/transformers.rs@@ -1,6 +1,6 @@use api_models::payments;use base64::Engine;-use masking::Secret;+use masking::{PeekInterface, Secret};use serde::{Deserialize, Serialize};use crate::{@@ -138,7 +138,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest {pub struct BraintreeAuthType {pub(super) auth_header: String,- pub(super) merchant_id: String,+ pub(super) merchant_id: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for BraintreeAuthType {@@ -150,7 +150,7 @@ impl TryFrom<&types::ConnectorAuthType> for BraintreeAuthType {api_secret: private_key,} = item{- let auth_key = format!("{public_key}:{private_key}");+ let auth_key = format!("{}:{}", public_key.peek(), private_key.peek());let auth_header = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_key));Ok(Self {auth_header,diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rsindex 9ecaeffec3..249ca3fe61 100644--- a/crates/router/src/connector/cashtocode.rs+++ b/crates/router/src/connector/cashtocode.rs@@ -3,6 +3,7 @@ mod transformers;use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as cashtocode;use crate::{@@ -51,14 +52,14 @@ fn get_auth_cashtocode(storage::enums::PaymentMethodType::ClassicReward => match auth_type {types::ConnectorAuthType::BodyKey { api_key, .. } => Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Basic {api_key}").into_masked(),+ format!("Basic {}", api_key.peek()).into_masked(),)]),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),},storage::enums::PaymentMethodType::Evoucher => match auth_type {types::ConnectorAuthType::BodyKey { key1, .. } => Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Basic {key1}").into_masked(),+ format!("Basic {}", key1.peek()).into_masked(),)]),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),},diff --git a/crates/router/src/connector/cashtocode/transformers.rs b/crates/router/src/connector/cashtocode/transformers.rsindex bd899a8c78..4c9582deaf 100644--- a/crates/router/src/connector/cashtocode/transformers.rs+++ b/crates/router/src/connector/cashtocode/transformers.rs@@ -83,7 +83,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for CashtocodePaymentsRequest}pub struct CashtocodeAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for CashtocodeAuthType {@@ -91,7 +91,7 @@ impl TryFrom<&types::ConnectorAuthType> for CashtocodeAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rsindex 1824124b43..c9d4edce7e 100644--- a/crates/router/src/connector/checkout.rs+++ b/crates/router/src/connector/checkout.rs@@ -6,6 +6,7 @@ use std::fmt::Debug;use common_utils::{crypto, ext_traits::ByteSliceExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use self::transformers as checkout;use super::utils::{self as conn_utils, RefundsRequestData};@@ -71,7 +72,7 @@ impl ConnectorCommon for Checkout {.change_context(errors::ConnectorError::FailedToObtainAuthType)?;Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", auth.api_secret).into_masked(),+ format!("Bearer {}", auth.api_secret.peek()).into_masked(),)])}@@ -153,7 +154,7 @@ impl.change_context(errors::ConnectorError::FailedToObtainAuthType)?;let mut auth = vec![(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", api_key.api_key).into_masked(),+ format!("Bearer {}", api_key.api_key.peek()).into_masked(),)];header.append(&mut auth);Ok(header)diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rsindex ed366b3449..ca51a732c4 100644--- a/crates/router/src/connector/checkout/transformers.rs+++ b/crates/router/src/connector/checkout/transformers.rs@@ -1,6 +1,6 @@use common_utils::errors::CustomResult;use error_stack::{IntoReport, ResultExt};-use masking::ExposeInterface;+use masking::{ExposeInterface, Secret};use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;use url::Url;@@ -8,7 +8,7 @@ use url::Url;use crate::{connector::utils::{RouterData, WalletData},core::errors,- pii, services,+ services,types::{self, api, storage::enums, transformers::ForeignFrom},};@@ -23,25 +23,25 @@ pub enum TokenRequest {#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct CheckoutGooglePayData {- protocol_version: pii::Secret<String>,- signature: pii::Secret<String>,- signed_message: pii::Secret<String>,+ protocol_version: Secret<String>,+ signature: Secret<String>,+ signed_message: Secret<String>,}#[derive(Debug, Serialize, Deserialize)]pub struct CheckoutApplePayData {- version: pii::Secret<String>,- data: pii::Secret<String>,- signature: pii::Secret<String>,+ version: Secret<String>,+ data: Secret<String>,+ signature: Secret<String>,header: CheckoutApplePayHeader,}#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct CheckoutApplePayHeader {- ephemeral_public_key: pii::Secret<String>,- public_key_hash: pii::Secret<String>,- transaction_id: pii::Secret<String>,+ ephemeral_public_key: Secret<String>,+ public_key_hash: Secret<String>,+ transaction_id: Secret<String>,}impl TryFrom<&types::TokenizationRouterData> for TokenRequest {@@ -74,7 +74,7 @@ impl TryFrom<&types::TokenizationRouterData> for TokenRequest {#[derive(Debug, Eq, PartialEq, Deserialize)]pub struct CheckoutTokenResponse {- token: pii::Secret<String>,+ token: Secret<String>,}impl<F, T>@@ -99,9 +99,9 @@ pub struct CardSource {#[serde(rename = "type")]pub source_type: CheckoutSourceTypes,pub number: cards::CardNumber,- pub expiry_month: pii::Secret<String>,- pub expiry_year: pii::Secret<String>,- pub cvv: pii::Secret<String>,+ pub expiry_month: Secret<String>,+ pub expiry_year: Secret<String>,+ pub cvv: Secret<String>,}#[derive(Debug, Serialize)]@@ -126,9 +126,9 @@ pub enum CheckoutSourceTypes {}pub struct CheckoutAuthType {- pub(super) api_key: String,- pub(super) processing_channel_id: String,- pub(super) api_secret: String,+ pub(super) api_key: Secret<String>,+ pub(super) processing_channel_id: Secret<String>,+ pub(super) api_secret: Secret<String>,}#[derive(Debug, Serialize)]@@ -142,7 +142,7 @@ pub struct PaymentsRequest {pub source: PaymentSource,pub amount: i64,pub currency: String,- pub processing_channel_id: String,+ pub processing_channel_id: Secret<String>,#[serde(rename = "3ds")]pub three_ds: CheckoutThreeDS,#[serde(flatten)]@@ -167,9 +167,9 @@ impl TryFrom<&types::ConnectorAuthType> for CheckoutAuthType {} = auth_type{Ok(Self {- api_key: api_key.to_string(),- api_secret: api_secret.to_string(),- processing_channel_id: key1.to_string(),+ api_key: api_key.to_owned(),+ api_secret: api_secret.to_owned(),+ processing_channel_id: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())@@ -459,7 +459,7 @@ pub enum CaptureType {pub struct PaymentCaptureRequest {pub amount: Option<i64>,pub capture_type: Option<CaptureType>,- pub processing_channel_id: String,+ pub processing_channel_id: Secret<String>,}impl TryFrom<&types::PaymentsCaptureRouterData> for PaymentCaptureRequest {diff --git a/crates/router/src/connector/coinbase/transformers.rs b/crates/router/src/connector/coinbase/transformers.rsindex c13a0b1782..96632cfff6 100644--- a/crates/router/src/connector/coinbase/transformers.rs+++ b/crates/router/src/connector/coinbase/transformers.rs@@ -41,7 +41,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for CoinbasePaymentsRequest {// Auth Structpub struct CoinbaseAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for CoinbaseAuthType {@@ -49,7 +49,7 @@ impl TryFrom<&types::ConnectorAuthType> for CoinbaseAuthType {fn try_from(_auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = _auth_type {Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/cryptopay/transformers.rs b/crates/router/src/connector/cryptopay/transformers.rsindex a998b9c04a..040e68a66e 100644--- a/crates/router/src/connector/cryptopay/transformers.rs+++ b/crates/router/src/connector/cryptopay/transformers.rs@@ -51,8 +51,8 @@ impl TryFrom<&types::ConnectorAuthType> for CryptopayAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {Ok(Self {- api_key: api_key.to_string().into(),- api_secret: key1.to_string().into(),+ api_key: api_key.to_owned(),+ api_secret: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rsindex 8d4ba97afc..ba8b35964f 100644--- a/crates/router/src/connector/cybersource.rs+++ b/crates/router/src/connector/cybersource.rs@@ -4,7 +4,7 @@ use std::fmt::Debug;use base64::Engine;use error_stack::{IntoReport, ResultExt};-use masking::PeekInterface;+use masking::{ExposeInterface, PeekInterface};use ring::{digest, hmac};use time::OffsetDateTime;use transformers as cybersource;@@ -60,17 +60,19 @@ impl Cybersource {format!("(request-target): get {resource}\n")};let signature_string = format!(- "host: {host}\ndate: {date}\n{request_target}v-c-merchant-id: {merchant_account}"+ "host: {host}\ndate: {date}\n{request_target}v-c-merchant-id: {}",+ merchant_account.peek());let key_value = consts::BASE64_ENGINE- .decode(api_secret)+ .decode(api_secret.expose()).into_report().change_context(errors::ConnectorError::RequestEncodingFailed)?;let key = hmac::Key::new(hmac::HMAC_SHA256, &key_value);let signature_value =consts::BASE64_ENGINE.encode(hmac::sign(&key, signature_string.as_bytes()).as_ref());let signature_header = format!(- r#"keyid="{api_key}", algorithm="HmacSHA256", headers="{headers}", signature="{signature_value}""#+ r#"keyid="{}", algorithm="HmacSHA256", headers="{headers}", signature="{signature_value}""#,+ api_key.peek());Ok(signature_header)@@ -162,7 +164,7 @@ wherelet sha256 = self.generate_digest(cybersource_req.map_or("{}".to_string(), |s| {- types::RequestBody::get_inner_value(s).peek().to_owned()+ types::RequestBody::get_inner_value(s).expose()}).as_bytes(),);diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rsindex 48b2c98c48..106ce2e3c2 100644--- a/crates/router/src/connector/cybersource/transformers.rs+++ b/crates/router/src/connector/cybersource/transformers.rs@@ -201,9 +201,9 @@ impl TryFrom<&types::RefundExecuteRouterData> for CybersourcePaymentsRequest {}pub struct CybersourceAuthType {- pub(super) api_key: String,- pub(super) merchant_account: String,- pub(super) api_secret: String,+ pub(super) api_key: Secret<String>,+ pub(super) merchant_account: Secret<String>,+ pub(super) api_secret: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for CybersourceAuthType {@@ -216,9 +216,9 @@ impl TryFrom<&types::ConnectorAuthType> for CybersourceAuthType {} = auth_type{Ok(Self {- api_key: api_key.to_string(),- merchant_account: key1.to_string(),- api_secret: api_secret.to_string(),+ api_key: api_key.to_owned(),+ merchant_account: key1.to_owned(),+ api_secret: api_secret.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/dlocal.rs b/crates/router/src/connector/dlocal.rsindex d22a23d2a4..be0855e435 100644--- a/crates/router/src/connector/dlocal.rs+++ b/crates/router/src/connector/dlocal.rs@@ -67,7 +67,7 @@ wherelet auth = dlocal::DlocalAuthType::try_from(&req.connector_auth_type)?;let sign_req: String = format!("{}{}{}",- auth.x_login,+ auth.x_login.peek(),date,types::RequestBody::get_inner_value(dlocal_req).peek()@@ -75,7 +75,7 @@ where);let authz = crypto::HmacSha256::sign_message(&crypto::HmacSha256,- auth.secret.as_bytes(),+ auth.secret.peek().as_bytes(),sign_req.as_bytes(),).change_context(errors::ConnectorError::RequestEncodingFailed)diff --git a/crates/router/src/connector/dlocal/transformers.rs b/crates/router/src/connector/dlocal/transformers.rsindex e49307fb1b..e6db1503e5 100644--- a/crates/router/src/connector/dlocal/transformers.rs+++ b/crates/router/src/connector/dlocal/transformers.rs@@ -191,9 +191,9 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for DlocalPaymentsCaptureRequest}// Auth Structpub struct DlocalAuthType {- pub(super) x_login: String,- pub(super) x_trans_key: String,- pub(super) secret: String,+ pub(super) x_login: Secret<String>,+ pub(super) x_trans_key: Secret<String>,+ pub(super) secret: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for DlocalAuthType {@@ -206,9 +206,9 @@ impl TryFrom<&types::ConnectorAuthType> for DlocalAuthType {} = auth_type{Ok(Self {- x_login: api_key.to_string(),- x_trans_key: key1.to_string(),- secret: api_secret.to_string(),+ x_login: api_key.to_owned(),+ x_trans_key: key1.to_owned(),+ secret: api_secret.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/dummyconnector/transformers.rs b/crates/router/src/connector/dummyconnector/transformers.rsindex a99a046773..adb917e3c1 100644--- a/crates/router/src/connector/dummyconnector/transformers.rs+++ b/crates/router/src/connector/dummyconnector/transformers.rs@@ -56,7 +56,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for DummyConnectorPaymentsRequ// Auth Structpub struct DummyConnectorAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for DummyConnectorAuthType {@@ -64,7 +64,7 @@ impl TryFrom<&types::ConnectorAuthType> for DummyConnectorAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/fiserv.rs b/crates/router/src/connector/fiserv.rsindex ba455a32cc..25a593f3ff 100644--- a/crates/router/src/connector/fiserv.rs+++ b/crates/router/src/connector/fiserv.rs@@ -4,7 +4,7 @@ use std::fmt::Debug;use base64::Engine;use error_stack::{IntoReport, ResultExt};-use masking::PeekInterface;+use masking::{ExposeInterface, PeekInterface};use ring::hmac;use time::OffsetDateTime;use transformers as fiserv;@@ -43,9 +43,9 @@ impl Fiserv {api_secret,..} = auth;- let raw_signature = format!("{api_key}{request_id}{timestamp}{payload}");+ let raw_signature = format!("{}{request_id}{timestamp}{payload}", api_key.peek());- let key = hmac::Key::new(hmac::HMAC_SHA256, api_secret.as_bytes());+ let key = hmac::Key::new(hmac::HMAC_SHA256, api_secret.expose().as_bytes());let signature_value =consts::BASE64_ENGINE.encode(hmac::sign(&key, raw_signature.as_bytes()).as_ref());Ok(signature_value)diff --git a/crates/router/src/connector/fiserv/transformers.rs b/crates/router/src/connector/fiserv/transformers.rsindex 8df6144313..6c6c346dcc 100644--- a/crates/router/src/connector/fiserv/transformers.rs+++ b/crates/router/src/connector/fiserv/transformers.rs@@ -67,7 +67,7 @@ pub struct TransactionDetails {#[derive(Default, Debug, Serialize, Eq, PartialEq)]#[serde(rename_all = "camelCase")]pub struct MerchantDetails {- merchant_id: String,+ merchant_id: Secret<String>,terminal_id: Option<String>,}@@ -156,9 +156,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for FiservPaymentsRequest {}pub struct FiservAuthType {- pub(super) api_key: String,- pub(super) merchant_account: String,- pub(super) api_secret: String,+ pub(super) api_key: Secret<String>,+ pub(super) merchant_account: Secret<String>,+ pub(super) api_secret: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for FiservAuthType {@@ -171,9 +171,9 @@ impl TryFrom<&types::ConnectorAuthType> for FiservAuthType {} = auth_type{Ok(Self {- api_key: api_key.to_string(),- merchant_account: key1.to_string(),- api_secret: api_secret.to_string(),+ api_key: api_key.to_owned(),+ merchant_account: key1.to_owned(),+ api_secret: api_secret.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/forte.rs b/crates/router/src/connector/forte.rsindex 53459d37a1..5dde831071 100644--- a/crates/router/src/connector/forte.rs+++ b/crates/router/src/connector/forte.rs@@ -4,6 +4,7 @@ use std::fmt::Debug;use base64::Engine;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as forte;use crate::{@@ -90,7 +91,11 @@ impl ConnectorCommon for Forte {let auth: forte::ForteAuthType = auth_type.try_into().change_context(errors::ConnectorError::FailedToObtainAuthType)?;- let raw_basic_token = format!("{}:{}", auth.api_access_id, auth.api_secret_key);+ let raw_basic_token = format!(+ "{}:{}",+ auth.api_access_id.peek(),+ auth.api_secret_key.peek()+ );let basic_token = format!("Basic {}", consts::BASE64_ENGINE.encode(raw_basic_token));Ok(vec![(@@ -164,8 +169,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::POk(format!("{}/organizations/{}/locations/{}/transactions",self.base_url(connectors),- auth.organization_id,- auth.location_id+ auth.organization_id.peek(),+ auth.location_id.peek()))}@@ -252,8 +257,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsReOk(format!("{}/organizations/{}/locations/{}/transactions/{}",self.base_url(connectors),- auth.organization_id,- auth.location_id,+ auth.organization_id.peek(),+ auth.location_id.peek(),txn_id))}@@ -320,8 +325,8 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::PaymeOk(format!("{}/organizations/{}/locations/{}/transactions",self.base_url(connectors),- auth.organization_id,- auth.location_id+ auth.organization_id.peek(),+ auth.location_id.peek()))}@@ -403,8 +408,8 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsROk(format!("{}/organizations/{}/locations/{}/transactions/{}",self.base_url(connectors),- auth.organization_id,- auth.location_id,+ auth.organization_id.peek(),+ auth.location_id.peek(),req.request.connector_transaction_id))}@@ -483,8 +488,8 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponOk(format!("{}/organizations/{}/locations/{}/transactions",self.base_url(connectors),- auth.organization_id,- auth.location_id+ auth.organization_id.peek(),+ auth.location_id.peek()))}@@ -564,8 +569,8 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseOk(format!("{}/organizations/{}/locations/{}/transactions/{}",self.base_url(connectors),- auth.organization_id,- auth.location_id,+ auth.organization_id.peek(),+ auth.location_id.peek(),req.request.get_connector_refund_id()?))}diff --git a/crates/router/src/connector/forte/transformers.rs b/crates/router/src/connector/forte/transformers.rsindex 3d125d36bb..144cefab4d 100644--- a/crates/router/src/connector/forte/transformers.rs+++ b/crates/router/src/connector/forte/transformers.rs@@ -1,5 +1,5 @@use cards::CardNumber;-use masking::Secret;+use masking::{PeekInterface, Secret};use serde::{Deserialize, Serialize};use crate::{@@ -112,10 +112,10 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for FortePaymentsRequest {// Auth Structpub struct ForteAuthType {- pub(super) api_access_id: String,- pub(super) organization_id: String,- pub(super) location_id: String,- pub(super) api_secret_key: String,+ pub(super) api_access_id: Secret<String>,+ pub(super) organization_id: Secret<String>,+ pub(super) location_id: Secret<String>,+ pub(super) api_secret_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for ForteAuthType {@@ -128,10 +128,10 @@ impl TryFrom<&types::ConnectorAuthType> for ForteAuthType {api_secret,key2,} => Ok(Self {- api_access_id: api_key.to_string(),- organization_id: format!("org_{}", key1),- location_id: format!("loc_{}", key2),- api_secret_key: api_secret.to_string(),+ api_access_id: api_key.to_owned(),+ organization_id: Secret::new(format!("org_{}", key1.peek())),+ location_id: Secret::new(format!("loc_{}", key2.peek())),+ api_secret_key: api_secret.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rsindex 9ca12514ec..e15da504a8 100644--- a/crates/router/src/connector/globalpay.rs+++ b/crates/router/src/connector/globalpay.rs@@ -6,6 +6,7 @@ use std::fmt::Debug;use ::common_utils::{errors::ReportSwitchExt, ext_traits::ByteSliceExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use serde_json::Value;use self::{@@ -62,7 +63,7 @@ where("X-GP-Version".to_string(), "2021-03-22".to_string().into()),(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", access_token.token).into_masked(),+ format!("Bearer {}", access_token.token.peek()).into_masked(),),])}diff --git a/crates/router/src/connector/globalpay/response.rs b/crates/router/src/connector/globalpay/response.rsindex 13cb2aad7e..7416d6f716 100644--- a/crates/router/src/connector/globalpay/response.rs+++ b/crates/router/src/connector/globalpay/response.rs@@ -1,3 +1,4 @@+use masking::Secret;use serde::{Deserialize, Serialize};use super::requests;@@ -71,7 +72,7 @@ pub struct Action {#[derive(Debug, Deserialize)]pub struct GlobalpayRefreshTokenResponse {- pub token: String,+ pub token: Secret<String>,pub seconds_to_expire: i64,}diff --git a/crates/router/src/connector/globalpay/transformers.rs b/crates/router/src/connector/globalpay/transformers.rsindex 48c6d9c7cc..6ae02ed4a7 100644--- a/crates/router/src/connector/globalpay/transformers.rs+++ b/crates/router/src/connector/globalpay/transformers.rs@@ -1,6 +1,6 @@use common_utils::crypto::{self, GenerateDigest};use error_stack::{IntoReport, ResultExt};-use masking::Secret;+use masking::{PeekInterface, Secret};use rand::distributions::DistString;use serde::{Deserialize, Serialize};use url::Url;@@ -106,7 +106,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for requests::GlobalpayCancelRequpub struct GlobalpayAuthType {pub app_id: Secret<String>,- pub key: String,+ pub key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for GlobalpayAuthType {@@ -114,8 +114,8 @@ impl TryFrom<&types::ConnectorAuthType> for GlobalpayAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- app_id: Secret::new(key1.to_owned()),- key: api_key.to_string(),+ app_id: key1.to_owned(),+ key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}@@ -142,7 +142,7 @@ impl TryFrom<&types::RefreshTokenRouterData> for GlobalpayRefreshTokenRequest {.attach_printable("Could not convert connector_auth to globalpay_auth")?;let nonce = rand::distributions::Alphanumeric.sample_string(&mut rand::thread_rng(), 12);- let nonce_with_api_key = format!("{}{}", nonce, globalpay_auth.key);+ let nonce_with_api_key = format!("{}{}", nonce, globalpay_auth.key.peek());let secret_vec = crypto::Sha512.generate_digest(nonce_with_api_key.as_bytes()).change_context(errors::ConnectorError::RequestEncodingFailed)diff --git a/crates/router/src/connector/globepay/transformers.rs b/crates/router/src/connector/globepay/transformers.rsindex c084607c4d..e78edf3ff4 100644--- a/crates/router/src/connector/globepay/transformers.rs+++ b/crates/router/src/connector/globepay/transformers.rs@@ -59,8 +59,8 @@ impl TryFrom<&types::ConnectorAuthType> for GlobepayAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- partner_code: Secret::new(api_key.to_owned()),- credential_code: Secret::new(key1.to_owned()),+ partner_code: api_key.to_owned(),+ credential_code: key1.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rsindex 220dceef7c..f3f5a4eb12 100644--- a/crates/router/src/connector/iatapay.rs+++ b/crates/router/src/connector/iatapay.rs@@ -5,6 +5,7 @@ use std::fmt::Debug;use base64::Engine;use common_utils::{crypto, ext_traits::ByteSliceExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as iatapay;use self::iatapay::IatapayPaymentsResponse;@@ -73,7 +74,7 @@ wherelet auth_header = (headers::AUTHORIZATION.to_string(),- format!("Bearer {}", access_token.token).into_masked(),+ format!("Bearer {}", access_token.token.peek()).into_masked(),);headers.push(auth_header);Ok(headers)@@ -153,7 +154,7 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, tiatapay::IatapayAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?;- let auth_id = format!("{}:{}", auth.client_id, auth.client_secret);+ let auth_id = format!("{}:{}", auth.client_id.peek(), auth.client_secret.peek());let auth_val: String = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_id));Ok(vec![diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rsindex 180a1a06ba..39c697d9e9 100644--- a/crates/router/src/connector/iatapay/transformers.rs+++ b/crates/router/src/connector/iatapay/transformers.rs@@ -28,7 +28,7 @@ impl TryFrom<&types::RefreshTokenRouterData> for IatapayAuthUpdateRequest {#[derive(Debug, Deserialize)]pub struct IatapayAuthUpdateResponse {- pub access_token: String,+ pub access_token: Secret<String>,pub token_type: String,pub expires_in: i64,pub scope: String,@@ -68,7 +68,7 @@ pub struct PayerInfo {#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]pub struct IatapayPaymentsRequest {- merchant_id: String,+ merchant_id: Secret<String>,amount: f64,currency: String,country: String,@@ -114,9 +114,9 @@ fn get_redirect_url(return_url: String) -> RedirectUrls {// Auth Structpub struct IatapayAuthType {- pub(super) client_id: String,- pub(super) merchant_id: String,- pub(super) client_secret: String,+ pub(super) client_id: Secret<String>,+ pub(super) merchant_id: Secret<String>,+ pub(super) client_secret: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for IatapayAuthType {@@ -128,9 +128,9 @@ impl TryFrom<&types::ConnectorAuthType> for IatapayAuthType {key1,api_secret,} => Ok(Self {- client_id: api_key.to_string(),- merchant_id: key1.to_string(),- client_secret: api_secret.to_string(),+ client_id: api_key.to_owned(),+ merchant_id: key1.to_owned(),+ client_secret: api_secret.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}@@ -245,7 +245,7 @@ impl<F, T>#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]pub struct IatapayRefundRequest {- pub merchant_id: String,+ pub merchant_id: Secret<String>,pub merchant_refund_id: String,pub amount: i64,pub currency: String,diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rsindex 01fe952f8f..f2f839e751 100644--- a/crates/router/src/connector/klarna/transformers.rs+++ b/crates/router/src/connector/klarna/transformers.rs@@ -1,5 +1,6 @@use api_models::payments;use error_stack::report;+use masking::Secret;use serde::{Deserialize, Serialize};use crate::{@@ -152,7 +153,7 @@ pub enum KlarnaSessionIntent {}pub struct KlarnaAuthType {- pub basic_token: String,+ pub basic_token: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for KlarnaAuthType {@@ -160,7 +161,7 @@ impl TryFrom<&types::ConnectorAuthType> for KlarnaAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = auth_type {Ok(Self {- basic_token: api_key.to_string(),+ basic_token: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/mollie.rs b/crates/router/src/connector/mollie.rsindex 39be74a0c3..46385e2ec6 100644--- a/crates/router/src/connector/mollie.rs+++ b/crates/router/src/connector/mollie.rs@@ -3,7 +3,7 @@ mod transformers;use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};-use masking::ExposeInterface;+use masking::PeekInterface;use transformers as mollie;use crate::{@@ -75,7 +75,7 @@ impl ConnectorCommon for Mollie {.change_context(errors::ConnectorError::FailedToObtainAuthType)?;Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", auth.api_key.expose()).into_masked(),+ format!("Bearer {}", auth.api_key.peek()).into_masked(),)])}diff --git a/crates/router/src/connector/mollie/transformers.rs b/crates/router/src/connector/mollie/transformers.rsindex ca10225a0e..c7738ed5b4 100644--- a/crates/router/src/connector/mollie/transformers.rs+++ b/crates/router/src/connector/mollie/transformers.rs@@ -444,12 +444,12 @@ impl TryFrom<&types::ConnectorAuthType> for MollieAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: Secret::new(api_key.to_owned()),+ api_key: api_key.to_owned(),profile_token: None,}),types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- api_key: Secret::new(api_key.to_owned()),- profile_token: Some(Secret::new(key1.to_owned())),+ api_key: api_key.to_owned(),+ profile_token: Some(key1.to_owned()),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}diff --git a/crates/router/src/connector/multisafepay.rs b/crates/router/src/connector/multisafepay.rsindex d062d08c31..07daef20e2 100644--- a/crates/router/src/connector/multisafepay.rs+++ b/crates/router/src/connector/multisafepay.rs@@ -3,6 +3,7 @@ mod transformers;use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};+use masking::ExposeInterface;use transformers as multisafepay;use crate::{@@ -139,7 +140,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRelet url = self.base_url(connectors);let api_key = multisafepay::MultisafepayAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?- .api_key;+ .api_key+ .expose();let ord_id = req.payment_id.clone();Ok(format!("{url}v1/json/orders/{ord_id}?api_key={api_key}"))}@@ -223,7 +225,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::Plet url = self.base_url(connectors);let api_key = multisafepay::MultisafepayAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?- .api_key;+ .api_key+ .expose();Ok(format!("{url}v1/json/orders?api_key={api_key}"))}@@ -313,7 +316,8 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponlet url = self.base_url(connectors);let api_key = multisafepay::MultisafepayAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?- .api_key;+ .api_key+ .expose();let ord_id = req.payment_id.clone();Ok(format!("{url}v1/json/orders/{ord_id}/refunds?api_key={api_key}"@@ -399,7 +403,8 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponselet url = self.base_url(connectors);let api_key = multisafepay::MultisafepayAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?- .api_key;+ .api_key+ .expose();let ord_id = req.payment_id.clone();Ok(format!("{url}v1/json/orders/{ord_id}/refunds?api_key={api_key}"diff --git a/crates/router/src/connector/multisafepay/transformers.rs b/crates/router/src/connector/multisafepay/transformers.rsindex c8b91a4bef..3e13a188bd 100644--- a/crates/router/src/connector/multisafepay/transformers.rs+++ b/crates/router/src/connector/multisafepay/transformers.rs@@ -416,7 +416,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques// Auth Structpub struct MultisafepayAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for MultisafepayAuthType {@@ -424,7 +424,7 @@ impl TryFrom<&types::ConnectorAuthType> for MultisafepayAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = auth_type {Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/nexinets/transformers.rs b/crates/router/src/connector/nexinets/transformers.rsindex e4e74a2dc4..5949e48ae1 100644--- a/crates/router/src/connector/nexinets/transformers.rs+++ b/crates/router/src/connector/nexinets/transformers.rs@@ -3,7 +3,7 @@ use base64::Engine;use cards::CardNumber;use common_utils::errors::CustomResult;use error_stack::{IntoReport, ResultExt};-use masking::Secret;+use masking::{PeekInterface, Secret};use serde::{Deserialize, Serialize};use url::Url;@@ -185,7 +185,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NexinetsPaymentsRequest {// Auth Structpub struct NexinetsAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for NexinetsAuthType {@@ -193,10 +193,10 @@ impl TryFrom<&types::ConnectorAuthType> for NexinetsAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => {- let auth_key = format!("{key1}:{api_key}");+ let auth_key = format!("{}:{}", key1.peek(), api_key.peek());let auth_header = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_key));Ok(Self {- api_key: auth_header,+ api_key: Secret::new(auth_header),})}_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rsindex 65e299cbed..13cf1426b9 100644--- a/crates/router/src/connector/nmi/transformers.rs+++ b/crates/router/src/connector/nmi/transformers.rs@@ -32,7 +32,7 @@ impl TryFrom<&ConnectorAuthType> for NmiAuthType {fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = auth_type {Ok(Self {- api_key: Secret::new(api_key.to_owned()),+ api_key: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rsindex ef5021dbfd..22c778334e 100644--- a/crates/router/src/connector/noon.rs+++ b/crates/router/src/connector/noon.rs@@ -5,6 +5,7 @@ use std::fmt::Debug;use base64::Engine;use common_utils::{crypto, ext_traits::ByteSliceExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as noon;use super::utils::PaymentsSyncRequestData;@@ -95,13 +96,19 @@ impl ConnectorCommon for Noon {) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {let auth = noon::NoonAuthType::try_from(auth_type)?;- let encoded_api_key = consts::BASE64_ENGINE.encode(format!(- "{}.{}:{}",- auth.business_identifier, auth.application_identifier, auth.api_key- ));+ let encoded_api_key = auth+ .business_identifier+ .zip(auth.application_identifier)+ .zip(auth.api_key)+ .map(|((business_identifier, application_identifier), api_key)| {+ consts::BASE64_ENGINE.encode(format!(+ "{}.{}:{}",+ business_identifier, application_identifier, api_key+ ))+ });Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Key_Test {encoded_api_key}").into_masked(),+ format!("Key_Test {}", encoded_api_key.peek()).into_masked(),)])}diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rsindex 9cb7cfdabb..648a708245 100644--- a/crates/router/src/connector/noon/transformers.rs+++ b/crates/router/src/connector/noon/transformers.rs@@ -218,9 +218,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest {// Auth Structpub struct NoonAuthType {- pub(super) api_key: String,- pub(super) application_identifier: String,- pub(super) business_identifier: String,+ pub(super) api_key: Secret<String>,+ pub(super) application_identifier: Secret<String>,+ pub(super) business_identifier: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for NoonAuthType {@@ -232,9 +232,9 @@ impl TryFrom<&types::ConnectorAuthType> for NoonAuthType {key1,api_secret,} => Ok(Self {- api_key: api_key.to_string(),- application_identifier: api_secret.to_string(),- business_identifier: key1.to_string(),+ api_key: api_key.to_owned(),+ application_identifier: api_secret.to_owned(),+ business_identifier: key1.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rsindex b6f89bb1db..8e58de4503 100644--- a/crates/router/src/connector/nuvei/transformers.rs+++ b/crates/router/src/connector/nuvei/transformers.rs@@ -5,7 +5,7 @@ use common_utils::{pii::Email,};use error_stack::{IntoReport, ResultExt};-use masking::Secret;+use masking::{PeekInterface, Secret};use reqwest::Url;use serde::{Deserialize, Serialize};@@ -34,8 +34,8 @@ pub struct NuveiMandateMeta {#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct NuveiSessionRequest {- pub merchant_id: String,- pub merchant_site_id: String,+ pub merchant_id: Secret<String>,+ pub merchant_site_id: Secret<String>,pub client_request_id: String,pub time_stamp: date_time::DateTime<date_time::YYYYMMDDHHmmss>,pub checksum: String,@@ -61,9 +61,9 @@ pub struct NuveiSessionResponse {pub struct NuveiPaymentsRequest {pub time_stamp: String,pub session_token: String,- pub merchant_id: String,- pub merchant_site_id: String,- pub client_request_id: String,+ pub merchant_id: Secret<String>,+ pub merchant_site_id: Secret<String>,+ pub client_request_id: Secret<String>,pub amount: String,pub currency: diesel_models::enums::Currency,/// This ID uniquely identifies your consumer/user in your system.@@ -103,8 +103,8 @@ pub struct NuveiInitPaymentRequest {#[serde(rename_all = "camelCase")]pub struct NuveiPaymentFlowRequest {pub time_stamp: String,- pub merchant_id: String,- pub merchant_site_id: String,+ pub merchant_id: Secret<String>,+ pub merchant_site_id: Secret<String>,pub client_request_id: String,pub amount: String,pub currency: diesel_models::enums::Currency,@@ -366,9 +366,7 @@ pub enum LiabilityShift {Failed,}-fn encode_payload(- payload: Vec<String>,-) -> Result<String, error_stack::Report<errors::ConnectorError>> {+fn encode_payload(payload: &[&str]) -> Result<String, error_stack::Report<errors::ConnectorError>> {let data = payload.join("");let digest = crypto::Sha256.generate_digest(data.as_bytes())@@ -393,12 +391,12 @@ impl TryFrom<&types::PaymentsAuthorizeSessionTokenRouterData> for NuveiSessionRemerchant_site_id: merchant_site_id.clone(),client_request_id: client_request_id.clone(),time_stamp: time_stamp.clone(),- checksum: encode_payload(vec![- merchant_id,- merchant_site_id,- client_request_id,- time_stamp.to_string(),- merchant_secret,+ checksum: encode_payload(&[+ merchant_id.peek(),+ merchant_site_id.peek(),+ &client_request_id,+ &time_stamp.to_string(),+ merchant_secret.peek(),])?,})}@@ -877,21 +875,21 @@ impl TryFrom<NuveiPaymentRequestData> for NuveiPaymentsRequest {Ok(Self {merchant_id: merchant_id.clone(),merchant_site_id: merchant_site_id.clone(),- client_request_id: client_request_id.clone(),+ client_request_id: Secret::new(client_request_id.clone()),time_stamp: time_stamp.clone(),session_token,transaction_type: request.capture_method.map(TransactionType::from).unwrap_or_default(),- checksum: encode_payload(vec![- merchant_id,- merchant_site_id,- client_request_id,- request.amount.clone(),- request.currency.clone().to_string(),- time_stamp,- merchant_secret,+ checksum: encode_payload(&[+ merchant_id.peek(),+ merchant_site_id.peek(),+ &client_request_id,+ &request.amount.clone(),+ &request.currency.to_string(),+ &time_stamp,+ merchant_secret.peek(),])?,amount: request.amount,currency: request.currency,@@ -913,19 +911,19 @@ impl TryFrom<NuveiPaymentRequestData> for NuveiPaymentFlowRequest {.change_context(errors::ConnectorError::RequestEncodingFailed)?;let merchant_secret = connector_meta.merchant_secret;Ok(Self {- merchant_id: merchant_id.clone(),- merchant_site_id: merchant_site_id.clone(),+ merchant_id: merchant_id.to_owned(),+ merchant_site_id: merchant_site_id.to_owned(),client_request_id: client_request_id.clone(),time_stamp: time_stamp.clone(),- checksum: encode_payload(vec![- merchant_id,- merchant_site_id,- client_request_id,- request.amount.clone(),- request.currency.clone().to_string(),- request.related_transaction_id.clone().unwrap_or_default(),- time_stamp,- merchant_secret,+ checksum: encode_payload(&[+ merchant_id.peek(),+ merchant_site_id.peek(),+ &client_request_id,+ &request.amount.clone(),+ &request.currency.to_string(),+ &request.related_transaction_id.clone().unwrap_or_default(),+ &time_stamp,+ merchant_secret.peek(),])?,amount: request.amount,currency: request.currency,@@ -1007,9 +1005,9 @@ impl TryFrom<&types::PaymentsCancelRouterData> for NuveiPaymentFlowRequest {// Auth Structpub struct NuveiAuthType {- pub(super) merchant_id: String,- pub(super) merchant_site_id: String,- pub(super) merchant_secret: String,+ pub(super) merchant_id: Secret<String>,+ pub(super) merchant_site_id: Secret<String>,+ pub(super) merchant_secret: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for NuveiAuthType {@@ -1022,9 +1020,9 @@ impl TryFrom<&types::ConnectorAuthType> for NuveiAuthType {} = auth_type{Ok(Self {- merchant_id: api_key.to_string(),- merchant_site_id: key1.to_string(),- merchant_secret: api_secret.to_string(),+ merchant_id: api_key.to_owned(),+ merchant_site_id: key1.to_owned(),+ merchant_secret: api_secret.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/opayo/transformers.rs b/crates/router/src/connector/opayo/transformers.rsindex 1dd06b46d3..e6c3d90fa4 100644--- a/crates/router/src/connector/opayo/transformers.rs+++ b/crates/router/src/connector/opayo/transformers.rs@@ -56,7 +56,7 @@ impl TryFrom<&types::ConnectorAuthType> for OpayoAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: Secret::new(api_key.to_string()),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/opennode/transformers.rs b/crates/router/src/connector/opennode/transformers.rsindex 8885b85cae..70a50e1b92 100644--- a/crates/router/src/connector/opennode/transformers.rs+++ b/crates/router/src/connector/opennode/transformers.rs@@ -1,5 +1,6 @@use std::collections::HashMap;+use masking::Secret;use serde::{Deserialize, Serialize};use crate::{@@ -30,7 +31,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for OpennodePaymentsRequest {//TODO: Fill the struct with respective fields// Auth Structpub struct OpennodeAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for OpennodeAuthType {@@ -38,7 +39,7 @@ impl TryFrom<&types::ConnectorAuthType> for OpennodeAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/payeezy.rs b/crates/router/src/connector/payeezy.rsindex 375fd3faeb..d210b04df2 100644--- a/crates/router/src/connector/payeezy.rs+++ b/crates/router/src/connector/payeezy.rs@@ -51,12 +51,16 @@ where.as_millis().to_string();let nonce = rand::distributions::Alphanumeric.sample_string(&mut rand::thread_rng(), 19);- let signature_string = format!(- "{}{}{}{}{}",- auth.api_key, nonce, timestamp, auth.merchant_token, request_payload+ let signature_string = auth.api_key.clone().zip(auth.merchant_token.clone()).map(+ |(api_key, merchant_token)| {+ format!(+ "{}{}{}{}{}",+ api_key, nonce, timestamp, merchant_token, request_payload+ )+ },);- let key = hmac::Key::new(hmac::HMAC_SHA256, auth.api_secret.as_bytes());- let tag = hmac::sign(&key, signature_string.as_bytes());+ let key = hmac::Key::new(hmac::HMAC_SHA256, auth.api_secret.expose().as_bytes());+ let tag = hmac::sign(&key, signature_string.expose().as_bytes());let hmac_sign = hex::encode(tag);let signature_value = consts::BASE64_ENGINE_URL_SAFE.encode(hmac_sign);Ok(vec![diff --git a/crates/router/src/connector/payeezy/transformers.rs b/crates/router/src/connector/payeezy/transformers.rsindex 3db71421fc..b35d764cc9 100644--- a/crates/router/src/connector/payeezy/transformers.rs+++ b/crates/router/src/connector/payeezy/transformers.rs@@ -201,9 +201,9 @@ fn get_payment_method_data(// Auth Structpub struct PayeezyAuthType {- pub(super) api_key: String,- pub(super) api_secret: String,- pub(super) merchant_token: String,+ pub(super) api_key: Secret<String>,+ pub(super) api_secret: Secret<String>,+ pub(super) merchant_token: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for PayeezyAuthType {@@ -216,9 +216,9 @@ impl TryFrom<&types::ConnectorAuthType> for PayeezyAuthType {} = item{Ok(Self {- api_key: api_key.to_string(),- api_secret: api_secret.to_string(),- merchant_token: key1.to_string(),+ api_key: api_key.to_owned(),+ api_secret: api_secret.to_owned(),+ merchant_token: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rsindex ec3303d3fc..c592377bc7 100644--- a/crates/router/src/connector/payme/transformers.rs+++ b/crates/router/src/connector/payme/transformers.rs@@ -250,8 +250,8 @@ impl TryFrom<&types::ConnectorAuthType> for PaymeAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- seller_payme_id: Secret::new(api_key.to_string()),- payme_client_key: Secret::new(key1.to_string()),+ seller_payme_id: api_key.to_owned(),+ payme_client_key: key1.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rsindex fb72a79bf6..dc6a70431a 100644--- a/crates/router/src/connector/paypal.rs+++ b/crates/router/src/connector/paypal.rs@@ -3,6 +3,7 @@ use std::fmt::Debug;use base64::Engine;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as paypal;use self::transformers::PaypalMeta;@@ -127,7 +128,7 @@ where),(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", access_token.token).into_masked(),+ format!("Bearer {}", access_token.token.peek()).into_masked(),),("Prefer".to_string(),@@ -228,8 +229,11 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t.try_into().change_context(errors::ConnectorError::FailedToObtainAuthType)?;- let auth_id = format!("{}:{}", auth.key1, auth.api_key);- let auth_val = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_id));+ let auth_id = auth+ .key1+ .zip(auth.api_key)+ .map(|(key1, api_key)| format!("{}:{}", key1, api_key));+ let auth_val = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_id.peek()));Ok(vec![(diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rsindex 32824e3cb8..622651aa9a 100644--- a/crates/router/src/connector/paypal/transformers.rs+++ b/crates/router/src/connector/paypal/transformers.rs@@ -173,8 +173,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {#[derive(Debug, Clone, Serialize, PartialEq)]pub struct PaypalAuthUpdateRequest {grant_type: String,- client_id: String,- client_secret: String,+ client_id: Secret<String>,+ client_secret: Secret<String>,}impl TryFrom<&types::RefreshTokenRouterData> for PaypalAuthUpdateRequest {type Error = error_stack::Report<errors::ConnectorError>;@@ -189,7 +189,7 @@ impl TryFrom<&types::RefreshTokenRouterData> for PaypalAuthUpdateRequest {#[derive(Default, Debug, Clone, Deserialize, PartialEq)]pub struct PaypalAuthUpdateResponse {- pub access_token: String,+ pub access_token: Secret<String>,pub token_type: String,pub expires_in: i64,}@@ -213,8 +213,8 @@ impl<F, T> TryFrom<types::ResponseRouterData<F, PaypalAuthUpdateResponse, T, typ#[derive(Debug)]pub struct PaypalAuthType {- pub(super) api_key: String,- pub(super) key1: String,+ pub(super) api_key: Secret<String>,+ pub(super) key1: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for PaypalAuthType {@@ -222,8 +222,8 @@ impl TryFrom<&types::ConnectorAuthType> for PaypalAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- api_key: api_key.to_string(),- key1: key1.to_string(),+ api_key: api_key.to_owned(),+ key1: key1.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}diff --git a/crates/router/src/connector/payu.rs b/crates/router/src/connector/payu.rsindex 0875fe29b4..1b5bc904bf 100644--- a/crates/router/src/connector/payu.rs+++ b/crates/router/src/connector/payu.rs@@ -3,6 +3,7 @@ mod transformers;use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as payu;use crate::{@@ -45,7 +46,7 @@ wherelet auth_header = (headers::AUTHORIZATION.to_string(),- format!("Bearer {}", access_token.token).into_masked(),+ format!("Bearer {}", access_token.token.peek()).into_masked(),);headers.push(auth_header);diff --git a/crates/router/src/connector/payu/transformers.rs b/crates/router/src/connector/payu/transformers.rsindex 8308985ea7..c43e59ac76 100644--- a/crates/router/src/connector/payu/transformers.rs+++ b/crates/router/src/connector/payu/transformers.rs@@ -16,7 +16,7 @@ const WALLET_IDENTIFIER: &str = "PBL";#[serde(rename_all = "camelCase")]pub struct PayuPaymentsRequest {customer_ip: std::net::IpAddr,- merchant_pos_id: String,+ merchant_pos_id: Secret<String>,total_amount: i64,currency_code: enums::Currency,description: String,@@ -131,8 +131,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {}pub struct PayuAuthType {- pub(super) api_key: String,- pub(super) merchant_pos_id: String,+ pub(super) api_key: Secret<String>,+ pub(super) merchant_pos_id: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for PayuAuthType {@@ -140,8 +140,8 @@ impl TryFrom<&types::ConnectorAuthType> for PayuAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- api_key: api_key.to_string(),- merchant_pos_id: key1.to_string(),+ api_key: api_key.to_owned(),+ merchant_pos_id: key1.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}@@ -262,8 +262,8 @@ impl<F, T>#[derive(Debug, Clone, Serialize, PartialEq)]pub struct PayuAuthUpdateRequest {grant_type: String,- client_id: String,- client_secret: String,+ client_id: Secret<String>,+ client_secret: Secret<String>,}impl TryFrom<&types::RefreshTokenRouterData> for PayuAuthUpdateRequest {@@ -278,7 +278,7 @@ impl TryFrom<&types::RefreshTokenRouterData> for PayuAuthUpdateRequest {}#[derive(Default, Debug, Clone, Deserialize, PartialEq)]pub struct PayuAuthUpdateResponse {- pub access_token: String,+ pub access_token: Secret<String>,pub token_type: String,pub expires_in: i64,pub grant_type: String,diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rsindex 73bc8f8744..4703a81f30 100644--- a/crates/router/src/connector/powertranz/transformers.rs+++ b/crates/router/src/connector/powertranz/transformers.rs@@ -219,8 +219,8 @@ impl TryFrom<&types::ConnectorAuthType> for PowertranzAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- power_tranz_id: Secret::new(key1.to_string()),- power_tranz_password: Secret::new(api_key.to_string()),+ power_tranz_id: key1.to_owned(),+ power_tranz_password: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rsindex 768a51f89e..b1e814afb4 100644--- a/crates/router/src/connector/rapyd.rs+++ b/crates/router/src/connector/rapyd.rs@@ -4,7 +4,7 @@ use std::fmt::Debug;use base64::Engine;use common_utils::{date_time, ext_traits::StringExt};use error_stack::{IntoReport, ResultExt};-use masking::ExposeInterface;+use masking::{ExposeInterface, PeekInterface};use rand::distributions::{Alphanumeric, DistString};use ring::hmac;use transformers as rapyd;@@ -45,9 +45,12 @@ impl Rapyd {access_key,secret_key,} = auth;- let to_sign =- format!("{http_method}{url_path}{salt}{timestamp}{access_key}{secret_key}{body}");- let key = hmac::Key::new(hmac::HMAC_SHA256, secret_key.as_bytes());+ let to_sign = format!(+ "{http_method}{url_path}{salt}{timestamp}{}{}{body}",+ access_key.peek(),+ secret_key.peek()+ );+ let key = hmac::Key::new(hmac::HMAC_SHA256, secret_key.peek().as_bytes());let tag = hmac::sign(&key, to_sign.as_bytes());let hmac_sign = hex::encode(tag);let signature_value = consts::BASE64_ENGINE_URL_SAFE.encode(hmac_sign);@@ -749,7 +752,11 @@ impl api::IncomingWebhook for Rapyd {.into_report().change_context(errors::ConnectorError::WebhookSourceVerificationFailed).attach_printable("Could not convert body to UTF-8")?;- let to_sign = format!("{url_path}{salt}{timestamp}{access_key}{secret_key}{body_string}");+ let to_sign = format!(+ "{url_path}{salt}{timestamp}{}{}{body_string}",+ access_key.peek(),+ secret_key.peek()+ );Ok(to_sign.into_bytes())}@@ -786,7 +793,7 @@ impl api::IncomingWebhook for Rapyd {.parse_struct("RapydAuthType").change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;let secret_key = auth.secret_key;- let key = hmac::Key::new(hmac::HMAC_SHA256, secret_key.as_bytes());+ let key = hmac::Key::new(hmac::HMAC_SHA256, secret_key.peek().as_bytes());let tag = hmac::sign(&key, &message);let hmac_sign = hex::encode(tag);Ok(hmac_sign.as_bytes().eq(&signature))diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rsindex 04264266c2..79ad6838ac 100644--- a/crates/router/src/connector/rapyd/transformers.rs+++ b/crates/router/src/connector/rapyd/transformers.rs@@ -144,8 +144,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for RapydPaymentsRequest {#[derive(Debug, Deserialize)]pub struct RapydAuthType {- pub access_key: String,- pub secret_key: String,+ pub access_key: Secret<String>,+ pub secret_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for RapydAuthType {@@ -153,8 +153,8 @@ impl TryFrom<&types::ConnectorAuthType> for RapydAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {Ok(Self {- access_key: api_key.to_string(),- secret_key: key1.to_string(),+ access_key: api_key.to_owned(),+ secret_key: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/shift4/transformers.rs b/crates/router/src/connector/shift4/transformers.rsindex 39d9ddb49d..dc675968a9 100644--- a/crates/router/src/connector/shift4/transformers.rs+++ b/crates/router/src/connector/shift4/transformers.rs@@ -271,7 +271,7 @@ fn get_address_details(address_details: Option<&payments::AddressDetails>) -> Op// Auth Structpub struct Shift4AuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for Shift4AuthType {@@ -279,7 +279,7 @@ impl TryFrom<&types::ConnectorAuthType> for Shift4AuthType {fn try_from(item: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = item {Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/stax/transformers.rs b/crates/router/src/connector/stax/transformers.rsindex 954e14413d..c7bec9cd27 100644--- a/crates/router/src/connector/stax/transformers.rs+++ b/crates/router/src/connector/stax/transformers.rs@@ -50,7 +50,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for StaxPaymentsRequest {//TODO: Fill the struct with respective fields// Auth Structpub struct StaxAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for StaxAuthType {@@ -58,7 +58,7 @@ impl TryFrom<&types::ConnectorAuthType> for StaxAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rsindex 8daca35205..a717022e78 100644--- a/crates/router/src/connector/stripe.rs+++ b/crates/router/src/connector/stripe.rs@@ -4,6 +4,7 @@ use std::{collections::HashMap, fmt::Debug, ops::Deref};use diesel_models::enums;use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use router_env::{instrument, tracing};use self::transformers as stripe;@@ -53,7 +54,7 @@ impl ConnectorCommon for Stripe {.change_context(errors::ConnectorError::FailedToObtainAuthType)?;Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", auth.api_key).into_masked(),+ format!("Bearer {}", auth.api_key.peek()).into_masked(),)])}}diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rsindex ffce082576..f73c512f10 100644--- a/crates/router/src/connector/stripe/transformers.rs+++ b/crates/router/src/connector/stripe/transformers.rs@@ -23,7 +23,7 @@ use crate::{};pub struct StripeAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for StripeAuthType {@@ -31,7 +31,7 @@ impl TryFrom<&types::ConnectorAuthType> for StripeAuthType {fn try_from(item: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = item {Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rsindex d6e623eaa7..e0a039e579 100644--- a/crates/router/src/connector/trustpay.rs+++ b/crates/router/src/connector/trustpay.rs@@ -5,6 +5,7 @@ use std::fmt::Debug;use base64::Engine;use common_utils::{crypto, errors::ReportSwitchExt, ext_traits::ByteSliceExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as trustpay;use super::utils::collect_and_sort_values_by_removing_signature;@@ -54,7 +55,7 @@ where),(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", token.token).into_masked(),+ format!("Bearer {}", token.token.peek()).into_masked(),),])}@@ -179,10 +180,15 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {let auth = trustpay::TrustpayAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?;- let auth_value = format!(- "Basic {}",- consts::BASE64_ENGINE.encode(format!("{}:{}", auth.project_id, auth.secret_key))- );+ let auth_value = auth+ .project_id+ .zip(auth.secret_key)+ .map(|(project_id, secret_key)| {+ format!(+ "Basic {}",+ consts::BASE64_ENGINE.encode(format!("{}:{}", project_id, secret_key))+ )+ });Ok(vec![(headers::CONTENT_TYPE.to_string(),diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rsindex c1446e0321..5ecdf376c4 100644--- a/crates/router/src/connector/trustpay/transformers.rs+++ b/crates/router/src/connector/trustpay/transformers.rs@@ -22,9 +22,9 @@ use crate::{type Error = error_stack::Report<errors::ConnectorError>;pub struct TrustpayAuthType {- pub(super) api_key: String,- pub(super) project_id: String,- pub(super) secret_key: String,+ pub(super) api_key: Secret<String>,+ pub(super) project_id: Secret<String>,+ pub(super) secret_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for TrustpayAuthType {@@ -37,9 +37,9 @@ impl TryFrom<&types::ConnectorAuthType> for TrustpayAuthType {} = auth_type{Ok(Self {- api_key: api_key.to_string(),- project_id: key1.to_string(),- secret_key: api_secret.to_string(),+ api_key: api_key.to_owned(),+ project_id: key1.to_owned(),+ secret_key: api_secret.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())@@ -59,7 +59,7 @@ pub enum TrustpayPaymentMethod {#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]#[serde(rename_all = "PascalCase")]pub struct MerchantIdentification {- pub project_id: String,+ pub project_id: Secret<String>,}#[derive(Default, Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]@@ -775,7 +775,7 @@ pub struct ResultInfo {#[derive(Default, Debug, Clone, Deserialize, PartialEq)]pub struct TrustpayAuthUpdateResponse {- pub access_token: Option<String>,+ pub access_token: Option<Secret<String>>,pub token_type: Option<String>,pub expires_in: Option<i64>,#[serde(rename = "ResultInfo")]diff --git a/crates/router/src/connector/tsys/transformers.rs b/crates/router/src/connector/tsys/transformers.rsindex 536f6d02ef..5aa4574c91 100644--- a/crates/router/src/connector/tsys/transformers.rs+++ b/crates/router/src/connector/tsys/transformers.rs@@ -85,9 +85,9 @@ impl TryFrom<&types::ConnectorAuthType> for TsysAuthType {key1,api_secret,} => Ok(Self {- device_id: Secret::new(api_key.to_string()),- transaction_key: Secret::new(key1.to_string()),- developer_id: Secret::new(api_secret.to_string()),+ device_id: api_key.to_owned(),+ transaction_key: key1.to_owned(),+ developer_id: api_secret.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex a547dafc3c..9a00a42222 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -38,11 +38,11 @@ pub fn missing_field_err(type Error = error_stack::Report<errors::ConnectorError>;pub trait AccessTokenRequestInfo {- fn get_request_id(&self) -> Result<String, Error>;+ fn get_request_id(&self) -> Result<Secret<String>, Error>;}impl AccessTokenRequestInfo for types::RefreshTokenRouterData {- fn get_request_id(&self) -> Result<String, Error> {+ fn get_request_id(&self) -> Result<Secret<String>, Error> {self.request.id.clone()diff --git a/crates/router/src/connector/wise.rs b/crates/router/src/connector/wise.rsindex 853837b58e..7d1f4b2786 100644--- a/crates/router/src/connector/wise.rs+++ b/crates/router/src/connector/wise.rs@@ -1,17 +1,21 @@mod transformers;-use std::fmt::Debug;use error_stack::{IntoReport, ResultExt};#[cfg(feature = "payouts")]+use masking::PeekInterface;+#[cfg(feature = "payouts")]use router_env::{instrument, tracing};use self::transformers as wise;use crate::{configs::settings,core::errors::{self, CustomResult},- headers, services,- services::request,+ headers,+ services::{+ self,+ request::{self, Mask},+ },types::{self,api::{self, ConnectorCommon, ConnectorCommonExt},@@ -42,7 +46,10 @@ where)];let auth = wise::WiseAuthType::try_from(&req.connector_auth_type).change_context(errors::ConnectorError::FailedToObtainAuthType)?;- let mut api_key = vec![(headers::AUTHORIZATION.to_string(), auth.api_key.into())];+ let mut api_key = vec![(+ headers::AUTHORIZATION.to_string(),+ auth.api_key.into_masked(),+ )];header.append(&mut api_key);Ok(header)}@@ -61,7 +68,7 @@ impl ConnectorCommon for Wise {.change_context(errors::ConnectorError::FailedToObtainAuthType)?;Ok(vec![(headers::AUTHORIZATION.to_string(),- auth.api_key.into(),+ auth.api_key.into_masked(),)])}@@ -297,7 +304,8 @@ impl services::ConnectorIntegration<api::PoQuote, types::PayoutsData, types::Pay.change_context(errors::ConnectorError::FailedToObtainAuthType)?;Ok(format!("{}v3/profiles/{}/quotes",- connectors.wise.base_url, auth.profile_id+ connectors.wise.base_url,+ auth.profile_id.peek()))}@@ -581,7 +589,9 @@ impl services::ConnectorIntegration<api::PoFulfill, types::PayoutsData, types::P)?;Ok(format!("{}v3/profiles/{}/transfers/{}/payments",- connectors.wise.base_url, auth.profile_id, transfer_id+ connectors.wise.base_url,+ auth.profile_id.peek(),+ transfer_id))}diff --git a/crates/router/src/connector/wise/transformers.rs b/crates/router/src/connector/wise/transformers.rsindex e9513873cd..113d249044 100644--- a/crates/router/src/connector/wise/transformers.rs+++ b/crates/router/src/connector/wise/transformers.rs@@ -2,7 +2,6 @@use api_models::payouts::PayoutMethodData;#[cfg(feature = "payouts")]use common_utils::pii::Email;-#[cfg(feature = "payouts")]use masking::Secret;use serde::Deserialize;#[cfg(feature = "payouts")]@@ -22,9 +21,9 @@ use crate::{use crate::{core::errors, types};pub struct WiseAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,#[allow(dead_code)]- pub(super) profile_id: String,+ pub(super) profile_id: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for WiseAuthType {@@ -32,8 +31,8 @@ impl TryFrom<&types::ConnectorAuthType> for WiseAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {- api_key: api_key.to_string(),- profile_id: key1.to_string(),+ api_key: api_key.to_owned(),+ profile_id: key1.to_owned(),}),_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,}@@ -69,7 +68,7 @@ pub struct WiseRecipientCreateRequest {currency: String,#[serde(rename = "type")]recipient_type: RecipientType,- profile: String,+ profile: Secret<String>,account_holder_name: Secret<String>,details: WiseBankDetails,}diff --git a/crates/router/src/connector/worldline.rs b/crates/router/src/connector/worldline.rsindex b4e1d4fcc2..b356945fc6 100644--- a/crates/router/src/connector/worldline.rs+++ b/crates/router/src/connector/worldline.rs@@ -6,6 +6,7 @@ use base64::Engine;use common_utils::ext_traits::ByteSliceExt;use diesel_models::enums;use error_stack::{IntoReport, ResultExt};+use masking::{ExposeInterface, PeekInterface};use ring::hmac;use time::{format_description, OffsetDateTime};use transformers as worldline;@@ -54,10 +55,10 @@ impl Worldline {api_secret,..} = auth;- let key = hmac::Key::new(hmac::HMAC_SHA256, api_secret.as_bytes());+ let key = hmac::Key::new(hmac::HMAC_SHA256, api_secret.expose().as_bytes());let signed_data = consts::BASE64_ENGINE.encode(hmac::sign(&key, signature_data.as_bytes()));- Ok(format!("GCS v1HMAC:{api_key}:{signed_data}"))+ Ok(format!("GCS v1HMAC:{}:{signed_data}", api_key.peek()))}pub fn get_current_date_time() -> CustomResult<String, errors::ConnectorError> {@@ -184,7 +185,7 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR) -> CustomResult<String, errors::ConnectorError> {let base_url = self.base_url(connectors);let auth: worldline::AuthType = worldline::AuthType::try_from(&req.connector_auth_type)?;- let merchant_account_id = auth.merchant_account_id;+ let merchant_account_id = auth.merchant_account_id.expose();let payment_id: &str = req.request.connector_transaction_id.as_ref();Ok(format!("{base_url}v1/{merchant_account_id}/payments/{payment_id}/cancel"@@ -264,7 +265,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe.change_context(errors::ConnectorError::MissingConnectorTransactionID)?;let base_url = self.base_url(connectors);let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;- let merchant_account_id = auth.merchant_account_id;+ let merchant_account_id = auth.merchant_account_id.expose();Ok(format!("{base_url}v1/{merchant_account_id}/payments/{payment_id}"))@@ -340,7 +341,7 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Paymelet payment_id = req.request.connector_transaction_id.clone();let base_url = self.base_url(connectors);let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;- let merchant_account_id = auth.merchant_account_id;+ let merchant_account_id = auth.merchant_account_id.expose();Ok(format!("{base_url}v1/{merchant_account_id}/payments/{payment_id}/approve"))@@ -457,7 +458,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P) -> CustomResult<String, errors::ConnectorError> {let base_url = self.base_url(connectors);let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;- let merchant_account_id = auth.merchant_account_id;+ let merchant_account_id = auth.merchant_account_id.expose();Ok(format!("{base_url}v1/{merchant_account_id}/payments"))}@@ -548,7 +549,7 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponlet payment_id = req.request.connector_transaction_id.clone();let base_url = self.base_url(connectors);let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;- let merchant_account_id = auth.merchant_account_id;+ let merchant_account_id = auth.merchant_account_id.expose();Ok(format!("{base_url}v1/{merchant_account_id}/payments/{payment_id}/refund"))@@ -638,7 +639,7 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponselet refund_id = req.request.get_connector_refund_id()?;let base_url = self.base_url(connectors);let auth: worldline::AuthType = worldline::AuthType::try_from(&req.connector_auth_type)?;- let merchant_account_id = auth.merchant_account_id;+ let merchant_account_id = auth.merchant_account_id.expose();Ok(format!("{base_url}v1/{merchant_account_id}/refunds/{refund_id}/"))diff --git a/crates/router/src/connector/worldline/transformers.rs b/crates/router/src/connector/worldline/transformers.rsindex a347537b23..6dbdd9bb22 100644--- a/crates/router/src/connector/worldline/transformers.rs+++ b/crates/router/src/connector/worldline/transformers.rs@@ -410,9 +410,9 @@ impl From<payments::AddressDetails> for Shipping {}pub struct AuthType {- pub api_key: String,- pub api_secret: String,- pub merchant_account_id: String,+ pub api_key: Secret<String>,+ pub api_secret: Secret<String>,+ pub merchant_account_id: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for AuthType {@@ -425,9 +425,9 @@ impl TryFrom<&types::ConnectorAuthType> for AuthType {} = auth_type{Ok(Self {- api_key: api_key.to_string(),- api_secret: api_secret.to_string(),- merchant_account_id: key1.to_string(),+ api_key: api_key.to_owned(),+ api_secret: api_secret.to_owned(),+ merchant_account_id: key1.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType)?diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rsindex 8309a1221f..2739c4fa36 100644--- a/crates/router/src/connector/worldpay/transformers.rs+++ b/crates/router/src/connector/worldpay/transformers.rs@@ -2,7 +2,7 @@ use base64::Engine;use common_utils::errors::CustomResult;use diesel_models::enums;use error_stack::{IntoReport, ResultExt};-use masking::PeekInterface;+use masking::{PeekInterface, Secret};use super::{requests::*, response::*};use crate::{@@ -88,7 +88,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for WorldpayPaymentsRequest {}pub struct WorldpayAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for WorldpayAuthType {@@ -96,10 +96,10 @@ impl TryFrom<&types::ConnectorAuthType> for WorldpayAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {match auth_type {types::ConnectorAuthType::BodyKey { api_key, key1 } => {- let auth_key = format!("{key1}:{api_key}");+ let auth_key = format!("{}:{}", key1.peek(), api_key.peek());let auth_header = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_key));Ok(Self {- api_key: auth_header,+ api_key: Secret::new(auth_header),})}_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rsindex cae788c20c..a583e0d834 100644--- a/crates/router/src/connector/zen.rs+++ b/crates/router/src/connector/zen.rs@@ -4,6 +4,7 @@ use std::fmt::Debug;use common_utils::{crypto, ext_traits::ByteSliceExt};use error_stack::{IntoReport, ResultExt};+use masking::PeekInterface;use transformers as zen;use uuid::Uuid;@@ -94,7 +95,7 @@ impl ConnectorCommon for Zen {let auth = zen::ZenAuthType::try_from(auth_type)?;Ok(vec![(headers::AUTHORIZATION.to_string(),- format!("Bearer {}", auth.api_key).into_masked(),+ format!("Bearer {}", auth.api_key.peek()).into_masked(),)])}diff --git a/crates/router/src/connector/zen/transformers.rs b/crates/router/src/connector/zen/transformers.rsindex 8bb8156a93..6813961446 100644--- a/crates/router/src/connector/zen/transformers.rs+++ b/crates/router/src/connector/zen/transformers.rs@@ -18,7 +18,7 @@ use crate::{};// Auth Structpub struct ZenAuthType {- pub(super) api_key: String,+ pub(super) api_key: Secret<String>,}impl TryFrom<&types::ConnectorAuthType> for ZenAuthType {@@ -26,7 +26,7 @@ impl TryFrom<&types::ConnectorAuthType> for ZenAuthType {fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {if let types::ConnectorAuthType::HeaderKey { api_key } = auth_type {Ok(Self {- api_key: api_key.to_string(),+ api_key: api_key.to_owned(),})} else {Err(errors::ConnectorError::FailedToObtainAuthType.into())diff --git a/crates/router/src/services/api/request.rs b/crates/router/src/services/api/request.rsindex 8caa9ff9e8..6c96e336a1 100644--- a/crates/router/src/services/api/request.rs+++ b/crates/router/src/services/api/request.rs@@ -56,16 +56,25 @@ impl<T: Eq + PartialEq + Clone> Maskable<T> {}}-pub trait Mask: Eq + Clone + PartialEq {- fn into_masked(self) -> Maskable<Self>;+pub trait Mask {+ type Output: Eq + Clone + PartialEq;+ fn into_masked(self) -> Maskable<Self::Output>;}-impl<T: std::fmt::Debug + Clone + Eq + PartialEq> Mask for T {- fn into_masked(self) -> Maskable<Self> {+impl Mask for String {+ type Output = Self;+ fn into_masked(self) -> Maskable<Self::Output> {Maskable::new_masked(self.into())}}+impl Mask for Secret<String> {+ type Output = String;+ fn into_masked(self) -> Maskable<Self::Output> {+ Maskable::new_masked(self)+ }+}+impl<T: Eq + PartialEq + Clone> From<T> for Maskable<T> {fn from(value: T) -> Self {Self::new_normal(value)diff --git a/crates/router/src/types.rs b/crates/router/src/types.rsindex f78a419cd9..919a92530a 100644--- a/crates/router/src/types.rs+++ b/crates/router/src/types.rs@@ -424,8 +424,8 @@ pub struct VerifyRequestData {#[derive(Debug, Clone)]pub struct AccessTokenRequestData {- pub app_id: String,- pub id: Option<String>,+ pub app_id: Secret<String>,+ pub id: Option<Secret<String>>,// Add more keys if required}@@ -464,7 +464,7 @@ pub struct AddAccessTokenResult {#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]pub struct AccessToken {- pub token: String,+ pub token: Secret<String>,pub expires: i64,}@@ -706,22 +706,22 @@ pub struct ResponseRouterData<Flow, R, Request, Response> {#[serde(tag = "auth_type")]pub enum ConnectorAuthType {HeaderKey {- api_key: String,+ api_key: Secret<String>,},BodyKey {- api_key: String,- key1: String,+ api_key: Secret<String>,+ key1: Secret<String>,},SignatureKey {- api_key: String,- key1: String,- api_secret: String,+ api_key: Secret<String>,+ key1: Secret<String>,+ api_secret: Secret<String>,},MultiAuthKey {- api_key: String,- key1: String,- api_secret: String,- key2: String,+ api_key: Secret<String>,+ key1: Secret<String>,+ api_secret: Secret<String>,+ key2: Secret<String>,},#[default]NoKey,diff --git a/crates/router/tests/connectors/airwallex.rs b/crates/router/tests/connectors/airwallex.rsindex 91cb04214a..014c030827 100644--- a/crates/router/tests/connectors/airwallex.rs+++ b/crates/router/tests/connectors/airwallex.rs@@ -1,6 +1,6 @@use std::str::FromStr;-use masking::Secret;+use masking::{PeekInterface, Secret};use router::types::{self, api, storage::enums, AccessToken};use crate::{@@ -41,7 +41,7 @@ fn get_access_token() -> Option<AccessToken> {match CONNECTOR.get_auth_token() {types::ConnectorAuthType::BodyKey { api_key, key1 } => Some(AccessToken {token: api_key,- expires: key1.parse::<i64>().unwrap(),+ expires: key1.peek().parse::<i64>().unwrap(),}),_ => None,}diff --git a/crates/router/tests/connectors/payu.rs b/crates/router/tests/connectors/payu.rsindex 018e2720cd..ad3b1ed920 100644--- a/crates/router/tests/connectors/payu.rs+++ b/crates/router/tests/connectors/payu.rs@@ -1,3 +1,4 @@+use masking::PeekInterface;use router::types::{self, api, storage::enums, AccessToken, ConnectorAuthType};use crate::{@@ -34,7 +35,7 @@ fn get_access_token() -> Option<AccessToken> {match connector.get_auth_token() {ConnectorAuthType::BodyKey { api_key, key1 } => Some(AccessToken {token: api_key,- expires: key1.parse::<i64>().unwrap(),+ expires: key1.peek().parse::<i64>().unwrap(),}),_ => None,}diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rsindex dcc88fbd09..5f97dc08ad 100644--- a/crates/test_utils/src/connector_auth.rs+++ b/crates/test_utils/src/connector_auth.rs@@ -1,6 +1,6 @@use std::{collections::HashMap, env};-use masking::{PeekInterface, Secret};+use masking::Secret;use router::types::ConnectorAuthType;use serde::{Deserialize, Serialize};@@ -149,25 +149,43 @@ impl ConnectorAuthenticationMap {table.get("key2"),) {(Some(api_key), None, None, None) => ConnectorAuthType::HeaderKey {- api_key: api_key.as_str().unwrap_or_default().to_string(),+ api_key: Secret::new(+ api_key.as_str().unwrap_or_default().to_string(),+ ),},(Some(api_key), Some(key1), None, None) => ConnectorAuthType::BodyKey {- api_key: api_key.as_str().unwrap_or_default().to_string(),- key1: key1.as_str().unwrap_or_default().to_string(),+ api_key: Secret::new(+ api_key.as_str().unwrap_or_default().to_string(),+ ),+ key1: Secret::new(key1.as_str().unwrap_or_default().to_string()),},(Some(api_key), Some(key1), Some(api_secret), None) => {ConnectorAuthType::SignatureKey {- api_key: api_key.as_str().unwrap_or_default().to_string(),- key1: key1.as_str().unwrap_or_default().to_string(),- api_secret: api_secret.as_str().unwrap_or_default().to_string(),+ api_key: Secret::new(+ api_key.as_str().unwrap_or_default().to_string(),+ ),+ key1: Secret::new(+ key1.as_str().unwrap_or_default().to_string(),+ ),+ api_secret: Secret::new(+ api_secret.as_str().unwrap_or_default().to_string(),+ ),}}(Some(api_key), Some(key1), Some(api_secret), Some(key2)) => {ConnectorAuthType::MultiAuthKey {- api_key: api_key.as_str().unwrap_or_default().to_string(),- key1: key1.as_str().unwrap_or_default().to_string(),- api_secret: api_secret.as_str().unwrap_or_default().to_string(),- key2: key2.as_str().unwrap_or_default().to_string(),+ api_key: Secret::new(+ api_key.as_str().unwrap_or_default().to_string(),+ ),+ key1: Secret::new(+ key1.as_str().unwrap_or_default().to_string(),+ ),+ api_secret: Secret::new(+ api_secret.as_str().unwrap_or_default().to_string(),+ ),+ key2: Secret::new(+ key2.as_str().unwrap_or_default().to_string(),+ ),}}_ => ConnectorAuthType::NoKey,@@ -191,7 +209,7 @@ pub struct HeaderKey {impl From<HeaderKey> for ConnectorAuthType {fn from(key: HeaderKey) -> Self {Self::HeaderKey {- api_key: key.api_key.peek().to_string(),+ api_key: key.api_key,}}}@@ -205,8 +223,8 @@ pub struct BodyKey {impl From<BodyKey> for ConnectorAuthType {fn from(key: BodyKey) -> Self {Self::BodyKey {- api_key: key.api_key.peek().to_string(),- key1: key.key1.peek().to_string(),+ api_key: key.api_key,+ key1: key.key1,}}}@@ -221,9 +239,9 @@ pub struct SignatureKey {impl From<SignatureKey> for ConnectorAuthType {fn from(key: SignatureKey) -> Self {Self::SignatureKey {- api_key: key.api_key.peek().to_string(),- key1: key.key1.peek().to_string(),- api_secret: key.api_secret.peek().to_string(),+ api_key: key.api_key,+ key1: key.key1,+ api_secret: key.api_secret,}}}@@ -239,10 +257,10 @@ pub struct MultiAuthKey {impl From<MultiAuthKey> for ConnectorAuthType {fn from(key: MultiAuthKey) -> Self {Self::MultiAuthKey {- api_key: key.api_key.peek().to_string(),- key1: key.key1.peek().to_string(),- api_secret: key.api_secret.peek().to_string(),- key2: key.key2.peek().to_string(),+ api_key: key.api_key,+ key1: key.key1,+ api_secret: key.api_secret,+ key2: key.key2,}}}diff --git a/crates/test_utils/src/main.rs b/crates/test_utils/src/main.rsindex 69dc39e622..dac0854925 100644--- a/crates/test_utils/src/main.rs+++ b/crates/test_utils/src/main.rs@@ -4,6 +4,7 @@ use std::{};use clap::{arg, command, Parser};+use masking::PeekInterface;use router::types::ConnectorAuthType;use test_utils::connector_auth::ConnectorAuthenticationMap;@@ -53,14 +54,18 @@ fn main() {if let Some(auth_type) = inner_map.get(&connector_name) {match auth_type {ConnectorAuthType::HeaderKey { api_key } => {- newman_command.args(["--env-var", &format!("connector_api_key={api_key}")]);+ // newman_command.args(["--env-var", &format!("connector_api_key={}", api_key.map(|val| val))]);+ newman_command.args([+ "--env-var",+ &format!("connector_api_key={}", api_key.peek()),+ ]);}ConnectorAuthType::BodyKey { api_key, key1 } => {newman_command.args(["--env-var",- &format!("connector_api_key={api_key}"),+ &format!("connector_api_key={}", api_key.peek()),"--env-var",- &format!("connector_key1={key1}"),+ &format!("connector_key1={}", key1.peek()),]);}ConnectorAuthType::SignatureKey {@@ -70,11 +75,11 @@ fn main() {} => {newman_command.args(["--env-var",- &format!("connector_api_key={api_key}"),+ &format!("connector_api_key={}", api_key.peek()),"--env-var",- &format!("connector_key1={key1}"),+ &format!("connector_key1={}", key1.peek()),"--env-var",- &format!("connector_api_secret={api_secret}"),+ &format!("connector_api_secret={}", api_secret.peek()),]);}ConnectorAuthType::MultiAuthKey {@@ -85,13 +90,13 @@ fn main() {} => {newman_command.args(["--env-var",- &format!("connector_api_key={api_key}"),+ &format!("connector_api_key={}", api_key.peek()),"--env-var",- &format!("connector_key1={key1}"),+ &format!("connector_key1={}", key1.peek()),"--env-var",- &format!("connector_key1={key2}"),+ &format!("connector_key1={}", key2.peek()),"--env-var",- &format!("connector_api_secret={api_secret}"),+ &format!("connector_api_secret={}", api_secret.peek()),]);}// Handle other ConnectorAuthType variants