I am currently using my own authentication code for my site, which is built on .NET. I did not accept the standard Forms Auth route, since all the examples that I could find were tightly integrated with WebForms, which I do not use. For all purposes and tasks, I have all the static HTML, and any logic is executed through Javascript and web service calls. Things like logging in, logging out and creating a new account are done without even leaving the page.
Here's how it works now: in the database, I have a User ID , a Security ID and a Session ID . All three are UUIDs, and the first two never change. Each time a user logs in, I check the user table for a row that matches this username and hashed password, and I update the Session ID to a new UUID. Then I create a cookie, which is a serialized representation of all three UUIDs. For any calls to secure web services, I will deserialize this cookie to make sure that the user table has a row with these three UUIDs. This is a fairly simple system and works well, but I don’t really like the fact that a user can log in with only one client at a time. This will cause problems when creating mobile and tablet applications and already creates problems if they have several computers or web browsers. For this reason, I am going to throw away this system and move on to something new. Since I wrote this many years ago, I believe there may be something much more recommended.
I read in the FormsAuthentication class in the .NET Framework that processes cookies, and runs as an HttpModule to validate each request. I am wondering if I can take advantage of this in my new design.
It seems that cookies have no status, and sessions do not need to be tracked in the database. This is because cookies are encrypted using a private key on the server, which can also be shared in a cluster of web servers. If I do something like:
FormsAuthentication.SetAuthCookie("Bob", true);
Then, in later requests, I can be sure that Bob is indeed a valid user, as a cookie will be very difficult if not impossible to fake.
Would it make sense to use the FormsAuthentication class to replace my current authentication model? Instead of a Session ID column in the database, I relied on encrypted cookies to represent valid sessions.
Is there a third-party / open source .NET authentication framework that might work better for my architecture?
Will this authentication mechanism cause any grief with code running on mobile and tablet clients such as iPhone or Windows 8 Surface? I would suggest that this would work if these applications could handle cookies. Thanks!