feat(injector): add support for new crate - injector for external vault proxy#8959
feat(injector): add support for new crate - injector for external vault proxy#8959bernard-eugine merged 88 commits intomainfrom
Conversation
Changed Files
|
…ch into addition_injector_crate
…ch into addition_injector_crate
…ch into addition_injector_crate
…ch into addition_injector_crate
…ch into addition_injector_crate
…ch into addition_injector_crate
…ch into addition_injector_crate
|
|
||
| // #[cfg(feature = "v2")] | ||
| // fn generate_connector_request_reference_id( | ||
| // &self, | ||
| // payment_intent: &hyperswitch_domain_models::payments::PaymentIntent, | ||
| // _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, | ||
| // ) -> String { | ||
| // payment_intent | ||
| // .merchant_reference_id | ||
| // .as_ref() | ||
| // .map(|id| id.get_string_repr().to_owned()) | ||
| // .unwrap_or_else(|| connector_utils::generate_12_digit_number().to_string()) | ||
| // } |
There was a problem hiding this comment.
please revert this change. seems like this is irrelevant change
| } | ||
|
|
||
| #[cfg(not(feature = "v2"))] | ||
| #[cfg(feature = "v1")] |
There was a problem hiding this comment.
if not required, please revert this
crates/injector/src/injector.rs
Outdated
| let tokens = find_all_tokens(&template); | ||
| let mut result = template; | ||
|
|
||
| for token_ref in tokens { |
…ch into addition_injector_crate
…ch into addition_injector_crate
| pub enum ContentType { | ||
| ApplicationJson, | ||
| ApplicationXWwwFormUrlencoded, | ||
| ApplicationXml, | ||
| TextXml, | ||
| TextPlain, | ||
| } |
There was a problem hiding this comment.
good that we moved to this crate.
cargo hack has been failing due to this particular structure is in hyperswitch interfaces which indirectly uses domain models and others.
but what of maintenance part? for the similar structures as well?
ps. not a blocker currently
CC: @jarnura
crates/injector/src/injector.rs
Outdated
| let method = match config.http_method { | ||
| injector_types::HttpMethod::GET => Method::Get, | ||
| injector_types::HttpMethod::POST => Method::Post, | ||
| injector_types::HttpMethod::PUT => Method::Put, | ||
| injector_types::HttpMethod::PATCH => Method::Patch, | ||
| injector_types::HttpMethod::DELETE => Method::Delete, | ||
| }; |
There was a problem hiding this comment.
we can write a from impl for this
crates/injector/src/injector.rs
Outdated
| if response_text.len() > 10_000_000 { | ||
| // 10MB limit | ||
| logger::error!( | ||
| response_length = response_text.len(), | ||
| "Response from connector is too large, potential DoS or memory exhaustion" | ||
| ); |
There was a problem hiding this comment.
why are we checking the response length? do we do this for normal connector call as well??
| let method = match request.method { | ||
| Method::Get => reqwest::Method::GET, | ||
| Method::Post => reqwest::Method::POST, | ||
| Method::Put => reqwest::Method::PUT, | ||
| Method::Patch => reqwest::Method::PATCH, | ||
| Method::Delete => reqwest::Method::DELETE, | ||
| }; |
| req_builder = req_builder.body(payload); | ||
| } | ||
| _ => { | ||
| logger::warn!("Unsupported request content type, using raw bytes"); |
There was a problem hiding this comment.
throw an error instead of warning
| } | ||
|
|
||
| #[derive(Error, Debug)] | ||
| pub enum InjectorError { |
There was a problem hiding this comment.
Ideally this HttpRequestFailed should be API error, and injector errors are different which would include TokenReplacementFailed.
| ContentType::ApplicationXml | ContentType::TextXml => { | ||
| Some(RequestContent::RawBytes(payload.as_bytes().to_vec())) | ||
| } | ||
| ContentType::TextPlain => { | ||
| Some(RequestContent::RawBytes(payload.as_bytes().to_vec())) | ||
| } |
There was a problem hiding this comment.
| ContentType::ApplicationXml | ContentType::TextXml => { | |
| Some(RequestContent::RawBytes(payload.as_bytes().to_vec())) | |
| } | |
| ContentType::TextPlain => { | |
| Some(RequestContent::RawBytes(payload.as_bytes().to_vec())) | |
| } | |
| ContentType::ApplicationXml | ContentType::TextXml | | |
| ContentType::TextPlain => { | |
| Some(RequestContent::RawBytes(payload.as_bytes().to_vec())) | |
| } |
…lt proxy (#8959) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Type of Change
Description
This is the injector crate which would be used for External Vault proxy usage
Additional Changes
Motivation and Context
Needed a generic way of passing on text as card number which would be swaped on vaults's end for not having PCI compliant data in router.
How did you test it?
Have added a test case in the crate itself
Checklist
cargo +nightly fmt --allcargo clippy