Jump to content

Jquery Refreshing - prevent direct access?


joecooper

Recommended Posts

You can't really. You could do things like check for the HTTP_X_REQUESTED_WITH header which jQuery sets for ajax requests and if it's not present, kill the script. All someone would have to do though is add that header to fool your script and access it directly. For someone who would even want to try and access that script directly, adding that header would be trivial.

alternatively you can output a token in a hidden field somewhere (or generate one with js as part of the ajax request payload) and check for that, but again, it's a trivial matter to circumvent. Or, you could try some "security through obscurity" by breaking it down into a chain of multiple requests. All of these (and kicken's) suggestions would help against random bots that try to request (like crawlers) and may also help weed out the more novice people, but wouldn't really help against people determined to get around it. As kicken said, bottom line is there's no way to absolutely prevent it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.