by billpg · 4y ago · 0 comments
In my template I’m using bcrypt and I’m doing it with every request. That might not scale well.
One commenter suggested storing a session token, probably one that expires, and not authenticating if that exists.
But, I’m using this for MVP’s to see if they’ll gain any kind of traction. Once a tool gets the kind of traction where this will be a problem it will be time to rethink the auth method.
The cache itself would be in the memory of a process which had access to cleartext passwords anyway, so presumably an exploit which allowed you to read the cache would be damning no matter what.
Once the next request, again with clear-text password, comes in you need to look up its validity. You want to check without hashing, that's the entire point. If you look up whether the hash is validly cached, you gained nothing. Hashing was required. To look up without hashing, you will need to use the clear-text password somehow. Hence it has to be part of the cache somehow, i.e. its index.
If that's all in memory in a memory-safe language, I guess it can be argued that's not unsafer than before, but I'm no expert.
Unless you store the user's password in the clear inside your user database, but will have other security issues.