I'm working on a very small ASP.NET ASHX web service that is running on Azure and I would like to secure. It has to be able to work without user interaction so I was thinking of just passing in some encrypted secret key to the request. But then I thought that, just in case, I should probably make that key change constantly.
So far, my idea is to generate a key in the same way both on the client and the server every 60 seconds, hash it, and use that as the key.
However, I've run into on thing I'm not sure how to handle. If it changes every 60 seconds and the client generates the key on second 59 and then it takes longer then 1 second for the server to respond to the request, it's key will no be different and the request will be denied.
Is there any good way of handling this case... maybe the key changes every 60 seconds, but is good for a few seconds after it changes?
I realize there's probably other ways to secure the service, but I already ruled out things like client side certificates for a few reasons and, in general, I'm OK with it being pretty simplistic. I just wanted it to be simpler than an unchanging password.
Thoughts?
You are obviously securing the service with HTTPs, that would be step 1.
Your identification/authentication you want the key to expire as you mention having the previous key be valid for a short timeframe. The server would auth against either of the two keys.
I would also add a third security measure...IP filtering. If this is an API that I assume will have some shared "secret" key it should, limit who can access this. This will prevent your keys getting out into the open and someone trying to attack your site maliciously if they happen to hack/acquire they key.