I'm building a Django website with MySQL. I've already decided to use Django's built in pbkdf2-sha256 with randomly generated salt hash to store a user's password.
However this website will also need to store third party login credentials for many other websites (who don't use oauth). So I was looking into AES-256 encryption and of course the issue becomes where to securely store the encryption key.
Now here's my solution: Let each encryption key = the hash of the users actual password and a randomly generated salt (different from the salt already used for the password stored hash). The salt would be stored in the table, the actual password and the hash of it obviously not. So the encryption key would be generated on login and stored temporarily but expire on logout. Further someone compromising the server can't generate the encryption key without cracking the original pbkdf2-sha256 hash and even then, it would only be for that one user, not a universal key.
The downside is that if they change/reset password, they would have to re-enter their credentials for each site. But that's not a huge deal and seems to be way more secure than storing the key somewhere on the server or even a different server.
But I only learned what a hash is 24 hours ago so what do I know. Am I overlooking something or is this reasonably secure? Or is there a better way?