We've built a WCF Rest service with various functions allowing us to access data from our database but we'd like to restrict access to these functions for obvious security reason but it doesn't have to be too complicated.
In short, this is what I had in mind:
The first steps to access our service is to call a logon function of some sort where a username and password are passed.
When authenticated against our database (or other), it would generate a token of some sort i.e. GUID will do and store this in a session or a cookie on the server.
Whenever another function is called, it would require to pass this token which would then be validated against the tokens held in sessions or cookie on the server rather than having to validate it again our database.
If it passes, the rest of the function would execute otherwise, it would throw back an error and the logon function would require to be called again.
- The session or cookie would expires every x minutes.
Questions:
Now is the above too simple?
Can you use session with wcf rest services as we may not an asp.net website or other? This would just run in IIS under http or https.
Am I better off using cookies of some sort on the server instead of session, but can these expire?
When passing the token, can I just pass it as part of my json object or should I pass this as a custom header of some sort?
Sorry if my suggestions or questions sound ridiculous or rather simplistic, but I know absolutely nothing about web authentication but everything I'm reading seems complicated for what I want to achieve. As I said, it doesn't have to be over complicated. I just want to restrict users from using this web service if they are not authorized or granted permission.
Can you redirect me to a sample? Any help or suggestion would be greatly appreciated.
I'd like to implement this before releasing to our clients.
Thanks.
Thierry
Update:
This post actual has a good visual representation of what I'm trying to achieve: