Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could always require the client to authenticate, using <a href="http://www.aswinanand.com/2009/01/http-basic-authentication-using-ajax/" rel="nofollow">HTTP Basic Auth</a> or some custom scheme. If your client requires the user to login, you can at least restrict the general public from obtaining the <code>www.companyA.com/services/service1.ashx</code> URL, since they will need to login to find out about it.</p> <p>It gets harder if you are also trying to protect the URL from unintended use by people who legitimately have access to the official client. You could try changing the service password at regular intervals, and updating the client along with it. That way a refresh of the client in-browser would pull the new password, but anyone who built custom code would be out of date. Of course, a really determined user could just write code to rip the password from the client JS programmatically when it changes, but you would at least protect against casual infringers.</p> <p>With regard to the URL token idea you mentioned in update 2, it could work something like this. Imagine every month, the <code>www.companyA.com/services/service1.ashx</code> URL requires a new token to work, e.g. <code>www.companyA.com/services/service1.ashx?token=January</code>. Once it's February, 'January' will stop working. The server will have to know to only accept current month, and client will have to know to send a token (determined at the time the client web page loads from the server in the browser)</p> <p>(All pseudo-code since I don't know C# and which JS framework you will use)</p> <p>Server-side code: </p> <pre><code>if (request.urlVars.token == Date.now.month) then render "This is the real data: [2,5,3,5,3]" else render "401 Unauthorized" </code></pre> <p>Client code (dynamic version served by your service) www.companyA.com/client/myajaxcode.js.asp</p> <pre><code>var dataUrl = 'www.companyA.com/services/service1.ashx?token=' + &lt;%= Date.now.month %&gt; // below is JS code that does ajax call using dataUrl ... </code></pre> <p>So now we have service code that will only accept the current month as a token, and client code that when you refresh in the browser gets the latest token (set dynamically as current month). Since this scheme is really predictable and could be hacked, the remaining step is to salted hash the token so no one can guess what it is going to be . </p> <pre><code>if (request.urlVars.token == mySaltedHashMethod(Date.now.month)) then </code></pre> <p>and</p> <pre><code>var dataUrl = 'www.companyA.com/services/service1.ashx?token=' + &lt;%= mySaltedHashMethod(Date.now.month) %&gt; </code></pre> <p>Which would leave you with a URL like <code>www.companyA.com/services/service1.ashx?token=gy4dc8dgf3f</code> and would change tokens every month.</p> <p>You would probably want to expire faster than every month as well, which you could do my using epoch hour instead of month.</p> <p>I'd be interested to see if someone out there has solved this with some kind of encrypted client code!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload