@@ -56,16 +56,27 @@ export function validatePrivateLink(
5656 next ( ) ;
5757 }
5858 const tenantInfo : ITenantConfig = await tenantManager . getTenantfromRiddler ( tenantId ) ;
59- const privateLinkEnable = tenantInfo ?. customData ?. privateEndpoints ?. accountLinkId
60- ? true
61- : false ;
59+ const privateLinkEnable =
60+ tenantInfo ?. customData ?. privateEndpoints &&
61+ Array . isArray ( tenantInfo . customData . privateEndpoints ) &&
62+ tenantInfo . customData . privateEndpoints ?. length > 0 &&
63+ tenantInfo . customData . privateEndpoints [ 0 ] ?. privateEndpointConnectionProxy
64+ ?. properties ?. remotePrivateEndpoint ?. connectionDetails &&
65+ Array . isArray (
66+ tenantInfo . customData . privateEndpoints [ 0 ] ?. privateEndpointConnectionProxy
67+ ?. properties ?. remotePrivateEndpoint ?. connectionDetails ,
68+ ) &&
69+ tenantInfo . customData . privateEndpoints [ 0 ] ?. privateEndpointConnectionProxy
70+ ?. properties ?. remotePrivateEndpoint ?. connectionDetails [ 0 ]
71+ ? true
72+ : false ;
6273 const clientIPAddress = req . ip ?? "" ;
6374 if ( privateLinkEnable && ( ! clientIPAddress || clientIPAddress . trim ( ) === "" ) ) {
6475 return handleResponse (
6576 Promise . reject (
6677 new NetworkError (
6778 400 ,
68- `Client IP address is required for private link in req.ip` ,
79+ `Client ip address is required for private link in req.ip` ,
6980 ) ,
7081 ) ,
7182 res ,
@@ -74,18 +85,20 @@ export function validatePrivateLink(
7485 const networkInfo = getNetworkInformationFromIP ( clientIPAddress ) ;
7586 if ( networkInfo . isPrivateLink ) {
7687 if ( privateLinkEnable ) {
77- const accountLinkId = tenantInfo ?. customData ?. privateEndpoints ?. accountLinkId ;
88+ const connectionDetail =
89+ tenantInfo ?. customData ?. privateEndpoints [ 0 ] ?. privateEndpointConnectionProxy
90+ ?. properties ?. remotePrivateEndpoint ?. connectionDetails [ 0 ] ;
91+ const accountLinkId = connectionDetail ?. linkIdentifier ;
7892 if ( networkInfo . privateLinkId === accountLinkId ) {
79- Lumberjack . info ( " This is a private link request" , {
93+ Lumberjack . info ( ` This is a private link request with matching link id.` , {
8094 tenantId,
81- privateLinkId : networkInfo . privateLinkId ,
8295 } ) ;
8396 } else {
8497 return handleResponse (
8598 Promise . reject (
8699 new NetworkError (
87100 400 ,
88- `This private link should not be connected since the link id ${ networkInfo . privateLinkId } does not match ${ accountLinkId } ` ,
101+ `This private link should not be connected since the link id mismatch ` ,
89102 ) ,
90103 ) ,
91104 res ,
0 commit comments