Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure the answers so far are on point, but it may be me that's confused. I'm responding in particular to the part of your question that says, "not accessible over the Internet". Here's my attempt at an answer:</p> <p>The web server, not PHP, listens on a socket and accepts connections. PHP can get information about the connection from $_SERVER (<a href="http://www.php.net/manual/en/reserved.variables.server.php" rel="noreferrer">http://www.php.net/manual/en/reserved.variables.server.php</a>). Be aware that all you're checking is from whence the connection came - you can't learn anything about whether your server is available via other IP addresses from $_SERVER. For example, I can access my local instance of Apache/PHP via any of:</p> <ul> <li><a href="http://localhost/" rel="noreferrer">http://localhost/</a> ($_SERVER["SERVER_ADDR"] => ::1)</li> <li><a href="http://127.0.0.1/" rel="noreferrer">http://127.0.0.1/</a> ($_SERVER["SERVER_ADDR"] => 127.0.0.1)</li> <li><a href="http://192.168.75.121/" rel="noreferrer">http://192.168.75.121/</a> ($_SERVER["SERVER_ADDR"] => 192.168.75.121)</li> <li><a href="http://shiva.local/" rel="noreferrer">http://shiva.local/</a> ($_SERVER["SERVER_ADDR"] => fe80::21c:42ff:fe00:8)</li> </ul> <p>So, if your plan is that the app is to behave differently upon seeing the "correct" value in $_SERVER["SERVER_ADDR"], you're probably pretty safe - i.e., it's unlikely that could be spoofed by a user from a remote client.</p> <p>Having said all of that, I would not use any of these techniques for either authentication of users or authorization of user privileges/actions on a deployed application that is available over the Internet. The one exception might be if you've got an entire app that is only to be available when accessed from localhost - then this technique probably makes decent sense and will be secure enough for a personal app.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload