I'm using ASP.NET, I use a custom authentication provider that I wrote myself, hashing and salting is in place so it should be relatively secure.
I also implemented a custom auth session mechanism which works like this.
- User signs in to the web app, the password is verified against the data in the mssql db.
- A new row is inserted to the 'sessions' table, it contains a reference to the user that is logged on, an authentication token, and an expiry date.
- The auth token is returned with a cookie , and is stored on the client's computer.
- The auth token is used to identify the user.
It works perfectly, but I'm not sure it's the right way to go, because I can see the potential security risks, for example if someone hacks into the db and changes the user id, or gets a hold of the auth token, or am I wrong?
P.S. Unfortunately I cannot use the built-in auth/session handling, because our customers requested that, plus we have to support other db engines, such as mysql, oracle/etc, so please don't suggest that :)