ajax - Preventing calls to php scripts from a localhost or from another domain -


i have website php scripts, of them called in ajax.
i'd prevent site malicious users try calling , using scripts site, or dummy localhost site.

i thought filtering domain name, tools easyphp , virtual host managers, can run local website tricking "domain" name.

i thought filtering ip adress of caller, guess if can trick "domain" name, can trick localhost ip.

so, how may have security work fine ?

what referring called cross site request forgery.

calling 1 of scripts website forbidden same-origin policy. taking consideration , fact ajax request can contain few headers without consent of server via cross-origin resource sharing, can send custom http header , checking header on server side, php. if header missing, request not coming own application.

you require each client send unique token each request in order fetch data. common used token method called synchronizer token pattern.

sorry long list of links included in answer, consider subject delicate 1 , security problem, think crucial read as can, many sources, in order understand problem different perspectives, available solutions , pick right 1 use case.

resources read:


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -