Skip to content

Commit

Permalink
fix: add create under a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dracarys18 committed Jul 8, 2024
1 parent 1a92dca commit 9a9e918
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion crates/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ license.workspace = true
default = ["kv_store", "stripe", "oltp", "olap", "backwards_compatibility", "accounts_cache", "dummy_connector", "payouts", "payout_retry", "business_profile_routing", "connector_choice_mca_id", "profile_specific_fallback_routing", "retry", "frm", "tls"]
tls = ["actix-web/rustls-0_22"]
email = ["external_services/email", "scheduler/email", "olap"]
keymanager_create = []
frm = ["api_models/frm", "hyperswitch_domain_models/frm"]
stripe = ["dep:serde_qs"]
release = ["stripe", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon", "external_services/aws_kms", "external_services/aws_s3"]
release = ["stripe", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon", "external_services/aws_kms", "external_services/aws_s3","keymanager_create"]
olap = ["hyperswitch_domain_models/olap", "storage_impl/olap", "scheduler/olap", "api_models/olap", "dep:analytics"]
oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]
Expand Down
21 changes: 12 additions & 9 deletions crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,18 @@ pub async fn create_merchant_account(
.payment_response_hash_key
.or(Some(generate_cryptographically_secure_random_string(64)));

encryption::create_key_in_key_manager(
&state,
domain::EncryptionCreateRequest {
identifier: domain::Identifier::Merchant(req.merchant_id.clone()),
},
)
.await
.change_context(errors::ApiErrorResponse::DuplicateMerchantAccount)
.attach_printable("Failed to insert key to KeyManager")?;
#[cfg(feature = "keymanager_create")]
{
encryption::create_key_in_key_manager(
&state,
domain::EncryptionCreateRequest {
identifier: domain::Identifier::Merchant(req.merchant_id.clone()),
},
)
.await
.change_context(errors::ApiErrorResponse::DuplicateMerchantAccount)
.attach_printable("Failed to insert key to KeyManager")?;
}

db.insert_merchant_key_store(key_store.clone(), &master_key.to_vec().into())
.await
Expand Down
19 changes: 11 additions & 8 deletions crates/router/src/types/domain/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,14 +927,17 @@ impl UserFromStorage {
created_at: common_utils::date_time::now(),
};

crate::encryption::create_key_in_key_manager(
state,
super::EncryptionCreateRequest {
identifier: super::Identifier::User(key_store.user_id.clone()),
},
)
.await
.change_context(UserErrors::InternalServerError)?;
#[cfg(feature = "keymanager_create")]
{
crate::encryption::create_key_in_key_manager(
state,
super::EncryptionCreateRequest {
identifier: super::Identifier::User(key_store.user_id.clone()),
},
)
.await
.change_context(UserErrors::InternalServerError)?;
}

state
.global_store
Expand Down

0 comments on commit 9a9e918

Please sign in to comment.