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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.