@@ -666,6 +666,13 @@ where
666
666
metrics:: PARTIAL_AUTH_FAILURE . add ( 1 , & [ ] ) ;
667
667
} ;
668
668
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
+
669
676
let payload = ExtractedPayload :: from_headers ( request_headers)
670
677
. and_then ( |value| {
671
678
let ( algo, secret) = state. get_detached_auth ( ) ?;
@@ -687,8 +694,13 @@ where
687
694
merchant_id : Some ( merchant_id) ,
688
695
key_id : Some ( key_id) ,
689
696
} => {
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 ?;
692
704
Ok ( (
693
705
auth. clone ( ) ,
694
706
AuthenticationType :: ApiKey {
@@ -702,8 +714,13 @@ where
702
714
merchant_id : Some ( merchant_id) ,
703
715
key_id : None ,
704
716
} => {
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 ?;
707
724
Ok ( (
708
725
auth. clone ( ) ,
709
726
AuthenticationType :: PublishableKey {
@@ -779,6 +796,7 @@ async fn construct_authentication_data<A>(
779
796
state : & A ,
780
797
merchant_id : & id_type:: MerchantId ,
781
798
request_headers : & HeaderMap ,
799
+ profile_id : Option < id_type:: ProfileId > ,
782
800
) -> RouterResult < AuthenticationData >
783
801
where
784
802
A : SessionStateInfo + Sync ,
@@ -830,7 +848,7 @@ where
830
848
merchant_account : merchant,
831
849
platform_merchant_account,
832
850
key_store,
833
- profile_id : None ,
851
+ profile_id,
834
852
} ;
835
853
836
854
Ok ( auth)
0 commit comments