Hello, I've made a voting on comments like the one this website has(something similar), and I'm slightly concerned about possible http request misuse. You'll know what I mean after I show you the questionable code:
$.ajax({
type: 'POST',
url: 'http://localhost/comments/vote_down/' + post_id
});
Now its still on localhost but it will get to the web eventually. What if someone just makes some kind of script which will run n times
this url http://localhost/comments/vote_down/post_id
.
Not even user authentication is very helpful, you just tweak your malicious script to authenticate and you can do it again. How can I make this request more secure, what can I do? thank you
EDIT
I see some answers , not the ones I've been looking for so far.
Maybe I'm expecting too much, is there a way I can directly refuse this request to anyone but someone redirected from localhost(or website.com), after x attempts to do so .
Maybe some kind of header authentication? I'm not very into that that is the main reason why I ask.
EDIT
Also what I've discovered accidentaly about a minute or so ago, I was browsing trough few similar questions and my firebug was on, I added one question to favorites .. saw console post response 200 OK
then I tried it for like 10 times just to see when will I be rejected to do the same again.. eventually I got bored .. so if StackOverflow didn't solve that .. what am I trying to do :=)