Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor: rename `kms` feature flag to `aws_kms` (#3249)

Chethan Rao91519d846219
diff --git a/README.md b/README.md
index 0f5e924589..0da065eeba 100644
--- a/README.md
+++ b/README.md
@@ -199,7 +199,7 @@ should be introduced, checking it agrees with the actual structure -->
│ ├── data_models : Represents the data/domain models used by the business/domain layer
│ ├── diesel_models : Database models shared across `router` and other crates
│ ├── drainer : Application that reads Redis streams and executes queries in database
-│ ├── external_services : Interactions with external systems like emails, KMS, etc.
+│ ├── external_services : Interactions with external systems like emails, AWS KMS, etc.
│ ├── masking : Personal Identifiable Information protection
│ ├── redis_interface : A user-friendly interface to Redis
│ ├── router : Main crate of the project
diff --git a/config/config.example.toml b/config/config.example.toml
index 87999f0e9e..027adee5f6 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -322,7 +322,7 @@ paypal = { currency = "USD,INR", country = "US" }
# ^------------------------------- any valid payment method type (can be multiple) (for cards this should be card_network)
# If either currency or country isn't provided then, all possible values are accepted
-# KMS configuration. Only applicable when the `kms` feature flag is enabled.
+# AWS KMS configuration. Only applicable when the `aws_kms` feature flag is enabled.
[kms]
key_id = "" # The AWS key ID used by the KMS SDK for decrypting data.
region = "" # The AWS region used by the KMS SDK for decrypting data.
diff --git a/crates/drainer/Cargo.toml b/crates/drainer/Cargo.toml
index 67169a1510..adffb39875 100644
--- a/crates/drainer/Cargo.toml
+++ b/crates/drainer/Cargo.toml
@@ -8,8 +8,8 @@ readme = "README.md"
license.workspace = true
[features]
-release = ["kms", "vergen"]
-kms = ["external_services/kms"]
+release = ["aws_kms", "vergen"]
+aws_kms = ["external_services/aws_kms"]
hashicorp-vault = ["external_services/hashicorp-vault"]
vergen = ["router_env/vergen"]
diff --git a/crates/drainer/src/connection.rs b/crates/drainer/src/connection.rs
index 6af0a97822..788ff1456e 100644
--- a/crates/drainer/src/connection.rs
+++ b/crates/drainer/src/connection.rs
@@ -1,10 +1,10 @@
use bb8::PooledConnection;
use diesel::PgConnection;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms::{self, decrypt::AwsKmsDecrypt};
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::{self, decrypt::VaultFetch, Kv2};
-#[cfg(feature = "kms")]
-use external_services::kms::{self, decrypt::KmsDecrypt};
-#[cfg(not(feature = "kms"))]
+#[cfg(not(feature = "aws_kms"))]
use masking::PeekInterface;
use crate::settings::Database;
@@ -28,7 +28,7 @@ pub async fn redis_connection(
pub async fn diesel_make_pg_pool(
database: &Database,
_test_transaction: bool,
- #[cfg(feature = "kms")] kms_client: &'static kms::KmsClient,
+ #[cfg(feature = "aws_kms")] aws_kms_client: &'static aws_kms::AwsKmsClient,
#[cfg(feature = "hashicorp-vault")] hashicorp_client: &'static hashicorp_vault::HashiCorpVault,
) -> PgPool {
let password = database.password.clone();
@@ -38,13 +38,13 @@ pub async fn diesel_make_pg_pool(
.await
.expect("Failed while fetching db password");
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let password = password
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.expect("Failed to decrypt password");
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let password = &password.peek();
let database_url = format!(
diff --git a/crates/drainer/src/services.rs b/crates/drainer/src/services.rs
index 4393ebb9dc..77ee980e90 100644
--- a/crates/drainer/src/services.rs
+++ b/crates/drainer/src/services.rs
@@ -27,8 +27,8 @@ impl Store {
master_pool: diesel_make_pg_pool(
&config.master_database,
test_transaction,
- #[cfg(feature = "kms")]
- external_services::kms::get_kms_client(&config.kms).await,
+ #[cfg(feature = "aws_kms")]
+ external_services::aws_kms::get_aws_kms_client(&config.kms).await,
#[cfg(feature = "hashicorp-vault")]
#[allow(clippy::expect_used)]
external_services::hashicorp_vault::get_hashicorp_client(&config.hc_vault)
diff --git a/crates/drainer/src/settings.rs b/crates/drainer/src/settings.rs
index 5b80ee375f..a60612f8b2 100644
--- a/crates/drainer/src/settings.rs
+++ b/crates/drainer/src/settings.rs
@@ -2,10 +2,10 @@ use std::path::PathBuf;
use common_utils::ext_traits::ConfigExt;
use config::{Environment, File};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault;
-#[cfg(feature = "kms")]
-use external_services::kms;
use redis_interface as redis;
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use router_env::{env, logger};
@@ -13,9 +13,9 @@ use serde::Deserialize;
use crate::errors;
-#[cfg(feature = "kms")]
-pub type Password = kms::KmsValue;
-#[cfg(not(feature = "kms"))]
+#[cfg(feature = "aws_kms")]
+pub type Password = aws_kms::AwsKmsValue;
+#[cfg(not(feature = "aws_kms"))]
pub type Password = masking::Secret<String>;
#[derive(clap::Parser, Default)]
@@ -34,8 +34,8 @@ pub struct Settings {
pub redis: redis::RedisSettings,
pub log: Log,
pub drainer: DrainerSettings,
- #[cfg(feature = "kms")]
- pub kms: kms::KmsConfig,
+ #[cfg(feature = "aws_kms")]
+ pub kms: aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
pub hc_vault: hashicorp_vault::HashiCorpVaultConfig,
}
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index bf836af71a..2b6bc22b2e 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -8,7 +8,7 @@ readme = "README.md"
license.workspace = true
[features]
-kms = ["dep:aws-config", "dep:aws-sdk-kms"]
+aws_kms = ["dep:aws-config", "dep:aws-sdk-kms"]
email = ["dep:aws-config"]
aws_s3 = ["dep:aws-config", "dep:aws-sdk-s3"]
hashicorp-vault = [ "dep:vaultrs" ]
diff --git a/crates/external_services/src/kms.rs b/crates/external_services/src/aws_kms.rs
similarity index 69%
rename from crates/external_services/src/kms.rs
rename to crates/external_services/src/aws_kms.rs
index 740bca4d82..cf21f36f22 100644
--- a/crates/external_services/src/kms.rs
+++ b/crates/external_services/src/aws_kms.rs
@@ -14,18 +14,20 @@ pub mod decrypt;
use crate::{consts, metrics};
-static KMS_CLIENT: tokio::sync::OnceCell<KmsClient> = tokio::sync::OnceCell::const_new();
+static AWS_KMS_CLIENT: tokio::sync::OnceCell<AwsKmsClient> = tokio::sync::OnceCell::const_new();
-/// Returns a shared KMS client, or initializes a new one if not previously initialized.
+/// Returns a shared AWS KMS client, or initializes a new one if not previously initialized.
#[inline]
-pub async fn get_kms_client(config: &KmsConfig) -> &'static KmsClient {
- KMS_CLIENT.get_or_init(|| KmsClient::new(config)).await
+pub async fn get_aws_kms_client(config: &AwsKmsConfig) -> &'static AwsKmsClient {
+ AWS_KMS_CLIENT
+ .get_or_init(|| AwsKmsClient::new(config))
+ .await
}
-/// Configuration parameters required for constructing a [`KmsClient`].
+/// Configuration parameters required for constructing a [`AwsKmsClient`].
#[derive(Clone, Debug, Default, serde::Deserialize)]
#[serde(default)]
-pub struct KmsConfig {
+pub struct AwsKmsConfig {
/// The AWS key identifier of the KMS key used to encrypt or decrypt data.
pub key_id: String,
@@ -33,16 +35,16 @@ pub struct KmsConfig {
pub region: String,
}
-/// Client for KMS operations.
+/// Client for AWS KMS operations.
#[derive(Debug)]
-pub struct KmsClient {
+pub struct AwsKmsClient {
inner_client: Client,
key_id: String,
}
-impl KmsClient {
- /// Constructs a new KMS client.
- pub async fn new(config: &KmsConfig) -> Self {
+impl AwsKmsClient {
+ /// Constructs a new AWS KMS client.
+ pub async fn new(config: &AwsKmsConfig) -> Self {
let region_provider = RegionProviderChain::first_try(Region::new(config.region.clone()));
let sdk_config = aws_config::from_env().region(region_provider).load().await;
@@ -56,12 +58,12 @@ impl KmsClient {
/// the SDK has the values required to interact with the AWS KMS APIs (`AWS_ACCESS_KEY_ID` and
/// `AWS_SECRET_ACCESS_KEY`) either set in environment variables, or that the SDK is running in
/// a machine that is able to assume an IAM role.
- pub async fn decrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, KmsError> {
+ pub async fn decrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> {
let start = Instant::now();
let data = consts::BASE64_ENGINE
.decode(data)
.into_report()
- .change_context(KmsError::Base64DecodingFailed)?;
+ .change_context(AwsKmsError::Base64DecodingFailed)?;
let ciphertext_blob = Blob::new(data);
let decrypt_output = self
@@ -74,21 +76,21 @@ impl KmsClient {
.map_err(|error| {
// Logging using `Debug` representation of the error as the `Display`
// representation does not hold sufficient information.
- logger::error!(kms_sdk_error=?error, "Failed to KMS decrypt data");
+ logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS decrypt data");
metrics::AWS_KMS_DECRYPTION_FAILURES.add(&metrics::CONTEXT, 1, &[]);
error
})
.into_report()
- .change_context(KmsError::DecryptionFailed)?;
+ .change_context(AwsKmsError::DecryptionFailed)?;
let output = decrypt_output
.plaintext
- .ok_or(KmsError::MissingPlaintextDecryptionOutput)
+ .ok_or(AwsKmsError::MissingPlaintextDecryptionOutput)
.into_report()
.and_then(|blob| {
String::from_utf8(blob.into_inner())
.into_report()
- .change_context(KmsError::Utf8DecodingFailed)
+ .change_context(AwsKmsError::Utf8DecodingFailed)
})?;
let time_taken = start.elapsed();
@@ -101,7 +103,7 @@ impl KmsClient {
/// the SDK has the values required to interact with the AWS KMS APIs (`AWS_ACCESS_KEY_ID` and
/// `AWS_SECRET_ACCESS_KEY`) either set in environment variables, or that the SDK is running in
/// a machine that is able to assume an IAM role.
- pub async fn encrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, KmsError> {
+ pub async fn encrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> {
let start = Instant::now();
let plaintext_blob = Blob::new(data.as_ref());
@@ -115,16 +117,16 @@ impl KmsClient {
.map_err(|error| {
// Logging using `Debug` representation of the error as the `Display`
// representation does not hold sufficient information.
- logger::error!(kms_sdk_error=?error, "Failed to KMS encrypt data");
+ logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS encrypt data");
metrics::AWS_KMS_ENCRYPTION_FAILURES.add(&metrics::CONTEXT, 1, &[]);
error
})
.into_report()
- .change_context(KmsError::EncryptionFailed)?;
+ .change_context(AwsKmsError::EncryptionFailed)?;
let output = encrypted_output
.ciphertext_blob
- .ok_or(KmsError::MissingCiphertextEncryptionOutput)
+ .ok_or(AwsKmsError::MissingCiphertextEncryptionOutput)
.into_report()
.map(|blob| consts::BASE64_ENGINE.encode(blob.into_inner()))?;
let time_taken = start.elapsed();
@@ -134,9 +136,9 @@ impl KmsClient {
}
}
-/// Errors that could occur during KMS operations.
+/// Errors that could occur during AWS KMS operations.
#[derive(Debug, thiserror::Error)]
-pub enum KmsError {
+pub enum AwsKmsError {
/// An error occurred when base64 encoding input data.
#[error("Failed to base64 encode input data")]
Base64EncodingFailed,
@@ -145,33 +147,33 @@ pub enum KmsError {
#[error("Failed to base64 decode input data")]
Base64DecodingFailed,
- /// An error occurred when KMS decrypting input data.
- #[error("Failed to KMS decrypt input data")]
+ /// An error occurred when AWS KMS decrypting input data.
+ #[error("Failed to AWS KMS decrypt input data")]
DecryptionFailed,
- /// An error occurred when KMS encrypting input data.
- #[error("Failed to KMS encrypt input data")]
+ /// An error occurred when AWS KMS encrypting input data.
+ #[error("Failed to AWS KMS encrypt input data")]
EncryptionFailed,
- /// The KMS decrypted output does not include a plaintext output.
- #[error("Missing plaintext KMS decryption output")]
+ /// The AWS KMS decrypted output does not include a plaintext output.
+ #[error("Missing plaintext AWS KMS decryption output")]
MissingPlaintextDecryptionOutput,
- /// The KMS encrypted output does not include a ciphertext output.
- #[error("Missing ciphertext KMS encryption output")]
+ /// The AWS KMS encrypted output does not include a ciphertext output.
+ #[error("Missing ciphertext AWS KMS encryption output")]
MissingCiphertextEncryptionOutput,
- /// An error occurred UTF-8 decoding KMS decrypted output.
+ /// An error occurred UTF-8 decoding AWS KMS decrypted output.
#[error("Failed to UTF-8 decode decryption output")]
Utf8DecodingFailed,
- /// The KMS client has not been initialized.
- #[error("The KMS client has not been initialized")]
- KmsClientNotInitialized,
+ /// The AWS KMS client has not been initialized.
+ #[error("The AWS KMS client has not been initialized")]
+ AwsKmsClientNotInitialized,
}
-impl KmsConfig {
- /// Verifies that the [`KmsClient`] configuration is usable.
+impl AwsKmsConfig {
+ /// Verifies that the [`AwsKmsClient`] configuration is usable.
pub fn validate(&self) -> Result<(), &'static str> {
use common_utils::{ext_traits::ConfigExt, fp_utils::when};
@@ -185,18 +187,24 @@ impl KmsConfig {
}
}
-/// A wrapper around a KMS value that can be decrypted.
+/// A wrapper around a AWS KMS value that can be decrypted.
#[derive(Clone, Debug, Default, serde::Deserialize, Eq, PartialEq)]
#[serde(transparent)]
-pub struct KmsValue(Secret<String>);
+pub struct AwsKmsValue(Secret<String>);
-impl From<String> for KmsValue {
+impl common_utils::ext_traits::ConfigExt for AwsKmsValue {
+ fn is_empty_after_trim(&self) -> bool {
+ self.0.peek().is_empty_after_trim()
+ }
+}
+
+impl From<String> for AwsKmsValue {
fn from(value: String) -> Self {
Self(Secret::new(value))
}
}
-impl From<Secret<String>> for KmsValue {
+impl From<Secret<String>> for AwsKmsValue {
fn from(value: Secret<String>) -> Self {
Self(value)
}
@@ -204,7 +212,7 @@ impl From<Secret<String>> for KmsValue {
#[cfg(feature = "hashicorp-vault")]
#[async_trait::async_trait]
-impl super::hashicorp_vault::decrypt::VaultFetch for KmsValue {
+impl super::hashicorp_vault::decrypt::VaultFetch for AwsKmsValue {
async fn fetch_inner<En>(
self,
client: &super::hashicorp_vault::HashiCorpVault,
@@ -224,13 +232,7 @@ impl super::hashicorp_vault::decrypt::VaultFetch for KmsValue {
>,
> + 'a,
{
- self.0.fetch_inner::<En>(client).await.map(KmsValue)
- }
-}
-
-impl common_utils::ext_traits::ConfigExt for KmsValue {
- fn is_empty_after_trim(&self) -> bool {
- self.0.peek().is_empty_after_trim()
+ self.0.fetch_inner::<En>(client).await.map(AwsKmsValue)
}
}
@@ -238,44 +240,44 @@ impl common_utils::ext_traits::ConfigExt for KmsValue {
mod tests {
#![allow(clippy::expect_used)]
#[tokio::test]
- async fn check_kms_encryption() {
+ async fn check_aws_kms_encryption() {
std::env::set_var("AWS_SECRET_ACCESS_KEY", "YOUR SECRET ACCESS KEY");
std::env::set_var("AWS_ACCESS_KEY_ID", "YOUR AWS ACCESS KEY ID");
use super::*;
- let config = KmsConfig {
- key_id: "YOUR KMS KEY ID".to_string(),
+ let config = AwsKmsConfig {
+ key_id: "YOUR AWS KMS KEY ID".to_string(),
region: "AWS REGION".to_string(),
};
let data = "hello".to_string();
let binding = data.as_bytes();
- let kms_encrypted_fingerprint = KmsClient::new(&config)
+ let kms_encrypted_fingerprint = AwsKmsClient::new(&config)
.await
.encrypt(binding)
.await
- .expect("kms encryption failed");
+ .expect("aws kms encryption failed");
println!("{}", kms_encrypted_fingerprint);
}
#[tokio::test]
- async fn check_kms_decrypt() {
+ async fn check_aws_kms_decrypt() {
std::env::set_var("AWS_SECRET_ACCESS_KEY", "YOUR SECRET ACCESS KEY");
std::env::set_var("AWS_ACCESS_KEY_ID", "YOUR AWS ACCESS KEY ID");
use super::*;
- let config = KmsConfig {
- key_id: "YOUR KMS KEY ID".to_string(),
+ let config = AwsKmsConfig {
+ key_id: "YOUR AWS KMS KEY ID".to_string(),
region: "AWS REGION".to_string(),
};
// Should decrypt to hello
- let data = "KMS ENCRYPTED CIPHER".to_string();
+ let data = "AWS KMS ENCRYPTED CIPHER".to_string();
let binding = data.as_bytes();
- let kms_encrypted_fingerprint = KmsClient::new(&config)
+ let kms_encrypted_fingerprint = AwsKmsClient::new(&config)
.await
.decrypt(binding)
.await
- .expect("kms decryption failed");
+ .expect("aws kms decryption failed");
println!("{}", kms_encrypted_fingerprint);
}
diff --git a/crates/external_services/src/aws_kms/decrypt.rs b/crates/external_services/src/aws_kms/decrypt.rs
new file mode 100644
index 0000000000..9abd4fefbe
--- /dev/null
+++ b/crates/external_services/src/aws_kms/decrypt.rs
@@ -0,0 +1,42 @@
+use common_utils::errors::CustomResult;
+
+use super::*;
+
+#[async_trait::async_trait]
+/// This trait performs in place decryption of the structure on which this is implemented
+pub trait AwsKmsDecrypt {
+ /// The output type of the decryption
+ type Output;
+ /// Decrypts the structure given a AWS KMS client
+ async fn decrypt_inner(
+ self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError>
+ where
+ Self: Sized;
+
+ /// Tries to use the Singleton client to decrypt the structure
+ async fn try_decrypt_inner(self) -> CustomResult<Self::Output, AwsKmsError>
+ where
+ Self: Sized,
+ {
+ let client = AWS_KMS_CLIENT
+ .get()
+ .ok_or(AwsKmsError::AwsKmsClientNotInitialized)?;
+ self.decrypt_inner(client).await
+ }
+}
+
+#[async_trait::async_trait]
+impl AwsKmsDecrypt for &AwsKmsValue {
+ type Output = String;
+ async fn decrypt_inner(
+ self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError> {
+ aws_kms_client
+ .decrypt(self.0.peek())
+ .await
+ .attach_printable("Failed to decrypt AWS KMS value")
+ }
+}
diff --git a/crates/external_services/src/kms/decrypt.rs b/crates/external_services/src/kms/decrypt.rs
deleted file mode 100644
index 0749745aff..0000000000
--- a/crates/external_services/src/kms/decrypt.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-use common_utils::errors::CustomResult;
-
-use super::*;
-
-#[async_trait::async_trait]
-/// This trait performs in place decryption of the structure on which this is implemented
-pub trait KmsDecrypt {
- /// The output type of the decryption
- type Output;
- /// Decrypts the structure given a KMS client
- async fn decrypt_inner(self, kms_client: &KmsClient) -> CustomResult<Self::Output, KmsError>
- where
- Self: Sized;
-
- /// Tries to use the Singleton client to decrypt the structure
- async fn try_decrypt_inner(self) -> CustomResult<Self::Output, KmsError>
- where
- Self: Sized,
- {
- let client = KMS_CLIENT.get().ok_or(KmsError::KmsClientNotInitialized)?;
- self.decrypt_inner(client).await
- }
-}
-
-#[async_trait::async_trait]
-impl KmsDecrypt for &KmsValue {
- type Output = String;
- async fn decrypt_inner(self, kms_client: &KmsClient) -> CustomResult<Self::Output, KmsError> {
- kms_client
- .decrypt(self.0.peek())
- .await
- .attach_printable("Failed to decrypt KMS value")
- }
-}
diff --git a/crates/external_services/src/lib.rs b/crates/external_services/src/lib.rs
index bba65873e9..cdabdeb49a 100644
--- a/crates/external_services/src/lib.rs
+++ b/crates/external_services/src/lib.rs
@@ -6,15 +6,15 @@
#[cfg(feature = "email")]
pub mod email;
-#[cfg(feature = "kms")]
-pub mod kms;
+#[cfg(feature = "aws_kms")]
+pub mod aws_kms;
pub mod file_storage;
#[cfg(feature = "hashicorp-vault")]
pub mod hashicorp_vault;
/// Crate specific constants
-#[cfg(feature = "kms")]
+#[cfg(feature = "aws_kms")]
pub mod consts {
/// General purpose base64 engine
pub(crate) const BASE64_ENGINE: base64::engine::GeneralPurpose =
@@ -22,20 +22,20 @@ pub mod consts {
}
/// Metrics for interactions with external systems.
-#[cfg(feature = "kms")]
+#[cfg(feature = "aws_kms")]
pub mod metrics {
use router_env::{counter_metric, global_meter, histogram_metric, metrics_context};
metrics_context!(CONTEXT);
global_meter!(GLOBAL_METER, "EXTERNAL_SERVICES");
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
counter_metric!(AWS_KMS_DECRYPTION_FAILURES, GLOBAL_METER); // No. of AWS KMS Decryption failures
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
counter_metric!(AWS_KMS_ENCRYPTION_FAILURES, GLOBAL_METER); // No. of AWS KMS Encryption failures
- #[cfg(feature = "kms")]
- histogram_metric!(AWS_KMS_DECRYPT_TIME, GLOBAL_METER); // Histogram for KMS decryption time (in sec)
- #[cfg(feature = "kms")]
- histogram_metric!(AWS_KMS_ENCRYPT_TIME, GLOBAL_METER); // Histogram for KMS encryption time (in sec)
+ #[cfg(feature = "aws_kms")]
+ histogram_metric!(AWS_KMS_DECRYPT_TIME, GLOBAL_METER); // Histogram for AWS KMS decryption time (in sec)
+ #[cfg(feature = "aws_kms")]
+ histogram_metric!(AWS_KMS_ENCRYPT_TIME, GLOBAL_METER); // Histogram for AWS KMS encryption time (in sec)
}
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index f60b0c25e9..9b345217bb 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -11,12 +11,12 @@ license.workspace = true
[features]
default = ["kv_store", "stripe", "oltp", "olap", "backwards_compatibility", "accounts_cache", "dummy_connector", "payouts", "business_profile_routing", "connector_choice_mca_id", "profile_specific_fallback_routing", "retry", "frm"]
aws_s3 = ["external_services/aws_s3"]
-kms = ["external_services/kms"]
+aws_kms = ["external_services/aws_kms"]
hashicorp-vault = ["external_services/hashicorp-vault"]
email = ["external_services/email", "olap"]
frm = []
stripe = ["dep:serde_qs"]
-release = ["kms", "stripe", "aws_s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon"]
+release = ["aws_kms", "stripe", "aws_s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon"]
olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap","api_models/olap","dep:analytics"]
oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]
diff --git a/crates/router/src/configs.rs b/crates/router/src/configs.rs
index 5cb1df0644..d069c89b82 100644
--- a/crates/router/src/configs.rs
+++ b/crates/router/src/configs.rs
@@ -1,7 +1,7 @@
+#[cfg(feature = "aws_kms")]
+pub mod aws_kms;
mod defaults;
#[cfg(feature = "hashicorp-vault")]
pub mod hc_vault;
-#[cfg(feature = "kms")]
-pub mod kms;
pub mod settings;
mod validations;
diff --git a/crates/router/src/configs/aws_kms.rs b/crates/router/src/configs/aws_kms.rs
new file mode 100644
index 0000000000..5e37f2a4dd
--- /dev/null
+++ b/crates/router/src/configs/aws_kms.rs
@@ -0,0 +1,107 @@
+use common_utils::errors::CustomResult;
+use external_services::aws_kms::{decrypt::AwsKmsDecrypt, AwsKmsClient, AwsKmsError};
+use masking::ExposeInterface;
+
+use crate::configs::settings;
+
+#[async_trait::async_trait]
+impl AwsKmsDecrypt for settings::Jwekey {
+ type Output = Self;
+
+ async fn decrypt_inner(
+ mut self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError> {
+ (
+ self.vault_encryption_key,
+ self.rust_locker_encryption_key,
+ self.vault_private_key,
+ self.tunnel_private_key,
+ ) = tokio::try_join!(
+ aws_kms_client.decrypt(self.vault_encryption_key),
+ aws_kms_client.decrypt(self.rust_locker_encryption_key),
+ aws_kms_client.decrypt(self.vault_private_key),
+ aws_kms_client.decrypt(self.tunnel_private_key),
+ )?;
+ Ok(self)
+ }
+}
+
+#[async_trait::async_trait]
+impl AwsKmsDecrypt for settings::ActiveKmsSecrets {
+ type Output = Self;
+ async fn decrypt_inner(
+ mut self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError> {
+ self.jwekey = self
+ .jwekey
+ .expose()
+ .decrypt_inner(aws_kms_client)
+ .await?
+ .into();
+ Ok(self)
+ }
+}
+
+#[async_trait::async_trait]
+impl AwsKmsDecrypt for settings::Database {
+ type Output = storage_impl::config::Database;
+
+ async fn decrypt_inner(
+ mut self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError> {
+ Ok(storage_impl::config::Database {
+ host: self.host,
+ port: self.port,
+ dbname: self.dbname,
+ username: self.username,
+ password: self.password.decrypt_inner(aws_kms_client).await?.into(),
+ pool_size: self.pool_size,
+ connection_timeout: self.connection_timeout,
+ queue_strategy: self.queue_strategy,
+ min_idle: self.min_idle,
+ max_lifetime: self.max_lifetime,
+ })
+ }
+}
+
+#[cfg(feature = "olap")]
+#[async_trait::async_trait]
+impl AwsKmsDecrypt for settings::PayPalOnboarding {
+ type Output = Self;
+
+ async fn decrypt_inner(
+ mut self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError> {
+ self.client_id = aws_kms_client
+ .decrypt(self.client_id.expose())
+ .await?
+ .into();
+ self.client_secret = aws_kms_client
+ .decrypt(self.client_secret.expose())
+ .await?
+ .into();
+ self.partner_id = aws_kms_client
+ .decrypt(self.partner_id.expose())
+ .await?
+ .into();
+ Ok(self)
+ }
+}
+
+#[cfg(feature = "olap")]
+#[async_trait::async_trait]
+impl AwsKmsDecrypt for settings::ConnectorOnboarding {
+ type Output = Self;
+
+ async fn decrypt_inner(
+ mut self,
+ aws_kms_client: &AwsKmsClient,
+ ) -> CustomResult<Self::Output, AwsKmsError> {
+ self.paypal = self.paypal.decrypt_inner(aws_kms_client).await?;
+ Ok(self)
+ }
+}
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 7b88c9c2dc..fc5ba0f55b 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -1,8 +1,8 @@
use std::collections::{HashMap, HashSet};
use api_models::{enums, payment_methods::RequiredFieldInfo};
-#[cfg(feature = "kms")]
-use external_services::kms::KmsValue;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms::AwsKmsValue;
use super::settings::{ConnectorFields, Password, PaymentMethodType, RequiredFieldFinal};
@@ -6235,12 +6235,12 @@ impl Default for super::settings::RequiredFields {
impl Default for super::settings::ApiKeys {
fn default() -> Self {
Self {
- #[cfg(feature = "kms")]
- kms_encrypted_hash_key: KmsValue::default(),
+ #[cfg(feature = "aws_kms")]
+ kms_encrypted_hash_key: AwsKmsValue::default(),
// Hex-encoded 32-byte long (64 characters long when hex-encoded) key used for calculating
// hashes of API keys
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
hash_key: String::new(),
// Specifies the number of days before API key expiry when email reminders should be sent
diff --git a/crates/router/src/configs/kms.rs b/crates/router/src/configs/kms.rs
deleted file mode 100644
index 4e236a512a..0000000000
--- a/crates/router/src/configs/kms.rs
+++ /dev/null
@@ -1,96 +0,0 @@
-use common_utils::errors::CustomResult;
-use external_services::kms::{decrypt::KmsDecrypt, KmsClient, KmsError};
-use masking::ExposeInterface;
-
-use crate::configs::settings;
-
-#[async_trait::async_trait]
-impl KmsDecrypt for settings::Jwekey {
- type Output = Self;
-
- async fn decrypt_inner(
- mut self,
- kms_client: &KmsClient,
- ) -> CustomResult<Self::Output, KmsError> {
- (
- self.vault_encryption_key,
- self.rust_locker_encryption_key,
- self.vault_private_key,
- self.tunnel_private_key,
- ) = tokio::try_join!(
- kms_client.decrypt(self.vault_encryption_key),
- kms_client.decrypt(self.rust_locker_encryption_key),
- kms_client.decrypt(self.vault_private_key),
- kms_client.decrypt(self.tunnel_private_key),
- )?;
- Ok(self)
- }
-}
-
-#[async_trait::async_trait]
-impl KmsDecrypt for settings::ActiveKmsSecrets {
- type Output = Self;
- async fn decrypt_inner(
- mut self,
- kms_client: &KmsClient,
- ) -> CustomResult<Self::Output, KmsError> {
- self.jwekey = self.jwekey.expose().decrypt_inner(kms_client).await?.into();
- Ok(self)
- }
-}
-
-#[async_trait::async_trait]
-impl KmsDecrypt for settings::Database {
- type Output = storage_impl::config::Database;
-
- async fn decrypt_inner(
- mut self,
- kms_client: &KmsClient,
- ) -> CustomResult<Self::Output, KmsError> {
- Ok(storage_impl::config::Database {
- host: self.host,
- port: self.port,
- dbname: self.dbname,
- username: self.username,
- password: self.password.decrypt_inner(kms_client).await?.into(),
- pool_size: self.pool_size,
- connection_timeout: self.connection_timeout,
- queue_strategy: self.queue_strategy,
- min_idle: self.min_idle,
- max_lifetime: self.max_lifetime,
- })
- }
-}
-
-#[cfg(feature = "olap")]
-#[async_trait::async_trait]
-impl KmsDecrypt for settings::PayPalOnboarding {
- type Output = Self;
-
- async fn decrypt_inner(
- mut self,
- kms_client: &KmsClient,
- ) -> CustomResult<Self::Output, KmsError> {
- self.client_id = kms_client.decrypt(self.client_id.expose()).await?.into();
- self.client_secret = kms_client
- .decrypt(self.client_secret.expose())
- .await?
- .into();
- self.partner_id = kms_client.decrypt(self.partner_id.expose()).await?.into();
- Ok(self)
- }
-}
-
-#[cfg(feature = "olap")]
-#[async_trait::async_trait]
-impl KmsDecrypt for settings::ConnectorOnboarding {
- type Output = Self;
-
- async fn decrypt_inner(
- mut self,
- kms_client: &KmsClient,
- ) -> CustomResult<Self::Output, KmsError> {
- self.paypal = self.paypal.decrypt_inner(kms_client).await?;
- Ok(self)
- }
-}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index dd6eaa104c..2519455f95 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -8,13 +8,13 @@ use analytics::ReportConfig;
use api_models::{enums, payment_methods::RequiredFieldInfo};
use common_utils::ext_traits::ConfigExt;
use config::{Environment, File};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
#[cfg(feature = "email")]
use external_services::email::EmailSettings;
use external_services::file_storage::FileStorageConfig;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault;
-#[cfg(feature = "kms")]
-use external_services::kms;
use redis_interface::RedisSettings;
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use rust_decimal::Decimal;
@@ -29,9 +29,9 @@ use crate::{
env::{self, logger, Env},
events::EventsConfig,
};
-#[cfg(feature = "kms")]
-pub type Password = kms::KmsValue;
-#[cfg(not(feature = "kms"))]
+#[cfg(feature = "aws_kms")]
+pub type Password = aws_kms::AwsKmsValue;
+#[cfg(not(feature = "aws_kms"))]
pub type Password = masking::Secret<String>;
#[derive(clap::Parser, Default)]
@@ -53,8 +53,8 @@ pub enum Subcommand {
GenerateOpenapiSpec,
}
-#[cfg(feature = "kms")]
-/// Store the decrypted kms secret values for active use in the application
+#[cfg(feature = "aws_kms")]
+/// Store the decrypted aws kms secret values for active use in the application
/// Currently using `StrongSecret` won't have any effect as this struct have smart pointers to heap
/// allocations.
/// note: we can consider adding such behaviour in the future with custom implementation
@@ -88,8 +88,8 @@ pub struct Settings {
pub pm_filters: ConnectorFilters,
pub bank_config: BankRedirectConfig,
pub api_keys: ApiKeys,
- #[cfg(feature = "kms")]
- pub kms: kms::KmsConfig,
+ #[cfg(feature = "aws_kms")]
+ pub kms: aws_kms::AwsKmsConfig,
pub file_storage: FileStorageConfig,
#[cfg(feature = "hashicorp-vault")]
pub hc_vault: hashicorp_vault::HashiCorpVaultConfig,
@@ -359,19 +359,19 @@ pub struct RequiredFieldFinal {
#[derive(Debug, Default, Deserialize, Clone)]
#[serde(default)]
pub struct Secrets {
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
pub jwt_secret: String,
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
pub admin_api_key: String,
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
pub recon_admin_api_key: String,
pub master_enc_key: Password,
- #[cfg(feature = "kms")]
- pub kms_encrypted_jwt_secret: kms::KmsValue,
- #[cfg(feature = "kms")]
- pub kms_encrypted_admin_api_key: kms::KmsValue,
- #[cfg(feature = "kms")]
- pub kms_encrypted_recon_admin_api_key: kms::KmsValue,
+ #[cfg(feature = "aws_kms")]
+ pub kms_encrypted_jwt_secret: aws_kms::AwsKmsValue,
+ #[cfg(feature = "aws_kms")]
+ pub kms_encrypted_admin_api_key: aws_kms::AwsKmsValue,
+ #[cfg(feature = "aws_kms")]
+ pub kms_encrypted_recon_admin_api_key: aws_kms::AwsKmsValue,
}
#[derive(Debug, Deserialize, Clone)]
@@ -441,7 +441,7 @@ pub struct Database {
pub max_lifetime: Option<u64>,
}
-#[cfg(not(feature = "kms"))]
+#[cfg(not(feature = "aws_kms"))]
impl From<Database> for storage_impl::config::Database {
fn from(val: Database) -> Self {
Self {
@@ -596,12 +596,12 @@ pub struct WebhookIgnoreErrorSettings {
pub struct ApiKeys {
/// Base64-encoded (KMS encrypted) ciphertext of the key used for calculating hashes of API
/// keys
- #[cfg(feature = "kms")]
- pub kms_encrypted_hash_key: kms::KmsValue,
+ #[cfg(feature = "aws_kms")]
+ pub kms_encrypted_hash_key: aws_kms::AwsKmsValue,
/// Hex-encoded 32-byte long (64 characters long when hex-encoded) key used for calculating
/// hashes of API keys
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
pub hash_key: String,
// Specifies the number of days before API key expiry when email reminders should be sent
@@ -712,7 +712,7 @@ impl Settings {
#[cfg(feature = "kv_store")]
self.drainer.validate()?;
self.api_keys.validate()?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
self.kms
.validate()
.map_err(|error| ApplicationError::InvalidConfigurationValueError(error.into()))?;
diff --git a/crates/router/src/configs/validations.rs b/crates/router/src/configs/validations.rs
index 910ae75434..a4eb3f3c66 100644
--- a/crates/router/src/configs/validations.rs
+++ b/crates/router/src/configs/validations.rs
@@ -5,7 +5,7 @@ impl super::settings::Secrets {
pub fn validate(&self) -> Result<(), ApplicationError> {
use common_utils::fp_utils::when;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
{
when(self.jwt_secret.is_default_or_empty(), || {
Err(ApplicationError::InvalidConfigurationValueError(
@@ -20,7 +20,7 @@ impl super::settings::Secrets {
})?;
}
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
{
when(self.kms_encrypted_jwt_secret.is_default_or_empty(), || {
Err(ApplicationError::InvalidConfigurationValueError(
@@ -131,14 +131,14 @@ impl super::settings::ApiKeys {
pub fn validate(&self) -> Result<(), ApplicationError> {
use common_utils::fp_utils::when;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
return when(self.kms_encrypted_hash_key.is_default_or_empty(), || {
Err(ApplicationError::InvalidConfigurationValueError(
"API key hashing key must not be empty when KMS feature is enabled".into(),
))
});
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
when(self.hash_key.is_empty(), || {
Err(ApplicationError::InvalidConfigurationValueError(
"API key hashing key must not be empty".into(),
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index 9bdc493e07..58f95e1371 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -35,7 +35,7 @@ pub mod user;
#[cfg(feature = "olap")]
pub mod user_role;
pub mod utils;
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
diff --git a/crates/router/src/core/api_keys.rs b/crates/router/src/core/api_keys.rs
index f28d845609..162f8bed0f 100644
--- a/crates/router/src/core/api_keys.rs
+++ b/crates/router/src/core/api_keys.rs
@@ -2,11 +2,11 @@ use common_utils::date_time;
#[cfg(feature = "email")]
use diesel_models::{api_keys::ApiKey, enums as storage_enums};
use error_stack::{report, IntoReport, ResultExt};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::decrypt::VaultFetch;
-#[cfg(feature = "kms")]
-use external_services::kms;
-#[cfg(not(feature = "kms"))]
+#[cfg(not(feature = "aws_kms"))]
use masking::ExposeInterface;
use masking::{PeekInterface, StrongSecret};
use router_env::{instrument, tracing};
@@ -30,26 +30,26 @@ const API_KEY_EXPIRY_NAME: &str = "API_KEY_EXPIRY";
#[cfg(feature = "email")]
const API_KEY_EXPIRY_RUNNER: &str = "API_KEY_EXPIRY_WORKFLOW";
-#[cfg(feature = "kms")]
-use external_services::kms::decrypt::KmsDecrypt;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms::decrypt::AwsKmsDecrypt;
static HASH_KEY: tokio::sync::OnceCell<StrongSecret<[u8; PlaintextApiKey::HASH_KEY_LEN]>> =
tokio::sync::OnceCell::const_new();
pub async fn get_hash_key(
api_key_config: &settings::ApiKeys,
- #[cfg(feature = "kms")] kms_client: &kms::KmsClient,
+ #[cfg(feature = "aws_kms")] aws_kms_client: &aws_kms::AwsKmsClient,
#[cfg(feature = "hashicorp-vault")]
hc_client: &external_services::hashicorp_vault::HashiCorpVault,
) -> errors::RouterResult<&'static StrongSecret<[u8; PlaintextApiKey::HASH_KEY_LEN]>> {
HASH_KEY
.get_or_try_init(|| async {
let hash_key = {
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
{
api_key_config.kms_encrypted_hash_key.clone()
}
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
{
masking::Secret::<_, masking::WithType>::new(api_key_config.hash_key.clone())
}
@@ -61,14 +61,14 @@ pub async fn get_hash_key(
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let hash_key = hash_key
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to KMS decrypt API key hashing key")?;
+ .attach_printable("Failed to AWS KMS decrypt API key hashing key")?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let hash_key = hash_key.expose();
<[u8; PlaintextApiKey::HASH_KEY_LEN]>::try_from(
@@ -153,7 +153,7 @@ impl PlaintextApiKey {
#[instrument(skip_all)]
pub async fn create_api_key(
state: AppState,
- #[cfg(feature = "kms")] kms_client: &kms::KmsClient,
+ #[cfg(feature = "aws_kms")] aws_kms_client: &aws_kms::AwsKmsClient,
#[cfg(feature = "hashicorp-vault")]
hc_client: &external_services::hashicorp_vault::HashiCorpVault,
api_key: api::CreateApiKeyRequest,
@@ -175,8 +175,8 @@ pub async fn create_api_key(
let hash_key = get_hash_key(
api_key_config,
- #[cfg(feature = "kms")]
- kms_client,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_client,
#[cfg(feature = "hashicorp-vault")]
hc_client,
)
@@ -589,8 +589,8 @@ mod tests {
let plaintext_api_key = PlaintextApiKey::new(consts::API_KEY_LENGTH);
let hash_key = get_hash_key(
&settings.api_keys,
- #[cfg(feature = "kms")]
- external_services::kms::get_kms_client(&settings.kms).await,
+ #[cfg(feature = "aws_kms")]
+ external_services::aws_kms::get_aws_kms_client(&settings.kms).await,
#[cfg(feature = "hashicorp-vault")]
external_services::hashicorp_vault::get_hashicorp_client(&settings.hc_vault)
.await
diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rs
index b7effaf63a..0e452a90f4 100644
--- a/crates/router/src/core/blocklist/utils.rs
+++ b/crates/router/src/core/blocklist/utils.rs
@@ -1,8 +1,8 @@
use api_models::blocklist as api_blocklist;
use common_utils::crypto::{self, SignMessage};
use error_stack::{IntoReport, ResultExt};
-#[cfg(feature = "kms")]
-use external_services::kms;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
use super::{errors, AppState};
use crate::{
@@ -38,15 +38,15 @@ pub async fn delete_entry_from_blocklist(
message: "blocklist record with given fingerprint id not found".to_string(),
})?;
- #[cfg(feature = "kms")]
- let decrypted_fingerprint = kms::get_kms_client(&state.conf.kms)
+ #[cfg(feature = "aws_kms")]
+ let decrypted_fingerprint = aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(blocklist_fingerprint.encrypted_fingerprint)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("failed to kms decrypt fingerprint")?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let decrypted_fingerprint = blocklist_fingerprint.encrypted_fingerprint;
let blocklist_entry = state
@@ -184,15 +184,15 @@ pub async fn insert_entry_into_blocklist(
message: "fingerprint not found".to_string(),
})?;
- #[cfg(feature = "kms")]
- let decrypted_fingerprint = kms::get_kms_client(&state.conf.kms)
+ #[cfg(feature = "aws_kms")]
+ let decrypted_fingerprint = aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(blocklist_fingerprint.encrypted_fingerprint)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("failed to kms decrypt encrypted fingerprint")?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let decrypted_fingerprint = blocklist_fingerprint.encrypted_fingerprint;
state
diff --git a/crates/router/src/core/currency.rs b/crates/router/src/core/currency.rs
index 41699df47a..b0d06f9fd6 100644
--- a/crates/router/src/core/currency.rs
+++ b/crates/router/src/core/currency.rs
@@ -17,7 +17,7 @@ pub async fn retrieve_forex(
state.conf.forex_api.call_delay,
state.conf.forex_api.local_fetch_retry_delay,
state.conf.forex_api.local_fetch_retry_count,
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
&state.conf.kms,
#[cfg(feature = "hashicorp-vault")]
&state.conf.hc_vault,
@@ -44,7 +44,7 @@ pub async fn convert_forex(
amount,
to_currency,
from_currency,
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
&state.conf.kms,
#[cfg(feature = "hashicorp-vault")]
&state.conf.hc_vault,
diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rs
index 9052893d4a..c7486e827c 100644
--- a/crates/router/src/core/errors.rs
+++ b/crates/router/src/core/errors.rs
@@ -221,12 +221,12 @@ pub enum VaultError {
}
#[derive(Debug, thiserror::Error)]
-pub enum KmsError {
+pub enum AwsKmsError {
#[error("Failed to base64 decode input data")]
Base64DecodingFailed,
- #[error("Failed to KMS decrypt input data")]
+ #[error("Failed to AWS KMS decrypt input data")]
DecryptionFailed,
- #[error("Missing plaintext KMS decryption output")]
+ #[error("Missing plaintext AWS KMS decryption output")]
MissingPlaintextDecryptionOutput,
#[error("Failed to UTF-8 decode decryption output")]
Utf8DecodingFailed,
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 5797fd60da..4bc0490e7d 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -603,9 +603,9 @@ pub async fn get_payment_method_from_hs_locker<'a>(
locker_choice: Option<api_enums::LockerChoice>,
) -> errors::CustomResult<Secret<String>, errors::VaultError> {
let locker = &state.conf.locker;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let jwekey = &state.conf.jwekey;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let jwekey = &state.kms_secrets;
let payment_method_data = if !locker.mock_locker {
@@ -661,9 +661,9 @@ pub async fn call_to_locker_hs<'a>(
locker_choice: api_enums::LockerChoice,
) -> errors::CustomResult<payment_methods::StoreCardRespPayload, errors::VaultError> {
let locker = &state.conf.locker;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let jwekey = &state.conf.jwekey;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let jwekey = &state.kms_secrets;
let db = &*state.store;
let stored_card_response = if !locker.mock_locker {
@@ -722,9 +722,9 @@ pub async fn get_card_from_hs_locker<'a>(
locker_choice: api_enums::LockerChoice,
) -> errors::CustomResult<payment_methods::Card, errors::VaultError> {
let locker = &state.conf.locker;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let jwekey = &state.conf.jwekey;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let jwekey = &state.kms_secrets;
if !locker.mock_locker {
@@ -777,9 +777,9 @@ pub async fn delete_card_from_hs_locker<'a>(
card_reference: &'a str,
) -> errors::RouterResult<payment_methods::DeleteCardResp> {
let locker = &state.conf.locker;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let jwekey = &state.conf.jwekey;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let jwekey = &state.kms_secrets;
let request = payment_methods::mk_delete_card_request_hs(
diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rs
index 304091e42a..12bb5981b1 100644
--- a/crates/router/src/core/payment_methods/transformers.rs
+++ b/crates/router/src/core/payment_methods/transformers.rs
@@ -186,14 +186,14 @@ pub fn get_dotted_jws(jws: encryption::JwsBody) -> String {
}
pub async fn get_decrypted_response_payload(
- #[cfg(not(feature = "kms"))] jwekey: &settings::Jwekey,
- #[cfg(feature = "kms")] jwekey: &settings::ActiveKmsSecrets,
+ #[cfg(not(feature = "aws_kms"))] jwekey: &settings::Jwekey,
+ #[cfg(feature = "aws_kms")] jwekey: &settings::ActiveKmsSecrets,
jwe_body: encryption::JweBody,
locker_choice: Option<api_enums::LockerChoice>,
) -> CustomResult<String, errors::VaultError> {
let target_locker = locker_choice.unwrap_or(api_enums::LockerChoice::Basilisk);
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let public_key = match target_locker {
api_enums::LockerChoice::Basilisk => jwekey.jwekey.peek().vault_encryption_key.as_bytes(),
api_enums::LockerChoice::Tartarus => {
@@ -201,16 +201,16 @@ pub async fn get_decrypted_response_payload(
}
};
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let private_key = jwekey.jwekey.peek().vault_private_key.as_bytes();
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let public_key = match target_locker {
api_enums::LockerChoice::Basilisk => jwekey.vault_encryption_key.as_bytes(),
api_enums::LockerChoice::Tartarus => jwekey.rust_locker_encryption_key.as_bytes(),
};
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let private_key = jwekey.vault_private_key.as_bytes();
let jwt = get_dotted_jwe(jwe_body);
@@ -237,8 +237,8 @@ pub async fn get_decrypted_response_payload(
}
pub async fn mk_basilisk_req(
- #[cfg(feature = "kms")] jwekey: &settings::ActiveKmsSecrets,
- #[cfg(not(feature = "kms"))] jwekey: &settings::Jwekey,
+ #[cfg(feature = "aws_kms")] jwekey: &settings::ActiveKmsSecrets,
+ #[cfg(not(feature = "aws_kms"))] jwekey: &settings::Jwekey,
jws: &str,
locker_choice: api_enums::LockerChoice,
) -> CustomResult<encryption::JweBody, errors::VaultError> {
@@ -257,7 +257,7 @@ pub async fn mk_basilisk_req(
let payload = utils::Encode::<encryption::JwsBody>::encode_to_vec(&jws_body)
.change_context(errors::VaultError::SaveCardFailed)?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let public_key = match locker_choice {
api_enums::LockerChoice::Basilisk => jwekey.jwekey.peek().vault_encryption_key.as_bytes(),
api_enums::LockerChoice::Tartarus => {
@@ -265,7 +265,7 @@ pub async fn mk_basilisk_req(
}
};
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let public_key = match locker_choice {
api_enums::LockerChoice::Basilisk => jwekey.vault_encryption_key.as_bytes(),
api_enums::LockerChoice::Tartarus => jwekey.rust_locker_encryption_key.as_bytes(),
@@ -293,8 +293,8 @@ pub async fn mk_basilisk_req(
}
pub async fn mk_add_locker_request_hs<'a>(
- #[cfg(not(feature = "kms"))] jwekey: &settings::Jwekey,
- #[cfg(feature = "kms")] jwekey: &settings::ActiveKmsSecrets,
+ #[cfg(not(feature = "aws_kms"))] jwekey: &settings::Jwekey,
+ #[cfg(feature = "aws_kms")] jwekey: &settings::ActiveKmsSecrets,
locker: &settings::Locker,
payload: &StoreLockerReq<'a>,
locker_choice: api_enums::LockerChoice,
@@ -302,10 +302,10 @@ pub async fn mk_add_locker_request_hs<'a>(
let payload = utils::Encode::<StoreCardReq<'_>>::encode_to_vec(&payload)
.change_context(errors::VaultError::RequestEncodingFailed)?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let private_key = jwekey.jwekey.peek().vault_private_key.as_bytes();
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let private_key = jwekey.vault_private_key.as_bytes();
let jws = encryption::jws_sign_payload(&payload, &locker.locker_signing_key_id, private_key)
@@ -463,8 +463,8 @@ pub fn mk_add_card_request(
}
pub async fn mk_get_card_request_hs(
- #[cfg(not(feature = "kms"))] jwekey: &settings::Jwekey,
- #[cfg(feature = "kms")] jwekey: &settings::ActiveKmsSecrets,
+ #[cfg(not(feature = "aws_kms"))] jwekey: &settings::Jwekey,
+ #[cfg(feature = "aws_kms")] jwekey: &settings::ActiveKmsSecrets,
locker: &settings::Locker,
customer_id: &str,
merchant_id: &str,
@@ -480,10 +480,10 @@ pub async fn mk_get_card_request_hs(
let payload = utils::Encode::<CardReqBody<'_>>::encode_to_vec(&card_req_body)
.change_context(errors::VaultError::RequestEncodingFailed)?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let private_key = jwekey.jwekey.peek().vault_private_key.as_bytes();
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let private_key = jwekey.vault_private_key.as_bytes();
let jws = encryption::jws_sign_payload(&payload, &locker.locker_signing_key_id, private_key)
@@ -540,8 +540,8 @@ pub fn mk_get_card_response(card: GetCardResponse) -> errors::RouterResult<Card>
}
pub async fn mk_delete_card_request_hs(
- #[cfg(feature = "kms")] jwekey: &settings::ActiveKmsSecrets,
- #[cfg(not(feature = "kms"))] jwekey: &settings::Jwekey,
+ #[cfg(feature = "aws_kms")] jwekey: &settings::ActiveKmsSecrets,
+ #[cfg(not(feature = "aws_kms"))] jwekey: &settings::Jwekey,
locker: &settings::Locker,
customer_id: &str,
merchant_id: &str,
@@ -556,10 +556,10 @@ pub async fn mk_delete_card_request_hs(
let payload = utils::Encode::<CardReqBody<'_>>::encode_to_vec(&card_req_body)
.change_context(errors::VaultError::RequestEncodingFailed)?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let private_key = jwekey.jwekey.peek().vault_private_key.as_bytes();
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let private_key = jwekey.vault_private_key.as_bytes();
let jws = encryption::jws_sign_payload(&payload, &locker.locker_signing_key_id, private_key)
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index 099c266e04..062c58e056 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -2,12 +2,12 @@ use api_models::payments as payment_types;
use async_trait::async_trait;
use common_utils::{ext_traits::ByteSliceExt, request::RequestContent};
use error_stack::{IntoReport, Report, ResultExt};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::decrypt::VaultFetch;
-#[cfg(feature = "kms")]
-use external_services::kms;
#[cfg(feature = "hashicorp-vault")]
use masking::ExposeInterface;
@@ -258,17 +258,18 @@ async fn create_applepay_session_token(
}
.await?;
- #[cfg(feature = "kms")]
- let decrypted_apple_pay_merchant_cert = kms::get_kms_client(&state.conf.kms)
- .await
- .decrypt(apple_pay_merchant_cert)
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Apple pay merchant certificate decryption failed")?;
+ #[cfg(feature = "aws_kms")]
+ let decrypted_apple_pay_merchant_cert =
+ aws_kms::get_aws_kms_client(&state.conf.kms)
+ .await
+ .decrypt(apple_pay_merchant_cert)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Apple pay merchant certificate decryption failed")?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let decrypted_apple_pay_merchant_cert_key =
- kms::get_kms_client(&state.conf.kms)
+ aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(apple_pay_merchant_cert_key)
.await
@@ -277,15 +278,16 @@ async fn create_applepay_session_token(
"Apple pay merchant certificate key decryption failed",
)?;
- #[cfg(feature = "kms")]
- let decrypted_merchant_identifier = kms::get_kms_client(&state.conf.kms)
- .await
- .decrypt(common_merchant_identifier)
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Apple pay merchant identifier decryption failed")?;
+ #[cfg(feature = "aws_kms")]
+ let decrypted_merchant_identifier =
+ aws_kms::get_aws_kms_client(&state.conf.kms)
+ .await
+ .decrypt(common_merchant_identifier)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Apple pay merchant identifier decryption failed")?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let decrypted_merchant_identifier = common_merchant_identifier;
let apple_pay_session_request = get_session_request_for_simplified_apple_pay(
@@ -293,10 +295,10 @@ async fn create_applepay_session_token(
session_token_data,
);
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let decrypted_apple_pay_merchant_cert = apple_pay_merchant_cert;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let decrypted_apple_pay_merchant_cert_key = apple_pay_merchant_cert_key;
(
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index fe4a7757ec..5d801063e6 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -13,12 +13,12 @@ use data_models::{
use diesel_models::enums;
// TODO : Evaluate all the helper functions ()
use error_stack::{report, IntoReport, ResultExt};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::decrypt::VaultFetch;
-#[cfg(feature = "kms")]
-use external_services::kms;
use josekit::jwe;
use masking::{ExposeInterface, PeekInterface};
use openssl::{
@@ -2888,7 +2888,7 @@ pub async fn get_merchant_connector_account(
},
)?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let private_key = state
.kms_secrets
.jwekey
@@ -2896,7 +2896,7 @@ pub async fn get_merchant_connector_account(
.tunnel_private_key
.as_bytes();
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let private_key = state.conf.jwekey.tunnel_private_key.as_bytes();
let decrypted_mca = services::decrypt_jwe(mca_config.config.as_str(), services::KeyIdCheck::SkipKeyIdCheck, private_key, jwe::RSA_OAEP_256)
@@ -3556,14 +3556,14 @@ impl ApplePayData {
}
.await?;
- #[cfg(feature = "kms")]
- let cert_data = kms::get_kms_client(&state.conf.kms)
+ #[cfg(feature = "aws_kms")]
+ let cert_data = aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(&apple_pay_ppc)
.await
.change_context(errors::ApplePayDecryptionError::DecryptionFailed)?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let cert_data = &apple_pay_ppc;
let base64_decode_cert_data = BASE64_ENGINE
@@ -3640,14 +3640,14 @@ impl ApplePayData {
}
.await?;
- #[cfg(feature = "kms")]
- let decrypted_apple_pay_ppc_key = kms::get_kms_client(&state.conf.kms)
+ #[cfg(feature = "aws_kms")]
+ let decrypted_apple_pay_ppc_key = aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(&apple_pay_ppc_key)
.await
.change_context(errors::ApplePayDecryptionError::DecryptionFailed)?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let decrypted_apple_pay_ppc_key = &apple_pay_ppc_key;
// Create PKey objects from EcKey
let private_key = PKey::private_key_from_pem(decrypted_apple_pay_ppc_key.as_bytes())
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 151078a605..486a60f7bc 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -7,8 +7,8 @@ use common_utils::{
ext_traits::{AsyncExt, Encode},
};
use error_stack::{report, IntoReport, ResultExt};
-#[cfg(feature = "kms")]
-use external_services::kms;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
use futures::FutureExt;
use router_derive::PaymentOperation;
use router_env::{instrument, logger, tracing};
@@ -869,8 +869,8 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>
}
if let Some(encoded_hash) = card_number_fingerprint {
- #[cfg(feature = "kms")]
- let encrypted_fingerprint = kms::get_kms_client(&state.conf.kms)
+ #[cfg(feature = "aws_kms")]
+ let encrypted_fingerprint = aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.encrypt(encoded_hash)
.await
@@ -882,7 +882,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>
Some,
);
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let encrypted_fingerprint = Some(encoded_hash);
if let Some(encrypted_fingerprint) = encrypted_fingerprint {
diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rs
index 9f70cc6bae..f77d512081 100644
--- a/crates/router/src/core/pm_auth.rs
+++ b/crates/router/src/core/pm_auth.rs
@@ -19,8 +19,8 @@ use common_utils::{
};
use data_models::payments::PaymentIntent;
use error_stack::{IntoReport, ResultExt};
-#[cfg(feature = "kms")]
-pub use external_services::kms;
+#[cfg(feature = "aws_kms")]
+pub use external_services::aws_kms;
use helpers::PaymentAuthConnectorDataExt;
use masking::{ExposeInterface, PeekInterface};
use pm_auth::{
@@ -368,8 +368,8 @@ async fn store_bank_details_in_payment_methods(
}
.await?;
- #[cfg(feature = "kms")]
- let pm_auth_key = kms::get_kms_client(&state.conf.kms)
+ #[cfg(feature = "aws_kms")]
+ let pm_auth_key = aws_kms::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(pm_auth_key)
.await
diff --git a/crates/router/src/core/verification.rs b/crates/router/src/core/verification.rs
index bac47b34dc..0ed70e6e0c 100644
--- a/crates/router/src/core/verification.rs
+++ b/crates/router/src/core/verification.rs
@@ -2,8 +2,8 @@ pub mod utils;
use api_models::verifications::{self, ApplepayMerchantResponse};
use common_utils::{errors::CustomResult, request::RequestContent};
use error_stack::ResultExt;
-#[cfg(feature = "kms")]
-use external_services::kms;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
use crate::{core::errors::api_error_response, headers, logger, routes::AppState, services};
@@ -13,7 +13,7 @@ pub async fn verify_merchant_creds_for_applepay(
state: AppState,
_req: &actix_web::HttpRequest,
body: verifications::ApplepayMerchantVerificationRequest,
- kms_config: &kms::KmsConfig,
+ kms_config: &aws_kms::AwsKmsConfig,
merchant_id: String,
) -> CustomResult<
services::ApplicationResponse<ApplepayMerchantResponse>,
@@ -27,19 +27,19 @@ pub async fn verify_merchant_creds_for_applepay(
let encrypted_key = &state.conf.applepay_merchant_configs.merchant_cert_key;
let applepay_endpoint = &state.conf.applepay_merchant_configs.applepay_endpoint;
- let applepay_internal_merchant_identifier = kms::get_kms_client(kms_config)
+ let applepay_internal_merchant_identifier = aws_kms::get_aws_kms_client(kms_config)
.await
.decrypt(encrypted_merchant_identifier)
.await
.change_context(api_error_response::ApiErrorResponse::InternalServerError)?;
- let cert_data = kms::get_kms_client(kms_config)
+ let cert_data = aws_kms::get_aws_kms_client(kms_config)
.await
.decrypt(encrypted_cert)
.await
.change_context(api_error_response::ApiErrorResponse::InternalServerError)?;
- let key_data = kms::get_kms_client(kms_config)
+ let key_data = aws_kms::get_aws_kms_client(kms_config)
.await
.decrypt(encrypted_key)
.await
diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs
index bb56a173da..1c80aff439 100644
--- a/crates/router/src/lib.rs
+++ b/crates/router/src/lib.rs
@@ -142,7 +142,7 @@ pub fn mk_app(
.service(routes::ConnectorOnboarding::server(state.clone()))
}
- #[cfg(all(feature = "olap", feature = "kms"))]
+ #[cfg(all(feature = "olap", feature = "aws_kms"))]
{
server_app = server_app.service(routes::Verify::server(state.clone()));
}
diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs
index d9916f98e7..e058d4f1c1 100644
--- a/crates/router/src/routes.rs
+++ b/crates/router/src/routes.rs
@@ -37,7 +37,7 @@ pub mod routing;
pub mod user;
#[cfg(feature = "olap")]
pub mod user_role;
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
@@ -57,7 +57,7 @@ pub use self::app::Forex;
pub use self::app::Payouts;
#[cfg(all(feature = "olap", feature = "recon"))]
pub use self::app::Recon;
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
pub use self::app::Verify;
pub use self::app::{
ApiKeys, AppState, BusinessProfile, Cache, Cards, Configs, ConnectorOnboarding, Customers,
diff --git a/crates/router/src/routes/api_keys.rs b/crates/router/src/routes/api_keys.rs
index fb1851af00..cf859d048d 100644
--- a/crates/router/src/routes/api_keys.rs
+++ b/crates/router/src/routes/api_keys.rs
@@ -44,8 +44,9 @@ pub async fn api_key_create(
&req,
payload,
|state, _, payload| async {
- #[cfg(feature = "kms")]
- let kms_client = external_services::kms::get_kms_client(&state.clone().conf.kms).await;
+ #[cfg(feature = "aws_kms")]
+ let aws_kms_client =
+ external_services::aws_kms::get_aws_kms_client(&state.clone().conf.kms).await;
#[cfg(feature = "hashicorp-vault")]
let hc_client = external_services::hashicorp_vault::get_hashicorp_client(
@@ -56,8 +57,8 @@ pub async fn api_key_create(
api_keys::create_api_key(
state,
- #[cfg(feature = "kms")]
- kms_client,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_client,
#[cfg(feature = "hashicorp-vault")]
hc_client,
payload,
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index c130da8dbb..f71592c544 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -1,16 +1,19 @@
use std::sync::Arc;
use actix_web::{web, Scope};
-#[cfg(all(feature = "olap", any(feature = "hashicorp-vault", feature = "kms")))]
+#[cfg(all(
+ feature = "olap",
+ any(feature = "hashicorp-vault", feature = "aws_kms")
+))]
use analytics::AnalyticsConfig;
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms::{self, decrypt::AwsKmsDecrypt};
#[cfg(feature = "email")]
use external_services::email::{ses::AwsSes, EmailService};
use external_services::file_storage::FileStorageInterface;
#[cfg(all(feature = "olap", feature = "hashicorp-vault"))]
use external_services::hashicorp_vault::decrypt::VaultFetch;
-#[cfg(feature = "kms")]
-use external_services::kms::{self, decrypt::KmsDecrypt};
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
use masking::PeekInterface;
use router_env::tracing_actix_web::RequestId;
use scheduler::SchedulerInterface;
@@ -29,7 +32,7 @@ use super::payouts::*;
use super::pm_auth;
#[cfg(feature = "olap")]
use super::routing as cloud_routing;
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_verified_domains};
#[cfg(feature = "olap")]
use super::{
@@ -63,7 +66,7 @@ pub struct AppState {
pub event_handler: EventsHandler,
#[cfg(feature = "email")]
pub email_client: Arc<dyn EmailService>,
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
pub kms_secrets: Arc<settings::ActiveKmsSecrets>,
pub api_client: Box<dyn crate::services::ApiClient>,
#[cfg(feature = "olap")]
@@ -141,15 +144,15 @@ impl AppState {
///
/// Panics if Store can't be created or JWE decryption fails
pub async fn with_storage(
- #[cfg_attr(not(all(feature = "olap", feature = "kms")), allow(unused_mut))]
+ #[cfg_attr(not(all(feature = "olap", feature = "aws_kms")), allow(unused_mut))]
mut conf: settings::Settings,
storage_impl: StorageImpl,
shut_down_signal: oneshot::Sender<()>,
api_client: Box<dyn crate::services::ApiClient>,
) -> Self {
Box::pin(async move {
- #[cfg(feature = "kms")]
- let kms_client = kms::get_kms_client(&conf.kms).await;
+ #[cfg(feature = "aws_kms")]
+ let aws_kms_client = aws_kms::get_aws_kms_client(&conf.kms).await;
#[cfg(all(feature = "hashicorp-vault", feature = "olap"))]
#[allow(clippy::expect_used)]
let hc_client =
@@ -207,14 +210,14 @@ impl AppState {
}
};
- #[cfg(all(feature = "kms", feature = "olap"))]
+ #[cfg(all(feature = "aws_kms", feature = "olap"))]
#[allow(clippy::expect_used)]
match conf.analytics {
AnalyticsConfig::Clickhouse { .. } => {}
AnalyticsConfig::Sqlx { ref mut sqlx }
| AnalyticsConfig::CombinedCkh { ref mut sqlx, .. }
| AnalyticsConfig::CombinedSqlx { ref mut sqlx, .. } => {
- sqlx.password = kms_client
+ sqlx.password = aws_kms_client
.decrypt(&sqlx.password.peek())
.await
.expect("Failed to decrypt password")
@@ -232,12 +235,12 @@ impl AppState {
.expect("Failed to decrypt connector onboarding credentials");
}
- #[cfg(all(feature = "kms", feature = "olap"))]
+ #[cfg(all(feature = "aws_kms", feature = "olap"))]
#[allow(clippy::expect_used)]
{
conf.connector_onboarding = conf
.connector_onboarding
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.expect("Failed to decrypt connector onboarding credentials");
}
@@ -256,14 +259,14 @@ impl AppState {
.expect("Failed to decrypt connector onboarding credentials");
}
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
#[allow(clippy::expect_used)]
let kms_secrets = settings::ActiveKmsSecrets {
jwekey: conf.jwekey.clone().into(),
}
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
- .expect("Failed while performing KMS decryption");
+ .expect("Failed while performing AWS KMS decryption");
#[cfg(feature = "email")]
let email_client = Arc::new(create_email_client(&conf).await);
@@ -276,7 +279,7 @@ impl AppState {
conf: Arc::new(conf),
#[cfg(feature = "email")]
email_client,
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
kms_secrets: Arc::new(kms_secrets),
api_client,
event_handler,
@@ -934,10 +937,10 @@ impl Gsm {
}
}
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
pub struct Verify;
-#[cfg(all(feature = "olap", feature = "kms"))]
+#[cfg(all(feature = "olap", feature = "aws_kms"))]
impl Verify {
pub fn server(state: AppState) -> Scope {
web::scope("/verify")
diff --git a/crates/router/src/routes/metrics.rs b/crates/router/src/routes/metrics.rs
index 6c3293dba9..c4d0420a9b 100644
--- a/crates/router/src/routes/metrics.rs
+++ b/crates/router/src/routes/metrics.rs
@@ -5,9 +5,9 @@ global_meter!(GLOBAL_METER, "ROUTER_API");
counter_metric!(HEALTH_METRIC, GLOBAL_METER); // No. of health API hits
counter_metric!(KV_MISS, GLOBAL_METER); // No. of KV misses
-#[cfg(feature = "kms")]
+#[cfg(feature = "aws_kms")]
counter_metric!(AWS_KMS_ENCRYPTION_FAILURES, GLOBAL_METER); // No. of AWS KMS Encryption failures
-#[cfg(feature = "kms")]
+#[cfg(feature = "aws_kms")]
counter_metric!(AWS_KMS_DECRYPTION_FAILURES, GLOBAL_METER); // No. of AWS KMS Decryption failures
// API Level Metrics
diff --git a/crates/router/src/services.rs b/crates/router/src/services.rs
index c0ed2b442d..220fde4631 100644
--- a/crates/router/src/services.rs
+++ b/crates/router/src/services.rs
@@ -13,14 +13,14 @@ pub mod recon;
#[cfg(feature = "email")]
pub mod email;
-#[cfg(any(feature = "kms", feature = "hashicorp-vault"))]
+#[cfg(any(feature = "aws_kms", feature = "hashicorp-vault"))]
use data_models::errors::StorageError;
use data_models::errors::StorageResult;
use error_stack::{IntoReport, ResultExt};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms::{self, decrypt::AwsKmsDecrypt};
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::decrypt::VaultFetch;
-#[cfg(feature = "kms")]
-use external_services::kms::{self, decrypt::KmsDecrypt};
use masking::{PeekInterface, StrongSecret};
#[cfg(feature = "kv_store")]
use storage_impl::KVRouterStore;
@@ -45,8 +45,8 @@ pub async fn get_store(
shut_down_signal: oneshot::Sender<()>,
test_transaction: bool,
) -> StorageResult<Store> {
- #[cfg(feature = "kms")]
- let kms_client = kms::get_kms_client(&config.kms).await;
+ #[cfg(feature = "aws_kms")]
+ let aws_kms_client = aws_kms::get_aws_kms_client(&config.kms).await;
#[cfg(feature = "hashicorp-vault")]
let hc_client = external_services::hashicorp_vault::get_hashicorp_client(&config.hc_vault)
@@ -62,9 +62,9 @@ pub async fn get_store(
.change_context(StorageError::InitializationError)
.attach_printable("Failed to fetch data from hashicorp vault")?;
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let master_config = master_config
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.change_context(StorageError::InitializationError)
.attach_printable("Failed to decrypt master database config")?;
@@ -79,17 +79,17 @@ pub async fn get_store(
.change_context(StorageError::InitializationError)
.attach_printable("Failed to fetch data from hashicorp vault")?;
- #[cfg(all(feature = "olap", feature = "kms"))]
+ #[cfg(all(feature = "olap", feature = "aws_kms"))]
let replica_config = replica_config
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.change_context(StorageError::InitializationError)
.attach_printable("Failed to decrypt replica database config")?;
let master_enc_key = get_master_enc_key(
config,
- #[cfg(feature = "kms")]
- kms_client,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_client,
#[cfg(feature = "hashicorp-vault")]
hc_client,
)
@@ -128,7 +128,7 @@ pub async fn get_store(
#[allow(clippy::expect_used)]
async fn get_master_enc_key(
conf: &crate::configs::settings::Settings,
- #[cfg(feature = "kms")] kms_client: &kms::KmsClient,
+ #[cfg(feature = "aws_kms")] aws_kms_client: &aws_kms::AwsKmsClient,
#[cfg(feature = "hashicorp-vault")]
hc_client: &external_services::hashicorp_vault::HashiCorpVault,
) -> StrongSecret<Vec<u8>> {
@@ -140,10 +140,10 @@ async fn get_master_enc_key(
.await
.expect("Failed to fetch master enc key");
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let master_enc_key = masking::Secret::<_, masking::WithType>::new(
master_enc_key
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.expect("Failed to decrypt master enc key"),
);
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 221106612f..308ceb2672 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -3,10 +3,10 @@ use api_models::{payment_methods::PaymentMethodListRequest, payments};
use async_trait::async_trait;
use common_utils::date_time;
use error_stack::{report, IntoReport, ResultExt};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms::{self, decrypt::AwsKmsDecrypt};
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::decrypt::VaultFetch;
-#[cfg(feature = "kms")]
-use external_services::kms::{self, decrypt::KmsDecrypt};
use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation};
#[cfg(feature = "hashicorp-vault")]
use masking::ExposeInterface;
@@ -225,8 +225,8 @@ where
let config = state.conf();
api_keys::get_hash_key(
&config.api_keys,
- #[cfg(feature = "kms")]
- kms::get_kms_client(&config.kms).await,
+ #[cfg(feature = "aws_kms")]
+ aws_kms::get_aws_kms_client(&config.kms).await,
#[cfg(feature = "hashicorp-vault")]
external_services::hashicorp_vault::get_hashicorp_client(&config.hc_vault)
.await
@@ -289,22 +289,22 @@ static ADMIN_API_KEY: tokio::sync::OnceCell<StrongSecret<String>> =
pub async fn get_admin_api_key(
secrets: &settings::Secrets,
- #[cfg(feature = "kms")] kms_client: &kms::KmsClient,
+ #[cfg(feature = "aws_kms")] aws_kms_client: &aws_kms::AwsKmsClient,
#[cfg(feature = "hashicorp-vault")]
hc_client: &external_services::hashicorp_vault::HashiCorpVault,
) -> RouterResult<&'static StrongSecret<String>> {
ADMIN_API_KEY
.get_or_try_init(|| async {
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let admin_api_key = secrets.admin_api_key.clone();
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let admin_api_key = secrets
.kms_encrypted_admin_api_key
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to KMS decrypt admin API key")?;
+ .attach_printable("Failed to AWS KMS decrypt admin API key")?;
#[cfg(feature = "hashicorp-vault")]
let admin_api_key = masking::Secret::new(admin_api_key)
@@ -368,8 +368,8 @@ where
let admin_api_key = get_admin_api_key(
&conf.secrets,
- #[cfg(feature = "kms")]
- kms::get_kms_client(&conf.kms).await,
+ #[cfg(feature = "aws_kms")]
+ aws_kms::get_aws_kms_client(&conf.kms).await,
#[cfg(feature = "hashicorp-vault")]
external_services::hashicorp_vault::get_hashicorp_client(&conf.hc_vault)
.await
@@ -873,19 +873,19 @@ static JWT_SECRET: tokio::sync::OnceCell<StrongSecret<String>> = tokio::sync::On
pub async fn get_jwt_secret(
secrets: &settings::Secrets,
- #[cfg(feature = "kms")] kms_client: &kms::KmsClient,
+ #[cfg(feature = "aws_kms")] aws_kms_client: &aws_kms::AwsKmsClient,
) -> RouterResult<&'static StrongSecret<String>> {
JWT_SECRET
.get_or_try_init(|| async {
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let jwt_secret = secrets
.kms_encrypted_jwt_secret
- .decrypt_inner(kms_client)
+ .decrypt_inner(aws_kms_client)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to KMS decrypt JWT secret")?;
+ .attach_printable("Failed to AWS KMS decrypt JWT secret")?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let jwt_secret = secrets.jwt_secret.clone();
Ok(StrongSecret::new(jwt_secret))
@@ -900,8 +900,8 @@ where
let conf = state.conf();
let secret = get_jwt_secret(
&conf.secrets,
- #[cfg(feature = "kms")]
- kms::get_kms_client(&conf.kms).await,
+ #[cfg(feature = "aws_kms")]
+ aws_kms::get_aws_kms_client(&conf.kms).await,
)
.await?
.peek()
@@ -972,11 +972,11 @@ static RECON_API_KEY: tokio::sync::OnceCell<StrongSecret<String>> =
#[cfg(feature = "recon")]
pub async fn get_recon_admin_api_key(
secrets: &settings::Secrets,
- #[cfg(feature = "kms")] kms_client: &kms::KmsClient,
+ #[cfg(feature = "aws_kms")] kms_client: &aws_kms::AwsKmsClient,
) -> RouterResult<&'static StrongSecret<String>> {
RECON_API_KEY
.get_or_try_init(|| async {
- #[cfg(feature = "kms")]
+ #[cfg(feature = "aws_kms")]
let recon_admin_api_key = secrets
.kms_encrypted_recon_admin_api_key
.decrypt_inner(kms_client)
@@ -984,7 +984,7 @@ pub async fn get_recon_admin_api_key(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to KMS decrypt recon admin API key")?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let recon_admin_api_key = secrets.recon_admin_api_key.clone();
Ok(StrongSecret::new(recon_admin_api_key))
@@ -1012,8 +1012,8 @@ where
let admin_api_key = get_recon_admin_api_key(
&conf.secrets,
- #[cfg(feature = "kms")]
- kms::get_kms_client(&conf.kms).await,
+ #[cfg(feature = "aws_kms")]
+ aws_kms::get_aws_kms_client(&conf.kms).await,
)
.await?;
diff --git a/crates/router/src/services/jwt.rs b/crates/router/src/services/jwt.rs
index b69a215839..08db52e402 100644
--- a/crates/router/src/services/jwt.rs
+++ b/crates/router/src/services/jwt.rs
@@ -26,8 +26,8 @@ where
{
let jwt_secret = authentication::get_jwt_secret(
&settings.secrets,
- #[cfg(feature = "kms")]
- external_services::kms::get_kms_client(&settings.kms).await,
+ #[cfg(feature = "aws_kms")]
+ external_services::aws_kms::get_aws_kms_client(&settings.kms).await,
)
.await
.change_context(UserErrors::InternalServerError)
diff --git a/crates/router/src/utils/currency.rs b/crates/router/src/utils/currency.rs
index a01f2520b6..057805a76f 100644
--- a/crates/router/src/utils/currency.rs
+++ b/crates/router/src/utils/currency.rs
@@ -4,10 +4,10 @@ use api_models::enums;
use common_utils::{date_time, errors::CustomResult, events::ApiEventMetric, ext_traits::AsyncExt};
use currency_conversion::types::{CurrencyFactors, ExchangeRates};
use error_stack::{IntoReport, ResultExt};
+#[cfg(feature = "aws_kms")]
+use external_services::aws_kms;
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::{self, decrypt::VaultFetch};
-#[cfg(feature = "kms")]
-use external_services::kms;
use masking::PeekInterface;
use once_cell::sync::Lazy;
use redis_interface::DelReply;
@@ -65,8 +65,8 @@ pub enum ForexCacheError {
LocalWriteError,
#[error("Json Parsing error")]
ParsingError,
- #[error("Kms decryption error")]
- KmsDecryptionFailed,
+ #[error("Aws Kms decryption error")]
+ AwsKmsDecryptionFailed,
#[error("Error connecting to redis")]
RedisConnectionError,
#[error("Not able to release write lock")]
@@ -128,7 +128,7 @@ async fn waited_fetch_and_update_caches(
state: &AppState,
local_fetch_retry_delay: u64,
local_fetch_retry_count: u64,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -151,8 +151,8 @@ async fn waited_fetch_and_update_caches(
successive_fetch_and_save_forex(
state,
None,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -192,7 +192,7 @@ pub async fn get_forex_rates(
call_delay: i64,
local_fetch_retry_delay: u64,
local_fetch_retry_count: u64,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -203,8 +203,8 @@ pub async fn get_forex_rates(
state,
call_delay,
local_rates,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -220,8 +220,8 @@ pub async fn get_forex_rates(
call_delay,
local_fetch_retry_delay,
local_fetch_retry_count,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -234,7 +234,7 @@ async fn handler_local_no_data(
call_delay: i64,
_local_fetch_retry_delay: u64,
_local_fetch_retry_count: u64,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -244,8 +244,8 @@ async fn handler_local_no_data(
state,
data,
call_delay,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -256,8 +256,8 @@ async fn handler_local_no_data(
Ok(successive_fetch_and_save_forex(
state,
None,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -268,8 +268,8 @@ async fn handler_local_no_data(
Ok(successive_fetch_and_save_forex(
state,
None,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -281,7 +281,7 @@ async fn handler_local_no_data(
async fn successive_fetch_and_save_forex(
state: &AppState,
stale_redis_data: Option<FxExchangeRatesCacheEntry>,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -292,8 +292,8 @@ async fn successive_fetch_and_save_forex(
}
let api_rates = fetch_forex_rates(
state,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -305,8 +305,8 @@ async fn successive_fetch_and_save_forex(
logger::error!(?err);
let secondary_api_rates = fallback_fetch_forex_rates(
state,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -351,7 +351,7 @@ async fn fallback_forex_redis_check(
state: &AppState,
redis_data: FxExchangeRatesCacheEntry,
call_delay: i64,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -367,8 +367,8 @@ async fn fallback_forex_redis_check(
successive_fetch_and_save_forex(
state,
Some(redis_data),
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -381,7 +381,7 @@ async fn handler_local_expired(
state: &AppState,
call_delay: i64,
local_rates: FxExchangeRatesCacheEntry,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -400,8 +400,8 @@ async fn handler_local_expired(
successive_fetch_and_save_forex(
state,
Some(local_rates),
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -415,8 +415,8 @@ async fn handler_local_expired(
successive_fetch_and_save_forex(
state,
Some(local_rates),
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
@@ -427,7 +427,7 @@ async fn handler_local_expired(
async fn fetch_forex_rates(
state: &AppState,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
@@ -436,7 +436,7 @@ async fn fetch_forex_rates(
#[cfg(feature = "hashicorp-vault")]
let client = hashicorp_vault::get_hashicorp_client(hc_config)
.await
- .change_context(ForexCacheError::KmsDecryptionFailed)?;
+ .change_context(ForexCacheError::AwsKmsDecryptionFailed)?;
#[cfg(not(feature = "hashicorp-vault"))]
let output = state.conf.forex_api.api_key.clone();
@@ -448,19 +448,19 @@ async fn fetch_forex_rates(
.clone()
.fetch_inner::<hashicorp_vault::Kv2>(client)
.await
- .change_context(ForexCacheError::KmsDecryptionFailed)?;
+ .change_context(ForexCacheError::AwsKmsDecryptionFailed)?;
Ok::<_, error_stack::Report<ForexCacheError>>(output)
}
.await?;
- #[cfg(feature = "kms")]
- let forex_api_key = kms::get_kms_client(kms_config)
+ #[cfg(feature = "aws_kms")]
+ let forex_api_key = aws_kms::get_aws_kms_client(aws_kms_config)
.await
.decrypt(forex_api_key.peek())
.await
- .change_context(ForexCacheError::KmsDecryptionFailed)?;
+ .change_context(ForexCacheError::AwsKmsDecryptionFailed)?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let forex_api_key = forex_api_key.peek();
let forex_url: String = format!("{}{}{}", FOREX_BASE_URL, forex_api_key, FOREX_BASE_CURRENCY);
@@ -516,7 +516,7 @@ async fn fetch_forex_rates(
pub async fn fallback_fetch_forex_rates(
state: &AppState,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<FxExchangeRatesCacheEntry, ForexCacheError> {
@@ -524,7 +524,7 @@ pub async fn fallback_fetch_forex_rates(
#[cfg(feature = "hashicorp-vault")]
let client = hashicorp_vault::get_hashicorp_client(hc_config)
.await
- .change_context(ForexCacheError::KmsDecryptionFailed)?;
+ .change_context(ForexCacheError::AwsKmsDecryptionFailed)?;
#[cfg(not(feature = "hashicorp-vault"))]
let output = state.conf.forex_api.fallback_api_key.clone();
@@ -536,19 +536,19 @@ pub async fn fallback_fetch_forex_rates(
.clone()
.fetch_inner::<hashicorp_vault::Kv2>(client)
.await
- .change_context(ForexCacheError::KmsDecryptionFailed)?;
+ .change_context(ForexCacheError::AwsKmsDecryptionFailed)?;
Ok::<_, error_stack::Report<ForexCacheError>>(output)
}
.await?;
- #[cfg(feature = "kms")]
- let fallback_forex_api_key = kms::get_kms_client(kms_config)
+ #[cfg(feature = "aws_kms")]
+ let fallback_forex_api_key = aws_kms::get_aws_kms_client(aws_kms_config)
.await
.decrypt(fallback_api_key.peek())
.await
- .change_context(ForexCacheError::KmsDecryptionFailed)?;
+ .change_context(ForexCacheError::AwsKmsDecryptionFailed)?;
- #[cfg(not(feature = "kms"))]
+ #[cfg(not(feature = "aws_kms"))]
let fallback_forex_api_key = fallback_api_key.peek();
let fallback_forex_url: String =
@@ -691,7 +691,7 @@ pub async fn convert_currency(
amount: i64,
to_currency: String,
from_currency: String,
- #[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
+ #[cfg(feature = "aws_kms")] aws_kms_config: &aws_kms::AwsKmsConfig,
#[cfg(feature = "hashicorp-vault")]
hc_config: &external_services::hashicorp_vault::HashiCorpVaultConfig,
) -> CustomResult<api_models::currency::CurrencyConversionResponse, ForexCacheError> {
@@ -700,8 +700,8 @@ pub async fn convert_currency(
state.conf.forex_api.call_delay,
state.conf.forex_api.local_fetch_retry_delay,
state.conf.forex_api.local_fetch_retry_count,
- #[cfg(feature = "kms")]
- kms_config,
+ #[cfg(feature = "aws_kms")]
+ aws_kms_config,
#[cfg(feature = "hashicorp-vault")]
hc_config,
)
diff --git a/crates/scheduler/src/configs/settings.rs b/crates/scheduler/src/configs/settings.rs
index 723ef81e70..0135c9dcf4 100644
--- a/crates/scheduler/src/configs/settings.rs
+++ b/crates/scheduler/src/configs/settings.rs
@@ -1,11 +1,5 @@
-#[cfg(feature = "kms")]
-use external_services::kms;
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use serde::Deserialize;
-#[cfg(feature = "kms")]
-pub type Password = kms::KmsValue;
-#[cfg(not(feature = "kms"))]
-pub type Password = masking::Secret<String>;
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]