Skip to content

Commit 10a4337

Browse files
fix(router): populate profile_id in for the HeaderAuth of v1 (#6936)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent d849403 commit 10a4337

File tree

7 files changed

+29
-11
lines changed

7 files changed

+29
-11
lines changed

config/deployments/integration_test.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ outgoing_enabled = true
419419
connectors_with_webhook_source_verification_call = "paypal" # List of connectors which has additional source verification api-call
420420

421421
[unmasked_headers]
422-
keys = "accept-language,user-agent"
422+
keys = "accept-language,user-agent,x-profile-id"
423423

424424
[saved_payment_methods]
425425
sdk_eligible_payment_methods = "card"

config/deployments/production.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ outgoing_enabled = true
435435
connectors_with_webhook_source_verification_call = "paypal" # List of connectors which has additional source verification api-call
436436

437437
[unmasked_headers]
438-
keys = "accept-language,user-agent"
438+
keys = "accept-language,user-agent,x-profile-id"
439439

440440
[saved_payment_methods]
441441
sdk_eligible_payment_methods = "card"

config/deployments/sandbox.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ outgoing_enabled = true
437437
connectors_with_webhook_source_verification_call = "paypal" # List of connectors which has additional source verification api-call
438438

439439
[unmasked_headers]
440-
keys = "accept-language,user-agent"
440+
keys = "accept-language,user-agent,x-profile-id"
441441

442442
[saved_payment_methods]
443443
sdk_eligible_payment_methods = "card"

config/development.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ enabled = true
768768
file_storage_backend = "file_system"
769769

770770
[unmasked_headers]
771-
keys = "accept-language,user-agent"
771+
keys = "accept-language,user-agent,x-profile-id"
772772

773773
[opensearch]
774774
host = "https://localhost:9200"

config/docker_compose.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ source = "logs"
609609
file_storage_backend = "file_system"
610610

611611
[unmasked_headers]
612-
keys = "accept-language,user-agent"
612+
keys = "accept-language,user-agent,x-profile-id"
613613

614614
[opensearch]
615615
host = "https://opensearch:9200"

crates/router/src/services/authentication.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,13 @@ where
666666
metrics::PARTIAL_AUTH_FAILURE.add(1, &[]);
667667
};
668668

669+
let profile_id = HeaderMapStruct::new(request_headers)
670+
.get_id_type_from_header_if_present::<id_type::ProfileId>(headers::X_PROFILE_ID)
671+
.change_context(errors::ValidationError::IncorrectValueProvided {
672+
field_name: "X-Profile-Id",
673+
})
674+
.change_context(errors::ApiErrorResponse::Unauthorized)?;
675+
669676
let payload = ExtractedPayload::from_headers(request_headers)
670677
.and_then(|value| {
671678
let (algo, secret) = state.get_detached_auth()?;
@@ -687,8 +694,13 @@ where
687694
merchant_id: Some(merchant_id),
688695
key_id: Some(key_id),
689696
} => {
690-
let auth =
691-
construct_authentication_data(state, &merchant_id, request_headers).await?;
697+
let auth = construct_authentication_data(
698+
state,
699+
&merchant_id,
700+
request_headers,
701+
profile_id,
702+
)
703+
.await?;
692704
Ok((
693705
auth.clone(),
694706
AuthenticationType::ApiKey {
@@ -702,8 +714,13 @@ where
702714
merchant_id: Some(merchant_id),
703715
key_id: None,
704716
} => {
705-
let auth =
706-
construct_authentication_data(state, &merchant_id, request_headers).await?;
717+
let auth = construct_authentication_data(
718+
state,
719+
&merchant_id,
720+
request_headers,
721+
profile_id,
722+
)
723+
.await?;
707724
Ok((
708725
auth.clone(),
709726
AuthenticationType::PublishableKey {
@@ -779,6 +796,7 @@ async fn construct_authentication_data<A>(
779796
state: &A,
780797
merchant_id: &id_type::MerchantId,
781798
request_headers: &HeaderMap,
799+
profile_id: Option<id_type::ProfileId>,
782800
) -> RouterResult<AuthenticationData>
783801
where
784802
A: SessionStateInfo + Sync,
@@ -830,7 +848,7 @@ where
830848
merchant_account: merchant,
831849
platform_merchant_account,
832850
key_store,
833-
profile_id: None,
851+
profile_id,
834852
};
835853

836854
Ok(auth)

loadtest/config/development.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ client_secret = ""
396396
partner_id = ""
397397

398398
[unmasked_headers]
399-
keys = "accept-language,user-agent"
399+
keys = "accept-language,user-agent,x-profile-id"
400400

401401
[multitenancy]
402402
enabled = false

0 commit comments

Comments
 (0)