javascript - Preventing forge HttpRequests -
i've been searching throughout day find way figure out, without sucess , thought maybe here ? trying use secrete password in .js file can't write directly in file because see when accessing source code. e.g need send password using ajax page make sure httprequest website not forge httprequest .
possible because i've tried else authentication forms didn't help.
i'm using asp.net , httphandler page returns data .
what can generate key valid set time using php so:
$password = "some random string"; $key = md5($password . $_server['request_time']) . "|" . $_server['request_time'];
this way know when key generated, , if it's been tampered because:
function check($key) { list($hash, $timestamp) = explode("|", $key, 2); if ($hash !== md5($password . $key)) { throw new exception("naughty!"); } if ($timestamp < $_server['request_time'] < 60*60) { throw new exception("too old"); } }
the down side people don't refresh page (in example 1 hour) key expire.
another issue 'attacker' technically first scrape page new key , use that, , scrape again when expires , on.
this solution works protecting against hotlinking.
Comments
Post a Comment