1

In my web-app I need to register http clients accessing from a local network behind a router.

I started with remoteHost : remotePort combination, but soon enough it became clear, that the port numer gets regenereated upon each connection.

I need to be able to identify the clients on something similar to MAC address, some property that doesn't change. I wanted to use headers[ "X-Forwarded-For" ], but it's not present at all:

[Pragma=no-cache, Cache-Control=no-cache, Host=somhost.com:8822, Upgrade=websocket, Connection=Upgrade, Sec-WebSocket-Key=scnlM7hzjjy3cklJhJciA==, Sec-WebSocket-Extensions=x-webkit-deflate-frame,deflate-frame, Sec-WebSocket-Version=13]

What are the other options to identify clients?

injecteer
  • 20,038
  • 4
  • 45
  • 89

4 Answers4

0

One option is using cookies. As the client accesses the webapp for the first time we could set a cookie on the client side that has a very long expiry date.

During the subsequent user re-logins we can rely on this cookie as cookies get sent to the server.

0

You can try this bit of PHP to see what the server knows about an incoming http request:

$keys = array_keys($_SERVER);
echo "<table bgcolor='black' cellpadding='1' cellspacing='1'>\n";
echo "  <tr bgcolor='yellow'><td><b>Key</b></td><td><b>Value</b></td></tr>\n";
foreach ($keys as $key) {
   echo "  <tr bgcolor='white'><td>" . $key . "</td><td>" . $_SERVER[$key] . "</td></tr>\n";
}
echo "</table>\n";
hairysocks
  • 111
  • 7
0

You could use an API key, that is, a unique identifier that the clients send along with each request to identify themselves. Depending on the authentication method you are using, you could consider the standard HTTP Authorization header to send this value:

Authorization: API-Key <value goes here>

Or create a custom HTTP header for this purpose. But be careful with custom headers: proxies might strip them out.

Community
  • 1
  • 1
cassiomolin
  • 124,154
  • 35
  • 280
  • 359
0

Are you identifying the user at the keyboard or the device making the request? Do you need to track these long term or only for the duration of a use session? Do your users connect from multiple devices?

Client side id certificates could work, depending on how the local machines are managed. If they are accessing your app from someplace they've already authenticated, then setting up a single sign on solution could work. Prompting for authentication always works too.

ivanivan
  • 2,155
  • 2
  • 10
  • 11