Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: How to get client's IP address?  (Read 16275 times)
Jan S.
Posts: 9


« on: September 15, 2014, 09:14:56 am »


Hi,

I am trying to create REST service based on com.WebServiceEngine and com.HTTPServiceRequest classes.
Is there any way how to get client's IP address or hostname?
I didn't find any suitable method in com.HTTPServiceRequest class documentation.

Jan
Frank G.
Four Js
Posts: 48


« Reply #1 on: September 15, 2014, 10:18:20 am »

Hi,

  No, there is no API to get client's IP address or hostname. Actually, it is maybe not the best way to handle authentication or whatever if based on IP address, as it can change over time or be hidden if going through a proxy. But if your client set a specific HTTP header, it will be transmitted and identify the user. And if everything is done overs HTTPS, it is also completely secured.

Why do you exactly need the IP address for ?

Frank
Jan S.
Posts: 9


« Reply #2 on: September 15, 2014, 10:37:55 am »


Yes, it's for authentication purpose. I know it's not ideal, but our current authentication mechanism requires it.
I'll be sending IP in HTTP header.

Thanks for reply.

Jan
Frank G.
Four Js
Posts: 48


« Reply #3 on: September 15, 2014, 03:41:49 pm »

Hi,

  If your 4GL web service is running behind the GAS, you can get the user-agent IP address the web server (apache or IIS) gave us and that the GAS sets automatically in a HTTP header called : X-FourJs-Environment-Variable-REMOTE_ADDR.

But again, authentication based on IP address is not recommended nor guaranty.

Frank
Reuben B.
Four Js
Posts: 1116


« Reply #4 on: September 16, 2014, 12:09:27 am »

A page relevant to what Frank is referring to is hidden in the GAS documentation, see section 3b here https://4js.com/online_documentation/fjs-gas-manual-html/#c_gas_fgl_env_001.html

A good exercise would be to use the various com.HTTPServiceRequest.getRequestHeader* methods and see what is being passed through from the web server

Reuben

 

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines