Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to secure my generic handler calls?

I am creating a myspace application and for some database entries I am using generic handlers which I have hosted on another website. From my myspace application I use ajax calls to those handlers to perform the activities that I want. I want to know how can I make these ajax calls secure? I mean I want to be sure that the handlers are being called by only the myspace app and not by entering url into the browser etc. Any ideas?

like image 960
ria Avatar asked Nov 06 '22 11:11

ria


1 Answers

You can secure you Generic Web Handler by doing trick with UrlReferrer for e.g

if (context.Request.UrlReferrer == null) 
 { 
      context.Response.Write("Invalid Request"); 
      return; 
 }

In addition you can check if UrlReferrer != null then domain Name must match with your incoming request url say for e.g.

 if(Request.UrlReferrer.ToString().indexOf("http://www.tyamjoli.com")!=-1)
 {
 //Valid request 
 }
like image 93
Pritam Baldota Avatar answered Nov 15 '22 06:11

Pritam Baldota