I have a situation where we use the ASP.NET Core Identity Framework for the Intranet system with hooks into an old CRM database (this database can't be changed without monumental efforts!).
However, we're having customers login to a separate DBContext using identity framework, with an ID to reference back to the CRM. This is in a separate web app with shared projects between them.
This is cumbersome and causes issues when customers are merged in the CRM, or additional people are added to an account etc. Plus we do not need to use roles or any advanced features for the customer login.
So I was thinking to store the username and password in the CRM with the following process:
- Generate a random random password.
- Use the internal database ID as the salt.
- Store the Sha256 hash of the "salt + password" in the password field.
When a customer logs in, we:
- Check the Sha256 hash against the salt and given password
- If successful, store a session cookie with the fact the customer is logged in:
_session.SetString("LoggedIn", "true"); - Each request to My Account will use a
ServiceFilterto check for the session cookie. If not found, redirect to the login screen.
Questions:
- Is this secure enough?
- Should we generate a random salt? If stored in the customer table how would it be different to the internal (20 character) customer ID?
- Is there a way for the server session cookie to be spoofed? Should we store a hash in the session which we also check on each action?
Store the Sha256 hash of the "salt + password" in the password field.. Is that storing in the Identity database or the CRM database?