cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch IP address of resquest

Former Member
0 Kudos

Hi ,

How can I fetch IP address from the request in xsjs service?

I tried with this code :

var ipAddress = $.request.headers.get("X-FORWARDED-FOR");

It is working but who ever request for service gives the same IP address.

Please suggest, how we can achieve this.

Thanks & Regards,

Desanth

View Entire Topic
Vlado
Advisor
Advisor
0 Kudos

Could it be that all your users are behind a proxy? Then you would see exactly the proxy IP address in "X-FORWARDED-FOR" as this is how they are all exposed in Internet.

Cheers,

--Vlado

Former Member
0 Kudos

Hi Vlado,

Is it the right way to fetch the IP address from the request in xsjs??

Thanks & Regards,

Desanth

Vlado
Advisor
Advisor
0 Kudos

Yes, it is. The explanation in your case is that all your users share a common single IP to the "outside world".

SvetoManolov
Employee
Employee
0 Kudos

Hi Desanth,

the question is related more to the web standards than to HANA XS specifics. That is

1) the xsjs code is correct - it obtains the value of the "X-FORWARDED-FOR" request. However ou should consider corner cases:

- note that the header might not exist

- you should consider that TupeList might contain multiple values... see

2) HTTP headers are not reliable as they can be manipulated by the end user. That is the client IP obtained from HTTP request header is not recommended to be used for security relevant decisions (e.g. access control)

Regards,

Svetoslav

Vlado
Advisor
Advisor
0 Kudos

Absolutely! I would expect it's only used for *not* security-relevant or business-critical decisions, e.g. it could be used for some kind of statistics.