mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	refactor(config): Add new type for kms encrypted values (#1823)
This commit is contained in:
		| @ -4,6 +4,10 @@ use diesel::PgConnection; | ||||
| use error_stack::{IntoReport, ResultExt}; | ||||
| #[cfg(feature = "kms")] | ||||
| use external_services::kms; | ||||
| #[cfg(feature = "kms")] | ||||
| use external_services::kms::decrypt::KmsDecrypt; | ||||
| #[cfg(not(feature = "kms"))] | ||||
| use masking::PeekInterface; | ||||
|  | ||||
| use crate::{configs::settings::Database, errors}; | ||||
|  | ||||
| @ -41,17 +45,18 @@ 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: &kms::KmsClient, | ||||
| ) -> PgPool { | ||||
|     #[cfg(feature = "kms")] | ||||
|     let password = kms::get_kms_client(kms_config) | ||||
|         .await | ||||
|         .decrypt(&database.kms_encrypted_password) | ||||
|     let password = database | ||||
|         .password | ||||
|         .clone() | ||||
|         .decrypt_inner(kms_client) | ||||
|         .await | ||||
|         .expect("Failed to KMS decrypt database 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
	 Sampras Lopes
					Sampras Lopes