javascript - How to restrict access to a resource based on domain -


i've got theoretical problem i'd solve. imagine want reference external resource within html document. however, want behaviour when following link vary depending on domain of referring page (the page link).

e.g.

a page hosted @ http://somedummydomain.com/mypage.html contains link resource http://someotherdummydomain.com/mydoc.pdf?key=123456789.

when user clicks on link mydoc.pdf, mydoc.pdf returned (200 ok) if referrer somedummydomain.com - if it's other domain return 401 not authorized. significance of key in query params application serving mydoc.pdf will, internally, have associated key somedummydomain.com domain, stipulating resource can accessed via domain.

obviously check referrer, it's trivial spoof referrer in http headers so, genuinely trying lock down, referrer header not going satisfactory.

i'm kind of assuming javascript have come play in way? i'm judging based on things google analytics js code accept events occurring on page hosted @ pre-registered domain.

does know how type of behaviour achieved?


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -