mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor(config): Add new type for kms encrypted values (#1823)
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
use bb8::PooledConnection;
|
||||
use diesel::PgConnection;
|
||||
#[cfg(feature = "kms")]
|
||||
use external_services::kms;
|
||||
use external_services::kms::{self, decrypt::KmsDecrypt};
|
||||
#[cfg(not(feature = "kms"))]
|
||||
use masking::PeekInterface;
|
||||
|
||||
use crate::settings::Database;
|
||||
|
||||
@ -20,17 +22,17 @@ pub async fn redis_connection(
|
||||
pub async fn diesel_make_pg_pool(
|
||||
database: &Database,
|
||||
_test_transaction: bool,
|
||||
#[cfg(feature = "kms")] kms_config: &kms::KmsConfig,
|
||||
#[cfg(feature = "kms")] kms_client: &'static kms::KmsClient,
|
||||
) -> PgPool {
|
||||
#[cfg(feature = "kms")]
|
||||
let password = kms::get_kms_client(kms_config)
|
||||
let password = database
|
||||
.password
|
||||
.decrypt_inner(kms_client)
|
||||
.await
|
||||
.decrypt(&database.kms_encrypted_password)
|
||||
.await
|
||||
.expect("Failed to KMS decrypt database password");
|
||||
.expect("Failed to decrypt password");
|
||||
|
||||
#[cfg(not(feature = "kms"))]
|
||||
let password = &database.password;
|
||||
let password = &database.password.peek();
|
||||
|
||||
let database_url = format!(
|
||||
"postgres://{}:{}@{}:{}/{}",
|
||||
|
||||
Reference in New Issue
Block a user