Re: Changing IP sent on header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/05/2014 6:41 AM, Ricardo R Bonfim wrote:
Done!!

Not sure why but after changing the value from header key from array
to string on the stream context creation, it worked perfectly!

Thanks Aziz =)

2014-05-02 17:11 GMT-03:00 Ricardo R Bonfim <ricobonfim@xxxxxxxxx>:
Well.. after searching for a while I found the same workaround...

but no success on changing the HTTP_X_FORWARDED_FOR header value until now...

Here's how my soapclient class is working to solve the problem..

class MySoapClient extends SoapClient {

     public function __construct( $wsdl ) {
         $options = array(
             'trace' => 1,
             'exceptions' => 1,
             'stream_context' => stream_context_create( array(
                 'http' => array(
                     'header' => array(
                         'X-FORWARDED-FOR: ' . $_SESSION['ip'],
                         ),
                     )
                 ),
             );

         parent::__construct( $wsdl, $options );
     }

}

No error, but no HTTP_X_FORWARDED_FOR on the SoapServer too =(

I found this bug report ( https://bugs.php.net/bug.php?id=49853 )
which seems to explain why it's not working...
I was using PHP Version 5.2.17 when started the development, then I
changed to PHP Version 5.4.4-14, but no luck on this version too...

Had anyone succeed in changing the http header before sending the soap request?

2014-05-02 16:05 GMT-03:00 Aziz Saleh <azizsaleh@xxxxxxxxx>:



On Fri, May 2, 2014 at 10:45 AM, Ricardo R Bonfim <ricobonfim@xxxxxxxxx>
wrote:

Hello,

I have a webservice which uses Soap to interact with clients, and I
want to log which is the IP I'm receiving requests from.
In a first moment, the requests will be sent directly from client
machine, by their own implementation of soap client, and I can get
their IPs looking on $_SERVER['REMOTE_ADDR'] variable, which's fitting
perfectly at the moment.
However, I've create a client page, which implements the soap client,
for users who don't want to implement could use.
The problem is:

My page is callling the webservice by ajax, which is getting me some
trouble to find the client IP who is using the system.

The use case would look like:

1- The Client log into the system.
2- The Client access the "client page".
3- The Client click on "Begin Transaction".
4- System sends an ajax request to the server to begin the transaction.
5- System receive the ajax request, and call the soap function
(SoapClient) to begin the transaction.
6- System (SoapServer) receive the request,save the Client IP and
returns 1 for sucess.

I have the right Client IP until setp #5 using the IP stored on
$_SESSION on step #1.

I thought that I could change the IP from REMOTE_ADDR when sending the
request on step #5, but I haven't found a way to do that..

Anyone has an idea on how to solve this problem?

--
Att,
____________________________________________________
Ricardo R Bonfim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Your system is acting as a proxy to the user. You will need to add (or
modify) the HTTP_X_FORWARDED_FOR header to the user IP. Since Javascript
can't detect user IP, you can do the following:

...
3 - Store the user IP in a session. The client click on "Being Transaction"
...
5 - Make the Soap call sending the new header with the IP in session.

If you are the owner of the Soap Server, then you check for that IP,
otherwise you might want to contact the owner to make it so that it is
checked first.

Aziz



--
Att,
____________________________________________________
Ricardo R Bonfim



If you have implemented a web client and there is an Ajax request made to your SOAP service, you still can ascertain the individual IP address, you couldforward the ip address information as part of the data component of the Ajax Request and then extract this at the service level.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux